pax_global_header00006660000000000000000000000064143521155750014522gustar00rootroot0000000000000052 comment=4e8bbf8fc4941e5da301a8b3db8d27e98de68666 python-xlib-0.33/000077500000000000000000000000001435211557500137245ustar00rootroot00000000000000python-xlib-0.33/.gitignore000066400000000000000000000014271435211557500157200ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python env/ build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *,cover .hypothesis/ # Translations *.mo *.pot # Django stuff: *.log # Sphinx documentation docs/_build/ # PyBuilder target/ # IntelliJ .idea/ # Visual Studio Code .vscode/ /.mypy_cache/ python-xlib-0.33/.landscape.yml000066400000000000000000000000551435211557500164570ustar00rootroot00000000000000python-targets: [2, 3] mccabe: run: false python-xlib-0.33/.travis.yml000066400000000000000000000031641435211557500160410ustar00rootroot00000000000000language: python python: - "2.7" - "3.4" - "3.5" - "3.6" - "3.7" - "3.8" - "3.9" # command to install dependencies install: - pip install -r requirements.txt - pip install -r dev-requirements.txt # command to run tests script: python -W all runtests.py --with-coverage --cover-html --cover-html-dir=Coverage_report after_success: - codecov before_deploy: # Generate source distribution. # Note: only do this with Python 3.5 because the contents # of the distribution are the same for all versions. - case "$TRAVIS_PYTHON_VERSION" in 3.5) python setup.py sdist --formats=bztar;; esac # Generate wheel distribution. # Note: only do this once, since we create a universal wheel. - case "$TRAVIS_PYTHON_VERSION" in 3.5) python setup.py bdist_wheel;; esac deploy: - provider: releases api_key: secure: "kZHDE09hKehX8bFRWa5qM56J3ujc3Stl5j2u9KfdXwmZyYlremZTJ5J9gdiLqqRrTI1jF5n+3miacYSdups1VSqgXYsGzoz99HurtcoMfkFxWkkeCnd6ORwvTXYFN28t2CcjWXV6jCyUABPaEv8TCK3/+LeFfuf30O5Hxg/KiUfpqBwXj6sWaht0whhay45r6D5nYb8omhqa7n4DDLlrStRqkp1SB895EElessFFuHjn/jkxlyEUjGjQ+x79h8JKiXVozYRcyb4eC75xIaE6+yeA6q2ZxMrNRdBnWbRrFBNYsx4QbMCe9vq2m0IQMkrh0kk5N53eA6/8Yy6ZpDUNAb/Alvql8+y/qWwVQl3TYwcMGd0PctmfGH6rElByiOIVV9Zv52hTK9jXky0ab+avLufXlL8tUDVSNReXR7En37vbxlq+AU+xNhHN3girkJJ7jU6saQpj1tROGBpPkLIIHQFh3dbubfgw9qdW5qYBZyLHK9yKNnlzFIr7yktqJvJ/jGz/YDER12UdlCzaoWtVdw8Ogm9faAFlMUvzExYt5BIneDYUe13GtoDw69aLiuq5YGcFKClsgDIqBqYYBTVIHwAS9kTV4CZV0L4C15ylmUIP68LFxZ/stufXW0MJxvhIaJ7gJ9d9LyCK1a0u0j5a78cX/OUx9RfqjOMCuVbGTys=" file_glob: true file: - dist/*.tar.* - dist/*.whl on: tags: true skip_cleanup: true python-xlib-0.33/CHANGELOG.md000066400000000000000000000350541435211557500155440ustar00rootroot00000000000000NEWS for Python X Library Version 0.33 ============ Bug Fixes --------- - Removed unused imports (thanks @Avasam). - Avoid to use fcntl module on some environments (thanks @i2y). - Change a test behavior for `unix_connect.get_socket` (thanks @i2y). - Fix accidental data change (thanks @Avasam). - Prefer `bool` over `Literal[0, 1, None]` (thanks @Avasam). - Change parentheses to brackets in LICENSE (thanks @mtelka). --- Version 0.32 ============ Bug Fixes --------- - Use archived link for X documentation resource (thanks @yaxollum). - Fix for auth entry having no display number (thanks @Majiir). - Fix return type inconsistency with the `pack_value` for class `Object` (thanks @allfro). - Rename `add_extension_error` method to `extension_add_error` (thanks @mattalexx). Extensions -------------------- - screensaver: fix screensaver protocol mismatch (thanks @yut23). - XRandr: add version 1.5 support for RRSetMonitor RRGetMonitors and RRDeleteMonitors (thanks @allfro and @jklong). --- Version 0.31 ============ Extensions -------------------- - XInput: add event methods (thanks @dd4e). --- Version 0.30 ============ Extensions -------------------- - XResource: first implementation (thanks @alebastr). - XRandr: add missing parameters to delete_output_mode function (thanks @jimmy-loyola). --- Version 0.29 ============ Extensions -------------------- - Drawable & XInput: Avoid using array.array.tostring() which wiil be removed in Python 3.9 (thanks @t-wissmann). --- Version 0.28 ============ Extensions -------------------- - DPMS: Display Power Management Signaling (by @thiagokokada) --- Version 0.27 ============ Bug Fixes --------- - fix TypeError in socket.error exception handling for Python 3.x (by @t-wissmann) Extensions -------------------- - NV-CONTROL: set offset for all perf levels (by @Sporif) --- Version 0.26 ============ Bug Fixes --------- - support legacy X servers like RealVNC's one (by @Gerardwx) Extensions -------------------- - enrich XFixes extension with XFixesSelectionNotify events (by @acrisci) - add example xfixes-selection-notify.py (by @acrisci) - fix two issues in NV-CONTROL extension (by @leinardi) - add method get_clock_info into NV-CONTROL extension (by @leinardi) - add default client version into Composite extension (by @jakogut) - add Damage extension with the example (by @mgarg1 and @jakogut) --- Version 0.25 ============ Bug Fixes --------- - fix increasing memory usage on display instantiation NV-CONTROL extension -------------------- - add first implementation by Roberto Leinardi (@leinardi) --- Version 0.24 ============ Bug Fixes --------- - fix protocol handling: correctly support explicit Unix connections and fix support fox macOS - improve Python 3 support: fix events sub-code handling and possible crashes when unpacking text data - add support for error handlers to the Composite extension Misc ---- - fix `xfixes` example - fix a bunch of typos in the code / documentation --- Version 0.23 ============ Bug Fixes --------- - fix strings decoding: use Latin-1 --- Version 0.22 ============ Bug Fixes --------- - fix `Display.change_pointer_control` implementation - fix `Drawable.put_pil_image` implementation --- Version 0.21 ============ Bug Fixes --------- - fix use under Windows Subsystem for Linux: when DISPLAY does not specify a protocol, and the implicit Unix socket connection fails, fallback to TCP (mimicking XCB's behavior). Misc ---- - don't bundle a copy of texi2html to build the HTML documentation, but use the currently installed version instead. --- Version 0.20 ============ Bug Fixes --------- - fix unclosed file in Xauth implementation - fix support for `Window.set_wm_transient_for` - fix support for `Drawable.put_image` / `Drawable.get_image` - use ASCII for decoding strings in Python 3 (same as Python 2) - fix Python 3 warnings about `array.tostring()` (deprecated) Misc ---- Improve response processing performance: reduce the number of `socket.recv` calls needed to receive a full response. --- Version 0.19 ============ Bug Fixes --------- - don't throw an exception if `$XAUTHFILE` / `~/.Xauthority` is missing - fix authentication work-around for SSH forwarding under Python 3 - improve `$DISPLAY` handling: support optional protocol prefix, and correctly handle `unix:0.0` as `:0.0` --- Version 0.18 ============ Bug Fixes --------- - fix Python 3 buffer abstraction - fix interrupted select handling for Python 3.3/3.4 - fix Unix socket support when only an abstract address is available --- Version 0.17 ============ Bug Fixes --------- - fix Xauth handling when using Python 2 and DISPLAY contains a remote IP - fix String16 request field handling when using Python 3 - fix RECORD extension and example when using Python 3 - fix handling of properties: use byte strings for all X11 8-bits strings, as not all of them are text properties (the window getters/setters for `wm_name`, `wm_icon_name`, `wm_class`, and `wm_client_machine` still return/expect Unicode strings) API Changes ----------- Core: - new window getter/setter for text properties: `get_full_text_property` and `change_text_property`; with automatic conversion to/from Unicode when the property type encoding is supported (`STRING` and `UTF8_STRING`) Composite extension: - support for `GetOverlayWindow` request --- Version 0.16 ============ Licensing --------- The project is now licensed under the GNU Lesser General Public License v2.1 or later (see the LICENSE file for details). Compatibility ------------- Support for Python versions older than 2.7 has been dropped. Support for Python 3 (3.3, 3.4 and 3.5) has been added. Note that Python-Xlib now depends on the six package (>=1.10) for combined Python 2 / 3 support. API Changes ----------- With the change of license, and no way to contact the original author of the SHAPE extension, the code had to be rewritten from scratch. This resulted in a few minor API changes (see [examples/shapewin.py](examples/shapewin.py)). Partial support for the SECURITY. XInput, and XFIXES extensions has been added. Bug Fixes --------- - fix RECORD extension - fixed OS X socket path - fix handling of generic events - fix handling of KeymapNotify events - several fixes for the RandR extension --- Version 0.15rc1 - 14 Nov 2009 ============================= Improved support for newer versions of Mac OS X, a couple of new extensions, and several bugfixes. Composite extension ------------------- Support for the composite extension, used to implement a composition manager (added for plcm work in plwm). By itself this extension is not very useful, it is intended to be used together with the DAMAGE and XFIXES extensions. Typically you would also need RENDER or glX or some similar method of creating fancy graphics. XF86 special function keysyms ----------------------------- Keysym definitions for special function keys found on modern keyboards, e.g. raise and lower volume, start specific applications, etc. Have a look in [Xlib/keysymdef/xf86.py](Xlib/keysymdef/xf86.py) to see what there are and experiment with xev to see what your keyboard generates. These definitions aren't brought in by default, so you must do this after importing `Xlib.XK`: ```python Xlib.XK.load_keysym_group('xf86') ``` RANDR extension --------------- The RANDR extension complements XINERAMA as a way of getting data about the physical screens making up a virtual screen in X. An example of usage can be found in [examples/xrandr.py](examples/xrandr.py). --- Version 0.14 - 1 Oct 2007 (trialed as 0.14rc1 on 10 Jun 2007) ============================================================= A couple of new extensions, a Python 2.5 fix and a couple of aliases (`Display.get_atom()` now uses the internal cache and added `Window.raise_window()`). Tabs converted to spaces (SF id: 1559082). RECORD extension (SF id: 1538663) --------------------------------- Alex Badea contributed a RECORD extension module, allowing Python Xlib programs to capture mouse and keyboard events (or all other core or extension events) easily. A demo is in the examples directory. See for more information. XINERAMA extension ------------------ Mike Meyer contributed a Xinerama extension module, allowing Python Xlib programs to interrogate the X server about positions and sizes of multiple screens. Specifications are a bit tricky to find - has some older specs and the source code of the xorg project (libs & server code) has "definitive" information. Python 2.5 fix (SF id: 1623900) ------------------------------- Bugfix to correct handling of XAuthority file parsing under Python 2.5 causing failed authentication. --- Version 0.13 - 6 Aug 2006 (trialed as 0.13pre1 on 22 Jul 2006) ============================================================== A small release to incorporate a number of minor corrections and bug fixes, including small changes to keysym handling, `.Xauthority` parsing, several fixes to sending/receiving/flushing data, addition of `WithdrawnState` to `WMHints`. petli completed documentation for `Display` objects. --- Version 0.12 - 29 Mar 2002 ========================== SHAPE extension --------------- Jeffrey Boser contributed a SHAPE extension module, allowing Python Xlib programs to use shaped windows. Take a look at examples/shapewin.py for ideas on how to use it. For more information on shaped windows, see Python 2.2 fix -------------- In Python 2.2 `FCNTL.FD_CLOEXEC` has disappeared and `FCNTL` on the whole is deprecated, so that had to be dealt with to make the Xlib work with that version. --- Version 0.11 - 23 Feb 2002 ========================== Regression tests for the protocol definition -------------------------------------------- Regressions tests have been created for all requests, replies and events. The tests use PyUnit, and the old resource database test has been updated to use it too. A lot of protocol bugfixes -------------------------- The bugs discovered by the regression tests have been fixed. Additionally, a subtle bug in the core engine which could cause a "can't happen"-error has also been found and fixed. --- Version 0.10 - 16 Dec 2001 ========================== Event bugfix ------------ The xlib failed to parse the type code of events sent from other clients using `SendEvent`. This has been fixed, adding the field `send_event' to all event objects. Event documentation ------------------- The section "Event Types" in the manual has been written, detailing all event types in the core protocol. The manual is now ten pages thicker. Basic support for GetImage/PutImage ----------------------------------- The Drawable methods `put_image()` and `get_image()` have been implemented, but handling image data is still up to the user. There is however, thanks to Ilpo Nyyssönen, a trivial method `put_pil_image()` that will work on some combinations of image and drawable depth. It's not perfect, but it's a start. --- Version 0.9 - 4 Dec 2001 ======================== Documentation improved ---------------------- The documentation has been augmented with a chapter about event handling, and a chapter listing all X objects and their methods provided by the library. They are not described in any detail, though. Keysym handling improved ------------------------ The module `Xlib.XK`, which listed all keysyms, have been split up into several sub-modules providing different sets of keysyms. By importing `Xlib.XK` only the miscellany and latin1 sets are loaded, thus removing some unnecessary clutter. `Xlib.display.Display` has two new methods (`lookup_string()` and `rebind_string()`) for translating keysyms into characters. Small changes to library interface ---------------------------------- The order of the `Xlib.display.Display` method `send_event()` parameters `event_mask` and propagate has changed. Some of the class names in `Xlib.protocol.event` have changed, to have the same name as the corresponding event type constant. A few bugfixes -------------- If a display has more than one screen, the default screen was always set to the highest numbered one, irrespective of what the user specified in `$DISPLAY`. Some response attributes in `Xlib.protocol.request` accidentally included a comma. --- Version 0.8 - 12 Jan 2001 ========================= Uses distutils -------------- Python Xlib now uses distutils to make installation and distribution building easier. Tested with Python 2.0 ---------------------- A few incompatibilities with Python 2.0 has been fixed. --- Version 0.7 - 8 Jan 2001 ======================== Fixed the 64-bit platform fix. ------------------------------ As it turns out, the attempted fix for 64-bit platforms in v0.6 didn't really work. Close study of structmodules.c gave the answer why, and now it really should work. Yeah. Optimizations of core protocol engine ------------------------------------- Python Xlib is now at least 25% faster after the core of the protocol engine has been rewritten. This is some quite cute code: tailor-made methods are generated for all structures, resulting in a 650% speed-up in generating binary data, and a 75% speed-up in parsing binary data. Interested Python hackers are recommended to take a look at the Struct class in `Xlib/protocol/rq.py`. --- Version 0.6 - 29 Dec 2000 ========================= Fix to make python-xlib work on 64-bytes architectures. ------------------------------------------------------- The struct and array modules uses `sizeof(long)` to determine the number of bytes used when representing the type code 'l'. On Intel and VAX, this is 32 bits as expected. On Alpha, it's 64 bits. python-xlib now probes how large each type code is to avoid this problem. --- Version 0.5 - 28 Dec 2000 ========================= - Functions implemented to get and set all ICCCM WM properties on Window objects. - Keymap cache implemented, with external `Xlib.display.Display` methods `keycode_to_keysym`, `keysym_to_keycode`, `keysym_to_keycodes` and `refresh_keyboard_mapping`. - Two utils for debugging X traffic implemented. `utils/tcpbug.py` forwards a TCP connection and outputs the communication between the client and the server. This output can then be fed into `utils/parsexbug.py`, which will output all requests, responses, errors and events in a readable format. --- Version 0.4 - 4 Oct 2000 ======================== - Thread support completed, but not really stress-tested yet. - A framework for handling different platforms has been implemented, together with generic Unix code and some simple VMS code. - Some documentation has been written. - The usual bunch of bugfixes. python-xlib-0.33/LICENSE000066400000000000000000000635351435211557500147450ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. {description} Copyright (C) {year} {fullname} This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. {signature of Ty Coon}, 1 April 1990 Ty Coon, President of Vice That's all there is to it! python-xlib-0.33/README.rst000066400000000000000000000112041435211557500154110ustar00rootroot00000000000000The Python X Library ==================== |Build Status| |codecov.io| |Code Health| `Homepage`_ | `Releases`_ | `Changelog`_ Copyright ~~~~~~~~~ The main part of the code is :: Copyright (C) 2000-2002 Peter Liljenberg Some contributed code is copyrighted by `the contributors `_, in these cases that is indicated in the source files in question. The Python X Library is released under LGPL v2.1 or later (since 2016), see the file LICENSE for details. 0.15rc1 and before were released under GPL v2. Requirements ~~~~~~~~~~~~ The Python X Library requires Python 2.7 or newer. It has been tested to various extents with Python 2.7 and 3.3 through 3.6. The Python X Library will only work on systems that have an X server installed, such as most Linux distros, but will not work on Windows or MacOS. Installation ~~~~~~~~~~~~ The Python Xlib uses the standard setuptools package, to install run this command: :: python setup.py install See the command help for details: ``python setup.py install -h``. Alternatively, you can run programs from the distribution directory, or change the module path in programs. There's a simple example program, implemented twice using both the high-level interface and the low-level protocol. Introduction ~~~~~~~~~~~~ The Python X Library is intended to be a fully functional X client library for Python programs. It is written entirely in Python, in contrast to earlier X libraries for Python (the ancient X extension and the newer plxlib) which were interfaces to the C Xlib. This is possible to do since X client programs communicate with the X server via the X protocol. The communication takes place over TCP/IP, Unix sockets, DECnet or any other streaming network protocol. The C Xlib is merely an interface to this protocol, providing functions suitable for a C environment. There are three advantages of implementing a pure Python library: - Integration: The library can make use of the wonderful object system in Python, providing an easy-to-use class hierarchy. - Portability: The library will be usable on (almost) any computer which have Python installed. A C interface could be problematic to port to non-Unix systems, such as MS Windows or OpenVMS. - Maintainability: It is much easier to develop and debug native Python modules than modules written in C. Documentation ~~~~~~~~~~~~~ The reference manual is not finished by far, but is probably still useful. It can be `browsed online `__. There are also some `example programs `_ and, of course, `the standard X11 documentation `__ applies. Project status ~~~~~~~~~~~~~~ The low-level protocol is complete, implementing client-side X11R6. The high-level object oriented interface is also fully functional. It is possible to write client applications with the library. Currently, the only real application using Python Xlib is the window manager PLWM, starting with version 2.0. There is a resource database implementation, ICCCM support and a framework for adding X extension code. Several extensions have been implemented (RECORD, SHAPE, Xinerama, Composite, RANDR, DAMAGE, Generic Event, SECURITY, XFIXES, XInput, XTEST, NV-CONTROL, DPMS and XRes); patches for additions are very welcome. There are most likely still bugs, but the library is at least stable enough to run PLWM. A continuously bigger part of the library is covered by regression tests, improving stability. The documentation is still quite rudimentary, but should be of some help for people programming with the Xlib. X beginners should first find some general texts on X. A very good starting point is http://www.rahul.net/kenton/xsites.html See the file TODO for a detailed list of what is missing, approximately ordered by importance. .. _Homepage: https://github.com/python-xlib/python-xlib .. _Releases: https://github.com/python-xlib/python-xlib/releases .. _Changelog: https://github.com/python-xlib/python-xlib/tree/master/CHANGELOG.md .. _Contributors: https://github.com/python-xlib/python-xlib/graphs/contributors .. _Examples: https://github.com/python-xlib/python-xlib/tree/master/examples .. |Build Status| image:: https://travis-ci.org/python-xlib/python-xlib.svg?branch=master :target: https://travis-ci.org/python-xlib/python-xlib .. |codecov.io| image:: https://codecov.io/github/python-xlib/python-xlib/coverage.svg?branch=master :target: https://codecov.io/github/python-xlib/python-xlib?branch=master .. |Code Health| image:: https://landscape.io/github/python-xlib/python-xlib/master/landscape.svg?style=flat :target: https://landscape.io/github/python-xlib/python-xlib/master python-xlib-0.33/TODO000066400000000000000000000032321435211557500144140ustar00rootroot00000000000000 *** To be a real C Xlib replacement * High-level functions: currently, there are mostly methods which directly correspond to X requests. There should be some simpler functions (e.g. Window.resize_window() in addition to Window.configure(), Drawable.rectangle() in addition to Drawable.poly_rectangle(), etc), and possibly also compound functions (e.g. create_pixmap_from_image() which would load an image file and create a pixmap of it). * Events: advanced event queue handling, e.g. filtering out events, only process events for a certain window, etc. * Extensions: as many extensions as possible should be implemented. *** Miscellaneous * Faster, faster! The protocol engine isn't very fast, despite the optimizations in version 0.7. I've started on this, but it is a big job. * The tread support and the protocol engine needs to be stress tested. They _seem_ to work, but that's no guarantee. * Much more documentation. * Test suite: a test suite which exercises the entire library would definitely be a nice thing to have. A start has been made for this, testing the protocol definitions. * Porting: the library should be runnable wherever there is a Python interpreter (with the necessary IPC support, that is.) * Widget set: a Python-optimized widget set using the X library would be really cute. The AnyGUI project could be a good front-end to use. * Server-side support: while we're at it, why not extend the library to provide at least the server-side parsing of the X protocol? It could be usable for writing X proxies, or for that matter, a complete X server in Python (this might be a little too spaced-out, though...) python-xlib-0.33/Xlib/000077500000000000000000000000001435211557500146225ustar00rootroot00000000000000python-xlib-0.33/Xlib/ChangeLog000066400000000000000000000101221435211557500163700ustar00rootroot000000000000002007-06-10 Mike Grant * (many files): (mgg) Converted tabs to spaces throughout the codebase, using reindent.py (SF id: 1559082) 2007-03-18 Mike Grant * Xlib/display.py: (mgg) Added a get_atom alias that uses the internal cache * Xlib/xobject/drawable.py: (mgg) Added a raise_window() alias to the Window class 2007-02-15 Mike Grant * Xlib/xauth.py: (mgg) Python 2.5 didn't like the way the buffer type was used, resulting in X authorisation failure, so reverted to using slices 2006-11-22 Mike Grant * Xlib/ext/record.py: Addition of RECORD extension by Alex Badea , SF patch id #1538663 (demo program in python-xlib/examples/record_demo.py) 2006-09-20 Mike Meyer * Xlib/ext/xinerama.py: (mwm) Addition of Xinerama extension 2006-07-22 Mike Grant Various typo fixes, general updates. Changelog hasn't been maintained since 2002, but some of the more significant comments from cvs logs follow: * Xlib/display.py: (petli) Fix bug in refresh_keyboard_mapping: ignore modifier and pointer remappings. Plays nice with pydoc. Copied some text from the docs to __doc__ strings in Xlib/display.py so that they appear when you use pydoc. Completed documentation for Display objects. * Xlib/XK.py: (calroc99) Minor doc string changes. Called load_keysym_group() for miscellany and latin1 keysyms, rather than importing the modules. * Xlib/keysymdef/*: (calroc99) Small change to keysym loading. Works the same way. * Xlib/support/*, Xlib/xauth.py, Xlib/error.py: (petli) Added ~/.Xauthority parsing by Python code instead of relying on /usr/X11R6/bin/xauth. Not activated yet in all cases yet? Activated in unix_support.py. * Xlib/xobject/drawable.py: (petli) Fix bugs in definition and method of GrabButton/Pointer * Xlib/xobject/icccm.py: (petli) Add WithdrawnState to WMHints * doc/*: (petli) documentation updates, typos and completing documentation for Display objects 2002-03-30 Peter Liljenberg * support/unix_connect.py: Handle fcntl/FCNTL changes in Python 2.2. 2002-03-11 Peter Liljenberg * xobject/drawable.py (Drawable.fill_arc): This should be a PolyFillArc. Fri Jan 19 17:49:45 2001 Peter Liljenberg * XK.py: Moved all keysyms into separate modules, based on their category. By default only the miscellany and latin1 keysyms are loaded, and other have to be loaded by importing the Xlib.keysymdef. module, or calling load_keysym_group('category'). * display.py (Display.lookup_string): (Display.rebind_string): Functions to translate keysyms to strings, and binding keysyms to new strings. 2001-01-16 * xobject/drawable.py (Window.send_event): * display.py (Display.send_event): Changed the order of the event_mask and propagate arguments. 2001-01-10 * display.py (Display._update_keymap): The first half of the update algorithm operated on an earlier type of code->sym map than the second half. Stupid, stupid. It would have been nice with a type-checker now. Tue Jan 9 13:03:19 2001 Peter Liljenberg * display.py (Display._update_keymap): Fixed call to append with 1.5.2 semantics, broke in newer Pythons. 2000-12-22 * display.py (Display.keycode_to_keysym): (Display.keysym_to_keycode): (Display.keysym_to_keycodes): (Display.refresh_keyboard_mapping): (Display._update_keymap): Added keymap cache implementation. 2000-12-21 * xobject/colormap.py (Colormap.alloc_named_color): Extended to handle #000000 style color specifications. * xobject/drawable.py (Window.reparent): Renamed from reparent_window. * display.py (Display.set_error_handler): Added. 2000-12-20 * display.py (_BaseDisplay): Implement a cache of atom names. python-xlib-0.33/Xlib/X.py000066400000000000000000000240271435211557500154100ustar00rootroot00000000000000# Xlib.X -- basic X constants # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Avoid overwriting None if doing "from Xlib.X import *" NONE = 0 ParentRelative = 1 # background pixmap in CreateWindow # and ChangeWindowAttributes CopyFromParent = 0 # border pixmap in CreateWindow # and ChangeWindowAttributes # special VisualID and special window # class passed to CreateWindow PointerWindow = 0 # destination window in SendEvent InputFocus = 1 # destination window in SendEvent PointerRoot = 1 # focus window in SetInputFocus AnyPropertyType = 0 # special Atom, passed to GetProperty AnyKey = 0 # special Key Code, passed to GrabKey AnyButton = 0 # special Button Code, passed to GrabButton AllTemporary = 0 # special Resource ID passed to KillClient CurrentTime = 0 # special Time NoSymbol = 0 # special KeySym #----------------------------------------------------------------------- # Event masks: # NoEventMask = 0 KeyPressMask = (1<<0) KeyReleaseMask = (1<<1) ButtonPressMask = (1<<2) ButtonReleaseMask = (1<<3) EnterWindowMask = (1<<4) LeaveWindowMask = (1<<5) PointerMotionMask = (1<<6) PointerMotionHintMask = (1<<7) Button1MotionMask = (1<<8) Button2MotionMask = (1<<9) Button3MotionMask = (1<<10) Button4MotionMask = (1<<11) Button5MotionMask = (1<<12) ButtonMotionMask = (1<<13) KeymapStateMask = (1<<14) ExposureMask = (1<<15) VisibilityChangeMask = (1<<16) StructureNotifyMask = (1<<17) ResizeRedirectMask = (1<<18) SubstructureNotifyMask = (1<<19) SubstructureRedirectMask = (1<<20) FocusChangeMask = (1<<21) PropertyChangeMask = (1<<22) ColormapChangeMask = (1<<23) OwnerGrabButtonMask = (1<<24) #----------------------------------------------------------------------- # Event names: # # Used in "type" field in XEvent structures. Not to be confused with event # masks above. They start from 2 because 0 and 1 are reserved in the # protocol for errors and replies. # KeyPress = 2 KeyRelease = 3 ButtonPress = 4 ButtonRelease = 5 MotionNotify = 6 EnterNotify = 7 LeaveNotify = 8 FocusIn = 9 FocusOut = 10 KeymapNotify = 11 Expose = 12 GraphicsExpose = 13 NoExpose = 14 VisibilityNotify = 15 CreateNotify = 16 DestroyNotify = 17 UnmapNotify = 18 MapNotify = 19 MapRequest = 20 ReparentNotify = 21 ConfigureNotify = 22 ConfigureRequest = 23 GravityNotify = 24 ResizeRequest = 25 CirculateNotify = 26 CirculateRequest = 27 PropertyNotify = 28 SelectionClear = 29 SelectionRequest = 30 SelectionNotify = 31 ColormapNotify = 32 ClientMessage = 33 MappingNotify = 34 LASTEvent = 35 # must be bigger than any event #----------------------------------------------------------------------- # Key masks: # # Used as modifiers to GrabButton and GrabKey, results of QueryPointer, # state in various key-, mouse-, and button-related events. # ShiftMask = (1<<0) LockMask = (1<<1) ControlMask = (1<<2) Mod1Mask = (1<<3) Mod2Mask = (1<<4) Mod3Mask = (1<<5) Mod4Mask = (1<<6) Mod5Mask = (1<<7) #----------------------------------------------------------------------- # Modifier names: # # Used to build a SetModifierMapping request or to read a # GetModifierMapping request. These correspond to the masks defined above. # ShiftMapIndex = 0 LockMapIndex = 1 ControlMapIndex = 2 Mod1MapIndex = 3 Mod2MapIndex = 4 Mod3MapIndex = 5 Mod4MapIndex = 6 Mod5MapIndex = 7 #----------------------------------------------------------------------- # Button masks: # # Used in same manner as Key masks above. Not to be confused with button # names below. Note that 0 is already defined above as "AnyButton". # Button1Mask = (1<<8) Button2Mask = (1<<9) Button3Mask = (1<<10) Button4Mask = (1<<11) Button5Mask = (1<<12) AnyModifier = (1<<15) # used in GrabButton, GrabKey #----------------------------------------------------------------------- # Button names: # # Used as arguments to GrabButton and as detail in ButtonPress and # ButtonRelease events. Not to be confused with button masks above. # Note that 0 is already defined above as "AnyButton". # Button1 = 1 Button2 = 2 Button3 = 3 Button4 = 4 Button5 = 5 #----------------------------------------------------------------------- # XXX These still need documentation -- for now, read # NotifyNormal = 0 NotifyGrab = 1 NotifyUngrab = 2 NotifyWhileGrabbed = 3 NotifyHint = 1 NotifyAncestor = 0 NotifyVirtual = 1 NotifyInferior = 2 NotifyNonlinear = 3 NotifyNonlinearVirtual = 4 NotifyPointer = 5 NotifyPointerRoot = 6 NotifyDetailNone = 7 VisibilityUnobscured = 0 VisibilityPartiallyObscured = 1 VisibilityFullyObscured = 2 PlaceOnTop = 0 PlaceOnBottom = 1 FamilyInternet = 0 FamilyDECnet = 1 FamilyChaos = 2 FamilyServerInterpreted = 5 FamilyInternetV6 = 6 PropertyNewValue = 0 PropertyDelete = 1 ColormapUninstalled = 0 ColormapInstalled = 1 GrabModeSync = 0 GrabModeAsync = 1 GrabSuccess = 0 AlreadyGrabbed = 1 GrabInvalidTime = 2 GrabNotViewable = 3 GrabFrozen = 4 AsyncPointer = 0 SyncPointer = 1 ReplayPointer = 2 AsyncKeyboard = 3 SyncKeyboard = 4 ReplayKeyboard = 5 AsyncBoth = 6 SyncBoth = 7 RevertToNone = 0 RevertToPointerRoot = PointerRoot RevertToParent = 2 Success = 0 BadRequest = 1 BadValue = 2 BadWindow = 3 BadPixmap = 4 BadAtom = 5 BadCursor = 6 BadFont = 7 BadMatch = 8 BadDrawable = 9 BadAccess = 10 BadAlloc = 11 BadColor = 12 BadGC = 13 BadIDChoice = 14 BadName = 15 BadLength = 16 BadImplementation = 17 FirstExtensionError = 128 LastExtensionError = 255 InputOutput = 1 InputOnly = 2 CWBackPixmap = (1<<0) CWBackPixel = (1<<1) CWBorderPixmap = (1<<2) CWBorderPixel = (1<<3) CWBitGravity = (1<<4) CWWinGravity = (1<<5) CWBackingStore = (1<<6) CWBackingPlanes = (1<<7) CWBackingPixel = (1<<8) CWOverrideRedirect = (1<<9) CWSaveUnder = (1<<10) CWEventMask = (1<<11) CWDontPropagate = (1<<12) CWColormap = (1<<13) CWCursor = (1<<14) CWX = (1<<0) CWY = (1<<1) CWWidth = (1<<2) CWHeight = (1<<3) CWBorderWidth = (1<<4) CWSibling = (1<<5) CWStackMode = (1<<6) ForgetGravity = 0 NorthWestGravity = 1 NorthGravity = 2 NorthEastGravity = 3 WestGravity = 4 CenterGravity = 5 EastGravity = 6 SouthWestGravity = 7 SouthGravity = 8 SouthEastGravity = 9 StaticGravity = 10 UnmapGravity = 0 NotUseful = 0 WhenMapped = 1 Always = 2 IsUnmapped = 0 IsUnviewable = 1 IsViewable = 2 SetModeInsert = 0 SetModeDelete = 1 DestroyAll = 0 RetainPermanent = 1 RetainTemporary = 2 Above = 0 Below = 1 TopIf = 2 BottomIf = 3 Opposite = 4 RaiseLowest = 0 LowerHighest = 1 PropModeReplace = 0 PropModePrepend = 1 PropModeAppend = 2 GXclear = 0x0 GXand = 0x1 GXandReverse = 0x2 GXcopy = 0x3 GXandInverted = 0x4 GXnoop = 0x5 GXxor = 0x6 GXor = 0x7 GXnor = 0x8 GXequiv = 0x9 GXinvert = 0xa GXorReverse = 0xb GXcopyInverted = 0xc GXorInverted = 0xd GXnand = 0xe GXset = 0xf LineSolid = 0 LineOnOffDash = 1 LineDoubleDash = 2 CapNotLast = 0 CapButt = 1 CapRound = 2 CapProjecting = 3 JoinMiter = 0 JoinRound = 1 JoinBevel = 2 FillSolid = 0 FillTiled = 1 FillStippled = 2 FillOpaqueStippled = 3 EvenOddRule = 0 WindingRule = 1 ClipByChildren = 0 IncludeInferiors = 1 Unsorted = 0 YSorted = 1 YXSorted = 2 YXBanded = 3 CoordModeOrigin = 0 CoordModePrevious = 1 Complex = 0 Nonconvex = 1 Convex = 2 ArcChord = 0 ArcPieSlice = 1 GCFunction = (1<<0) GCPlaneMask = (1<<1) GCForeground = (1<<2) GCBackground = (1<<3) GCLineWidth = (1<<4) GCLineStyle = (1<<5) GCCapStyle = (1<<6) GCJoinStyle = (1<<7) GCFillStyle = (1<<8) GCFillRule = (1<<9) GCTile = (1<<10) GCStipple = (1<<11) GCTileStipXOrigin = (1<<12) GCTileStipYOrigin = (1<<13) GCFont = (1<<14) GCSubwindowMode = (1<<15) GCGraphicsExposures = (1<<16) GCClipXOrigin = (1<<17) GCClipYOrigin = (1<<18) GCClipMask = (1<<19) GCDashOffset = (1<<20) GCDashList = (1<<21) GCArcMode = (1<<22) GCLastBit = 22 FontLeftToRight = 0 FontRightToLeft = 1 FontChange = 255 XYBitmap = 0 XYPixmap = 1 ZPixmap = 2 AllocNone = 0 AllocAll = 1 DoRed = (1<<0) DoGreen = (1<<1) DoBlue = (1<<2) CursorShape = 0 TileShape = 1 StippleShape = 2 AutoRepeatModeOff = 0 AutoRepeatModeOn = 1 AutoRepeatModeDefault = 2 LedModeOff = 0 LedModeOn = 1 KBKeyClickPercent = (1<<0) KBBellPercent = (1<<1) KBBellPitch = (1<<2) KBBellDuration = (1<<3) KBLed = (1<<4) KBLedMode = (1<<5) KBKey = (1<<6) KBAutoRepeatMode = (1<<7) MappingSuccess = 0 MappingBusy = 1 MappingFailed = 2 MappingModifier = 0 MappingKeyboard = 1 MappingPointer = 2 DontPreferBlanking = 0 PreferBlanking = 1 DefaultBlanking = 2 DisableScreenSaver = 0 DisableScreenInterval = 0 DontAllowExposures = 0 AllowExposures = 1 DefaultExposures = 2 ScreenSaverReset = 0 ScreenSaverActive = 1 HostInsert = 0 HostDelete = 1 EnableAccess = 1 DisableAccess = 0 StaticGray = 0 GrayScale = 1 StaticColor = 2 PseudoColor = 3 TrueColor = 4 DirectColor = 5 LSBFirst = 0 MSBFirst = 1 python-xlib-0.33/Xlib/XK.py000066400000000000000000000062121435211557500155170ustar00rootroot00000000000000# Xlib.XK -- X keysym defs # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # # This module defines some functions for working with X keysyms as well # as a modular keysym definition and loading mechanism. See the keysym # definition modules in the Xlib/keysymdef directory. from Xlib.X import NoSymbol def string_to_keysym(keysym): '''Return the (16 bit) numeric code of keysym. Given the name of a keysym as a string, return its numeric code. Don't include the 'XK_' prefix, just use the base, i.e. 'Delete' instead of 'XK_Delete'.''' return globals().get('XK_' + keysym, NoSymbol) def load_keysym_group(group): '''Load all the keysyms in group. Given a group name such as 'latin1' or 'katakana' load the keysyms defined in module 'Xlib.keysymdef.group-name' into this XK module.''' if '.' in group: raise ValueError('invalid keysym group name: %s' % group) G = globals() #Get a reference to XK.__dict__ a.k.a. globals #Import just the keysyms module. mod = __import__('Xlib.keysymdef.%s' % group, G, locals(), [group]) #Extract names of just the keysyms. keysyms = [n for n in dir(mod) if n.startswith('XK_')] #Copy the named keysyms into XK.__dict__ for keysym in keysyms: ## k = mod.__dict__[keysym]; assert k == int(k) #probably too much. G[keysym] = mod.__dict__[keysym] #And get rid of the keysym module. del mod def _load_keysyms_into_XK(mod): '''keysym definition modules need no longer call Xlib.XK._load_keysyms_into_XK(). You should remove any calls to that function from your keysym modules.''' pass # Always import miscellany and latin1 keysyms load_keysym_group('miscellany') load_keysym_group('latin1') def keysym_to_string(keysym): '''Translate a keysym (16 bit number) into a python string. This will pass 0 to 0xff as well as XK_BackSpace, XK_Tab, XK_Clear, XK_Return, XK_Pause, XK_Scroll_Lock, XK_Escape, XK_Delete. For other values it returns None.''' # ISO latin 1, LSB is the code if keysym & 0xff00 == 0: return chr(keysym & 0xff) if keysym in [XK_BackSpace, XK_Tab, XK_Clear, XK_Return, XK_Pause, XK_Scroll_Lock, XK_Escape, XK_Delete]: return chr(keysym & 0xff) # We should be able to do these things quite automatically # for latin2, latin3, etc, in Python 2.0 using the Unicode, # but that will have to wait. return None python-xlib-0.33/Xlib/Xatom.py000066400000000000000000000036451435211557500162740ustar00rootroot00000000000000# Xlib.Xatom -- Standard X atoms # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA PRIMARY = 1 SECONDARY = 2 ARC = 3 ATOM = 4 BITMAP = 5 CARDINAL = 6 COLORMAP = 7 CURSOR = 8 CUT_BUFFER0 = 9 CUT_BUFFER1 = 10 CUT_BUFFER2 = 11 CUT_BUFFER3 = 12 CUT_BUFFER4 = 13 CUT_BUFFER5 = 14 CUT_BUFFER6 = 15 CUT_BUFFER7 = 16 DRAWABLE = 17 FONT = 18 INTEGER = 19 PIXMAP = 20 POINT = 21 RECTANGLE = 22 RESOURCE_MANAGER = 23 RGB_COLOR_MAP = 24 RGB_BEST_MAP = 25 RGB_BLUE_MAP = 26 RGB_DEFAULT_MAP = 27 RGB_GRAY_MAP = 28 RGB_GREEN_MAP = 29 RGB_RED_MAP = 30 STRING = 31 VISUALID = 32 WINDOW = 33 WM_COMMAND = 34 WM_HINTS = 35 WM_CLIENT_MACHINE = 36 WM_ICON_NAME = 37 WM_ICON_SIZE = 38 WM_NAME = 39 WM_NORMAL_HINTS = 40 WM_SIZE_HINTS = 41 WM_ZOOM_HINTS = 42 MIN_SPACE = 43 NORM_SPACE = 44 MAX_SPACE = 45 END_SPACE = 46 SUPERSCRIPT_X = 47 SUPERSCRIPT_Y = 48 SUBSCRIPT_X = 49 SUBSCRIPT_Y = 50 UNDERLINE_POSITION = 51 UNDERLINE_THICKNESS = 52 STRIKEOUT_ASCENT = 53 STRIKEOUT_DESCENT = 54 ITALIC_ANGLE = 55 X_HEIGHT = 56 QUAD_WIDTH = 57 WEIGHT = 58 POINT_SIZE = 59 RESOLUTION = 60 COPYRIGHT = 61 NOTICE = 62 FONT_NAME = 63 FAMILY_NAME = 64 FULL_NAME = 65 CAP_HEIGHT = 66 WM_CLASS = 67 WM_TRANSIENT_FOR = 68 LAST_PREDEFINED = 68 python-xlib-0.33/Xlib/Xcursorfont.py000066400000000000000000000037551435211557500175420ustar00rootroot00000000000000# Xlib.Xcursorfont -- standard cursors # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA num_glyphs = 154 X_cursor = 0 arrow = 2 based_arrow_down = 4 based_arrow_up = 6 boat = 8 bogosity = 10 bottom_left_corner = 12 bottom_right_corner = 14 bottom_side = 16 bottom_tee = 18 box_spiral = 20 center_ptr = 22 circle = 24 clock = 26 coffee_mug = 28 cross = 30 cross_reverse = 32 crosshair = 34 diamond_cross = 36 dot = 38 dotbox = 40 double_arrow = 42 draft_large = 44 draft_small = 46 draped_box = 48 exchange = 50 fleur = 52 gobbler = 54 gumby = 56 hand1 = 58 hand2 = 60 heart = 62 icon = 64 iron_cross = 66 left_ptr = 68 left_side = 70 left_tee = 72 leftbutton = 74 ll_angle = 76 lr_angle = 78 man = 80 middlebutton = 82 mouse = 84 pencil = 86 pirate = 88 plus = 90 question_arrow = 92 right_ptr = 94 right_side = 96 right_tee = 98 rightbutton = 100 rtl_logo = 102 sailboat = 104 sb_down_arrow = 106 sb_h_double_arrow = 108 sb_left_arrow = 110 sb_right_arrow = 112 sb_up_arrow = 114 sb_v_double_arrow = 116 shuttle = 118 sizing = 120 spider = 122 spraycan = 124 star = 126 target = 128 tcross = 130 top_left_arrow = 132 top_left_corner = 134 top_right_corner = 136 top_side = 138 top_tee = 140 trek = 142 ul_angle = 144 umbrella = 146 ur_angle = 148 watch = 150 xterm = 152 python-xlib-0.33/Xlib/Xutil.py000066400000000000000000000042511435211557500163030ustar00rootroot00000000000000# Xlib.Xutil -- ICCCM definitions and similar stuff # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA NoValue = 0x0000 XValue = 0x0001 YValue = 0x0002 WidthValue = 0x0004 HeightValue = 0x0008 AllValues = 0x000F XNegative = 0x0010 YNegative = 0x0020 USPosition = (1 << 0) USSize = (1 << 1) PPosition = (1 << 2) PSize = (1 << 3) PMinSize = (1 << 4) PMaxSize = (1 << 5) PResizeInc = (1 << 6) PAspect = (1 << 7) PBaseSize = (1 << 8) PWinGravity = (1 << 9) PAllHints = (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect) InputHint = (1 << 0) StateHint = (1 << 1) IconPixmapHint = (1 << 2) IconWindowHint = (1 << 3) IconPositionHint = (1 << 4) IconMaskHint = (1 << 5) WindowGroupHint = (1 << 6) MessageHint = (1 << 7) UrgencyHint = (1 << 8) AllHints = (InputHint|StateHint|IconPixmapHint|IconWindowHint| IconPositionHint|IconMaskHint|WindowGroupHint|MessageHint| UrgencyHint) WithdrawnState = 0 NormalState = 1 IconicState = 3 DontCareState = 0 ZoomState = 2 InactiveState = 4 RectangleOut = 0 RectangleIn = 1 RectanglePart = 2 VisualNoMask = 0x0 VisualIDMask = 0x1 VisualScreenMask = 0x2 VisualDepthMask = 0x4 VisualClassMask = 0x8 VisualRedMaskMask = 0x10 VisualGreenMaskMask = 0x20 VisualBlueMaskMask = 0x40 VisualColormapSizeMask = 0x80 VisualBitsPerRGBMask = 0x100 VisualAllMask = 0x1FF ReleaseByFreeingColormap = 1 BitmapSuccess = 0 BitmapOpenFailed = 1 BitmapFileInvalid = 2 BitmapNoMemory = 3 XCSUCCESS = 0 XCNOMEM = 1 XCNOENT = 2 python-xlib-0.33/Xlib/__init__.py000066400000000000000000000022401435211557500167310ustar00rootroot00000000000000# Xlib.__init__ -- glue for Xlib package # # Copyright (C) 2000-2002 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA __version__ = (0, 33) __version_extra__ = '' __version_string__ = '.'.join(map(str, __version__)) + __version_extra__ __all__ = [ 'X', 'XK', 'Xatom', 'Xcursorfont', 'Xutil', 'display', 'error', 'rdb', # Explicitly exclude threaded, so that it isn't imported by # from Xlib import * ] python-xlib-0.33/Xlib/display.py000066400000000000000000001103511435211557500166420ustar00rootroot00000000000000# Xlib.display -- high level display object # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python modules import types # Python 2/3 compatibility. from six import create_unbound_method # Xlib modules from . import error from . import ext from . import X # Xlib.protocol modules from .protocol import display as protocol_display from .protocol import request, event, rq # Xlib.xobjects modules from .xobject import resource from .xobject import drawable from .xobject import fontable from .xobject import colormap from .xobject import cursor _resource_baseclasses = { 'resource': resource.Resource, 'drawable': drawable.Drawable, 'window': drawable.Window, 'pixmap': drawable.Pixmap, 'fontable': fontable.Fontable, 'font': fontable.Font, 'gc': fontable.GC, 'colormap': colormap.Colormap, 'cursor': cursor.Cursor, } _resource_hierarchy = { 'resource': ('drawable', 'window', 'pixmap', 'fontable', 'font', 'gc', 'colormap', 'cursor'), 'drawable': ('window', 'pixmap'), 'fontable': ('font', 'gc') } class _BaseDisplay(protocol_display.Display): # Implement a cache of atom names, used by Window objects when # dealing with some ICCCM properties not defined in Xlib.Xatom def __init__(self, *args, **keys): self.resource_classes = _resource_baseclasses.copy() protocol_display.Display.__init__(self, *args, **keys) self._atom_cache = {} def get_atom(self, atomname, only_if_exists=False): if atomname in self._atom_cache: return self._atom_cache[atomname] r = request.InternAtom(display = self, name = atomname, only_if_exists = only_if_exists) # don't cache NONE responses in case someone creates this later if r.atom != X.NONE: self._atom_cache[atomname] = r.atom return r.atom class Display(object): def __init__(self, display = None): self.display = _BaseDisplay(display) # Create the keymap cache self._keymap_codes = [()] * 256 self._keymap_syms = {} self._update_keymap(self.display.info.min_keycode, (self.display.info.max_keycode - self.display.info.min_keycode + 1)) # Translations for keysyms to strings. self.keysym_translations = {} # Find all supported extensions self.extensions = [] self.class_extension_dicts = {} self.display_extension_methods = {} # a dict that maps the event name to the code # or, when it's an event with a subcode, to a tuple of (event,subcode) # note this wraps the dict so you address it as # extension_event.EXTENSION_EVENT_NAME rather than # extension_event["EXTENSION_EVENT_NAME"] self.extension_event = rq.DictWrapper({}) exts = self.list_extensions() # Go through all extension modules for extname, modname in ext.__extensions__: if extname in exts: # Import the module and fetch it __import__('Xlib.ext.' + modname) mod = getattr(ext, modname) info = self.query_extension(extname) self.display.set_extension_major(extname, info.major_opcode) # Call initialiasation function mod.init(self, info) self.extensions.append(extname) # Finalize extensions by creating new classes for class_name, dictionary in self.class_extension_dicts.items(): origcls = self.display.resource_classes[class_name] self.display.resource_classes[class_name] = type(origcls.__name__, (origcls,), dictionary) # Problem: we have already created some objects without the # extensions: the screen roots and default colormaps. # Fix that by reinstantiating them. for screen in self.display.info.roots: screen.root = self.display.resource_classes['window'](self.display, screen.root.id) screen.default_colormap = self.display.resource_classes['colormap'](self.display, screen.default_colormap.id) def get_display_name(self): """Returns the name used to connect to the server, either provided when creating the Display object, or fetched from the environmental variable $DISPLAY.""" return self.display.get_display_name() def fileno(self): """Returns the file descriptor number of the underlying socket. This method is provided to allow Display objects to be passed select.select().""" return self.display.fileno() def close(self): """Close the display, freeing the resources that it holds.""" self.display.close() def set_error_handler(self, handler): """Set the default error handler which will be called for all unhandled errors. handler should take two arguments as a normal request error handler, but the second argument (the request) will be None. See section Error Handling.""" self.display.set_error_handler(handler) def flush(self): """Flush the request queue, building and sending the queued requests. This can be necessary in applications that never wait for events, and in threaded applications.""" self.display.flush() def sync(self): """Flush the queue and wait until the server has processed all the queued requests. Use this e.g. when it is important that errors caused by a certain request is trapped.""" # Do a light-weight replyrequest to sync. There must # be a better way to do it... self.get_pointer_control() def next_event(self): """Return the next event. If there are no events queued, it will block until the next event is fetched from the server.""" return self.display.next_event() def pending_events(self): """Return the number of events queued, i.e. the number of times that Display.next_event() can be called without blocking.""" return self.display.pending_events() def has_extension(self, extension): """Check if both the server and the client library support the X extension named extension.""" return extension in self.extensions def create_resource_object(self, type, id): """Create a resource object of type for the integer id. type should be one of the following strings: resource drawable window pixmap fontable font gc colormap cursor This function can be used when a resource ID has been fetched e.g. from an resource or a command line argument. Resource objects should never be created by instantiating the appropriate class directly, since any X extensions dynamically added by the library will not be available. """ return self.display.resource_classes[type](self.display, id) # We need this to handle display extension methods def __getattr__(self, attr): try: function = self.display_extension_methods[attr] return types.MethodType(function, self) except KeyError: raise AttributeError(attr) ### ### display information retrieval ### def screen(self, sno = None): if sno is None: return self.display.info.roots[self.display.default_screen] else: return self.display.info.roots[sno] def screen_count(self): """Return the total number of screens on the display.""" return len(self.display.info.roots) def get_default_screen(self): """Return the number of the default screen, extracted from the display name.""" return self.display.get_default_screen() ### ### Extension module interface ### def extension_add_method(self, object, name, function): """extension_add_method(object, name, function) Add an X extension module method. OBJECT is the type of object to add the function to, a string from this list: display resource drawable window pixmap fontable font gc colormap cursor NAME is the name of the method, a string. FUNCTION is a normal function whose first argument is a 'self'. """ if object == 'display': if hasattr(self, name): raise AssertionError('attempting to replace display method: %s' % name) self.display_extension_methods[name] = function else: class_list = (object, ) + _resource_hierarchy.get(object, ()) for class_name in class_list: cls = _resource_baseclasses[class_name] if hasattr(cls, name): raise AssertionError('attempting to replace %s method: %s' % (class_name, name)) method = create_unbound_method(function, cls) # Maybe should check extension overrides too try: self.class_extension_dicts[class_name][name] = method except KeyError: self.class_extension_dicts[class_name] = { name: method } def extension_add_event(self, code, evt, name = None): """extension_add_event(code, evt, [name]) Add an extension event. CODE is the numeric code, and EVT is the event class. EVT will be cloned, and the attribute _code of the new event class will be set to CODE. If NAME is omitted, it will be set to the name of EVT. This name is used to insert an entry in the DictWrapper extension_event. """ newevt = type(evt.__name__, evt.__bases__, evt.__dict__.copy()) newevt._code = code self.display.add_extension_event(code, newevt) if name is None: name = evt.__name__ setattr(self.extension_event, name, code) def extension_add_subevent(self, code, subcode, evt, name = None): """extension_add_subevent(code, evt, [name]) Add an extension subevent. CODE is the numeric code, subcode is the sub-ID of this event that shares the code ID with other sub-events and EVT is the event class. EVT will be cloned, and the attribute _code of the new event class will be set to CODE. If NAME is omitted, it will be set to the name of EVT. This name is used to insert an entry in the DictWrapper extension_event. """ newevt = type(evt.__name__, evt.__bases__, evt.__dict__.copy()) newevt._code = code self.display.add_extension_event(code, newevt, subcode) if name is None: name = evt.__name__ # store subcodes as a tuple of (event code, subcode) in the # extension dict maintained in the display object setattr(self.extension_event, name, (code,subcode)) def extension_add_error(self, code, err): """extension_add_error(code, err) Add an extension error. CODE is the numeric code, and ERR is the error class. """ self.display.add_extension_error(code, err) ### ### keymap cache implementation ### # The keycode->keysym map is stored in a list with 256 elements. # Each element represents a keycode, and the tuple elements are # the keysyms bound to the key. # The keysym->keycode map is stored in a mapping, where the keys # are keysyms. The values are a sorted list of tuples with two # elements each: (index, keycode) # keycode is the code for a key to which this keysym is bound, and # index is the keysyms index in the map for that keycode. def keycode_to_keysym(self, keycode, index): """Convert a keycode to a keysym, looking in entry index. Normally index 0 is unshifted, 1 is shifted, 2 is alt grid, and 3 is shift+alt grid. If that key entry is not bound, X.NoSymbol is returned.""" try: return self._keymap_codes[keycode][index] except IndexError: return X.NoSymbol def keysym_to_keycode(self, keysym): """Look up the primary keycode that is bound to keysym. If several keycodes are found, the one with the lowest index and lowest code is returned. If keysym is not bound to any key, 0 is returned.""" try: return self._keymap_syms[keysym][0][1] except (KeyError, IndexError): return 0 def keysym_to_keycodes(self, keysym): """Look up all the keycodes that is bound to keysym. A list of tuples (keycode, index) is returned, sorted primarily on the lowest index and secondarily on the lowest keycode.""" try: # Copy the map list, reversing the arguments return map(lambda x: (x[1], x[0]), self._keymap_syms[keysym]) except KeyError: return [] def refresh_keyboard_mapping(self, evt): """This method should be called once when a MappingNotify event is received, to update the keymap cache. evt should be the event object.""" if isinstance(evt, event.MappingNotify): if evt.request == X.MappingKeyboard: self._update_keymap(evt.first_keycode, evt.count) else: raise TypeError('expected a MappingNotify event') def _update_keymap(self, first_keycode, count): """Internal function, called to refresh the keymap cache. """ # Delete all sym->code maps for the changed codes lastcode = first_keycode + count for keysym, codes in self._keymap_syms.items(): i = 0 while i < len(codes): code = codes[i][1] if code >= first_keycode and code < lastcode: del codes[i] else: i = i + 1 # Get the new keyboard mapping keysyms = self.get_keyboard_mapping(first_keycode, count) # Replace code->sym map with the new map self._keymap_codes[first_keycode:lastcode] = keysyms # Update sym->code map code = first_keycode for syms in keysyms: index = 0 for sym in syms: if sym != X.NoSymbol: if sym in self._keymap_syms: symcodes = self._keymap_syms[sym] symcodes.append((index, code)) symcodes.sort() else: self._keymap_syms[sym] = [(index, code)] index = index + 1 code = code + 1 ### ### client-internal keysym to string translations ### def lookup_string(self, keysym): """Return a string corresponding to KEYSYM, or None if no reasonable translation is found. """ s = self.keysym_translations.get(keysym) if s is not None: return s import Xlib.XK return Xlib.XK.keysym_to_string(keysym) def rebind_string(self, keysym, newstring): """Change the translation of KEYSYM to NEWSTRING. If NEWSTRING is None, remove old translation if any. """ if newstring is None: try: del self.keysym_translations[keysym] except KeyError: pass else: self.keysym_translations[keysym] = newstring ### ### X requests ### def intern_atom(self, name, only_if_exists = False): """Intern the string name, returning its atom number. If only_if_exists is true and the atom does not already exist, it will not be created and X.NONE is returned.""" r = request.InternAtom(display = self.display, name = name, only_if_exists = only_if_exists) return r.atom def get_atom(self, atom, only_if_exists = False): """Alias for intern_atom, using internal cache""" return self.display.get_atom(atom, only_if_exists) def get_atom_name(self, atom): """Look up the name of atom, returning it as a string. Will raise BadAtom if atom does not exist.""" r = request.GetAtomName(display = self.display, atom = atom) return r.name def get_selection_owner(self, selection): """Return the window that owns selection (an atom), or X.NONE if there is no owner for the selection. Can raise BadAtom.""" r = request.GetSelectionOwner(display = self.display, selection = selection) return r.owner def send_event(self, destination, event, event_mask = 0, propagate = False, onerror = None): """Send a synthetic event to the window destination which can be a window object, or X.PointerWindow or X.InputFocus. event is the event object to send, instantiated from one of the classes in protocol.events. See XSendEvent(3X11) for details. There is also a Window.send_event() method.""" request.SendEvent(display = self.display, onerror = onerror, propagate = propagate, destination = destination, event_mask = event_mask, event = event) def ungrab_pointer(self, time, onerror = None): """Release a grabbed pointer and any queued events. See XUngrabPointer(3X11).""" request.UngrabPointer(display = self.display, onerror = onerror, time = time) def change_active_pointer_grab(self, event_mask, cursor, time, onerror = None): """Change the dynamic parameters of a pointer grab. See XChangeActivePointerGrab(3X11).""" request.ChangeActivePointerGrab(display = self.display, onerror = onerror, cursor = cursor, time = time, event_mask = event_mask) def ungrab_keyboard(self, time, onerror = None): """Ungrab a grabbed keyboard and any queued events. See XUngrabKeyboard(3X11).""" request.UngrabKeyboard(display = self.display, onerror = onerror, time = time) def allow_events(self, mode, time, onerror = None): """Release some queued events. mode should be one of X.AsyncPointer, X.SyncPointer, X.AsyncKeyboard, X.SyncKeyboard, X.ReplayPointer, X.ReplayKeyboard, X.AsyncBoth, or X.SyncBoth. time should be a timestamp or X.CurrentTime.""" request.AllowEvents(display = self.display, onerror = onerror, mode = mode, time = time) def grab_server(self, onerror = None): """Disable processing of requests on all other client connections until the server is ungrabbed. Server grabbing should be avoided as much as possible.""" request.GrabServer(display = self.display, onerror = onerror) def ungrab_server(self, onerror = None): """Release the server if it was previously grabbed by this client.""" request.UngrabServer(display = self.display, onerror = onerror) def warp_pointer(self, x, y, src_window = X.NONE, src_x = 0, src_y = 0, src_width = 0, src_height = 0, onerror = None): """Move the pointer relative its current position by the offsets (x, y). However, if src_window is a window the pointer is only moved if the specified rectangle in src_window contains it. If src_width is 0 it will be replaced with the width of src_window - src_x. src_height is treated in a similar way. To move the pointer to absolute coordinates, use Window.warp_pointer().""" request.WarpPointer(display = self.display, onerror = onerror, src_window = src_window, dst_window = X.NONE, src_x = src_x, src_y = src_y, src_width = src_width, src_height = src_height, dst_x = x, dst_y = y) def set_input_focus(self, focus, revert_to, time, onerror = None): """Set input focus to focus, which should be a window, X.PointerRoot or X.NONE. revert_to specifies where the focus reverts to if the focused window becomes not visible, and should be X.RevertToParent, RevertToPointerRoot, or RevertToNone. See XSetInputFocus(3X11) for details. There is also a Window.set_input_focus().""" request.SetInputFocus(display = self.display, onerror = onerror, revert_to = revert_to, focus = focus, time = time) def get_input_focus(self): """Return an object with the following attributes: focus The window which currently holds the input focus, X.NONE or X.PointerRoot. revert_to Where the focus will revert, one of X.RevertToParent, RevertToPointerRoot, or RevertToNone. """ return request.GetInputFocus(display = self.display) def query_keymap(self): """Return a bit vector for the logical state of the keyboard, where each bit set to 1 indicates that the corresponding key is currently pressed down. The vector is represented as a list of 32 integers. List item N contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N.""" r = request.QueryKeymap(display = self.display) return r.map def open_font(self, name): """Open the font identifed by the pattern name and return its font object. If name does not match any font, None is returned.""" fid = self.display.allocate_resource_id() ec = error.CatchError(error.BadName) request.OpenFont(display = self.display, onerror = ec, fid = fid, name = name) self.sync() if ec.get_error(): self.display.free_resource_id(fid) return None else: cls = self.display.get_resource_class('font', fontable.Font) return cls(self.display, fid, owner = 1) def list_fonts(self, pattern, max_names): """Return a list of font names matching pattern. No more than max_names will be returned.""" r = request.ListFonts(display = self.display, max_names = max_names, pattern = pattern) return r.fonts def list_fonts_with_info(self, pattern, max_names): """Return a list of fonts matching pattern. No more than max_names will be returned. Each list item represents one font and has the following properties: name The name of the font. min_bounds max_bounds min_char_or_byte2 max_char_or_byte2 default_char draw_direction min_byte1 max_byte1 all_chars_exist font_ascent font_descent replies_hint See the description of XFontStruct in XGetFontProperty(3X11) for details on these values. properties A list of properties. Each entry has two attributes: name The atom identifying this property. value A 32-bit unsigned value. """ return request.ListFontsWithInfo(display = self.display, max_names = max_names, pattern = pattern) def set_font_path(self, path, onerror = None): """Set the font path to path, which should be a list of strings. If path is empty, the default font path of the server will be restored.""" request.SetFontPath(display = self.display, onerror = onerror, path = path) def get_font_path(self): """Return the current font path as a list of strings.""" r = request.GetFontPath(display = self.display) return r.paths def query_extension(self, name): """Ask the server if it supports the extension name. If it is supported an object with the following attributes is returned: major_opcode The major opcode that the requests of this extension uses. first_event The base event code if the extension have additional events, or 0. first_error The base error code if the extension have additional errors, or 0. If the extension is not supported, None is returned.""" r = request.QueryExtension(display = self.display, name = name) if r.present: return r else: return None def list_extensions(self): """Return a list of all the extensions provided by the server.""" r = request.ListExtensions(display = self.display) return r.names def change_keyboard_mapping(self, first_keycode, keysyms, onerror = None): """Modify the keyboard mapping, starting with first_keycode. keysyms is a list of tuples of keysyms. keysyms[n][i] will be assigned to keycode first_keycode+n at index i.""" request.ChangeKeyboardMapping(display = self.display, onerror = onerror, first_keycode = first_keycode, keysyms = keysyms) def get_keyboard_mapping(self, first_keycode, count): """Return the current keyboard mapping as a list of tuples, starting at first_keycount and no more than count.""" r = request.GetKeyboardMapping(display = self.display, first_keycode = first_keycode, count = count) return r.keysyms def change_keyboard_control(self, onerror = None, **keys): """Change the parameters provided as keyword arguments: key_click_percent The volume of key clicks between 0 (off) and 100 (load). -1 will restore default setting. bell_percent The base volume of the bell, coded as above. bell_pitch The pitch of the bell in Hz, -1 restores the default. bell_duration The duration of the bell in milliseconds, -1 restores the default. led led_mode led_mode should be X.LedModeOff or X.LedModeOn. If led is provided, it should be a 32-bit mask listing the LEDs that should change. If led is not provided, all LEDs are changed. key auto_repeat_mode auto_repeat_mode should be one of X.AutoRepeatModeOff, X.AutoRepeatModeOn, or X.AutoRepeatModeDefault. If key is provided, that key will be modified, otherwise the global state for the entire keyboard will be modified.""" request.ChangeKeyboardControl(display = self.display, onerror = onerror, attrs = keys) def get_keyboard_control(self): """Return an object with the following attributes: global_auto_repeat X.AutoRepeatModeOn or X.AutoRepeatModeOff. auto_repeats A list of 32 integers. List item N contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N. If a bit is on, autorepeat is enabled for the corresponding key. led_mask A 32-bit mask indicating which LEDs are on. key_click_percent The volume of key click, from 0 to 100. bell_percent bell_pitch bell_duration The volume, pitch and duration of the bell. """ return request.GetKeyboardControl(display = self.display) def bell(self, percent = 0, onerror = None): """Ring the bell at the volume percent which is relative the base volume. See XBell(3X11).""" request.Bell(display = self.display, onerror = onerror, percent = percent) def change_pointer_control(self, accel = None, threshold = None, onerror = None): """To change the pointer acceleration, set accel to a tuple (num, denum). The pointer will then move num/denum times the normal speed if it moves beyond the threshold number of pixels at once. To change the threshold, set it to the number of pixels. -1 restores the default.""" if accel is None: do_accel = 0 accel_num = 0 accel_denum = 0 else: do_accel = 1 accel_num, accel_denum = accel if threshold is None: do_threshold = 0 else: do_threshold = 1 request.ChangePointerControl(display = self.display, onerror = onerror, do_accel = do_accel, do_thresh = do_threshold, accel_num = accel_num, accel_denum = accel_denum, threshold = threshold) def get_pointer_control(self): """Return an object with the following attributes: accel_num accel_denom The acceleration as numerator/denumerator. threshold The number of pixels the pointer must move before the acceleration kicks in.""" return request.GetPointerControl(display = self.display) def set_screen_saver(self, timeout, interval, prefer_blank, allow_exposures, onerror = None): """See XSetScreenSaver(3X11).""" request.SetScreenSaver(display = self.display, onerror = onerror, timeout = timeout, interval = interval, prefer_blank = prefer_blank, allow_exposures = allow_exposures) def get_screen_saver(self): """Return an object with the attributes timeout, interval, prefer_blanking, allow_exposures. See XGetScreenSaver(3X11) for details.""" return request.GetScreenSaver(display = self.display) def change_hosts(self, mode, host_family, host, onerror = None): """mode is either X.HostInsert or X.HostDelete. host_family is one of X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos, X.FamilyServerInterpreted or X.FamilyInternetV6. host is a list of bytes. For the Internet family, it should be the four bytes of an IPv4 address.""" request.ChangeHosts(display = self.display, onerror = onerror, mode = mode, host_family = host_family, host = host) def list_hosts(self): """Return an object with the following attributes: mode X.EnableAccess if the access control list is used, X.DisableAccess otherwise. hosts The hosts on the access list. Each entry has the following attributes: family X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos, X.FamilyServerInterpreted or X.FamilyInternetV6. name A list of byte values, the coding depends on family. For the Internet family, it is the 4 bytes of an IPv4 address. """ return request.ListHosts(display = self.display) def set_access_control(self, mode, onerror = None): """Enable use of access control lists at connection setup if mode is X.EnableAccess, disable if it is X.DisableAccess.""" request.SetAccessControl(display = self.display, onerror = onerror, mode = mode) def set_close_down_mode(self, mode, onerror = None): """Control what will happen with the client's resources at connection close. The default is X.DestroyAll, the other values are X.RetainPermanent and X.RetainTemporary.""" request.SetCloseDownMode(display = self.display, onerror = onerror, mode = mode) def force_screen_saver(self, mode, onerror = None): """If mode is X.ScreenSaverActive the screen saver is activated. If it is X.ScreenSaverReset, the screen saver is deactivated as if device input had been received.""" request.ForceScreenSaver(display = self.display, onerror = onerror, mode = mode) def set_pointer_mapping(self, map): """Set the mapping of the pointer buttons. map is a list of logical button numbers. map must be of the same length as the list returned by Display.get_pointer_mapping(). map[n] sets the logical number for the physical button n+1. Logical number 0 disables the button. Two physical buttons cannot be mapped to the same logical number. If one of the buttons to be altered are logically in the down state, X.MappingBusy is returned and the mapping is not changed. Otherwise the mapping is changed and X.MappingSuccess is returned.""" r = request.SetPointerMapping(display = self.display, map = map) return r.status def get_pointer_mapping(self): """Return a list of the pointer button mappings. Entry N in the list sets the logical button number for the physical button N+1.""" r = request.GetPointerMapping(display = self.display) return r.map def set_modifier_mapping(self, keycodes): """Set the keycodes for the eight modifiers X.Shift, X.Lock, X.Control, X.Mod1, X.Mod2, X.Mod3, X.Mod4 and X.Mod5. keycodes should be a eight-element list where each entry is a list of the keycodes that should be bound to that modifier. If any changed key is logically in the down state, X.MappingBusy is returned and the mapping is not changed. If the mapping violates some server restriction, X.MappingFailed is returned. Otherwise the mapping is changed and X.MappingSuccess is returned.""" r = request.SetModifierMapping(display = self.display, keycodes = keycodes) return r.status def get_modifier_mapping(self): """Return a list of eight lists, one for each modifier. The list can be indexed using X.ShiftMapIndex, X.Mod1MapIndex, and so on. The sublists list the keycodes bound to that modifier.""" r = request.GetModifierMapping(display = self.display) return r.keycodes def no_operation(self, onerror = None): """Do nothing but send a request to the server.""" request.NoOperation(display = self.display, onerror = onerror) python-xlib-0.33/Xlib/error.py000066400000000000000000000112171435211557500163270ustar00rootroot00000000000000# Xlib.error -- basic error classes # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Xlib modules from . import X # Xlib.protocol modules from .protocol import rq class DisplayError(Exception): def __init__(self, display): self.display = display def __str__(self): return 'Display error "%s"' % self.display class DisplayNameError(DisplayError): def __str__(self): return 'Bad display name "%s"' % self.display class DisplayConnectionError(DisplayError): def __init__(self, display, msg): self.display = display self.msg = msg def __str__(self): return 'Can\'t connect to display "%s": %s' % (self.display, self.msg) class ConnectionClosedError(Exception): def __init__(self, whom): self.whom = whom def __str__(self): return 'Display connection closed by %s' % self.whom class XauthError(Exception): pass class XNoAuthError(Exception): pass class ResourceIDError(Exception): pass class XError(rq.GetAttrData, Exception): _fields = rq.Struct( rq.Card8('type'), # Always 0 rq.Card8('code'), rq.Card16('sequence_number'), rq.Card32('resource_id'), rq.Card16('minor_opcode'), rq.Card8('major_opcode'), rq.Pad(21) ) def __init__(self, display, data): self._data, _ = self._fields.parse_binary(data, display, rawdict = True) def __str__(self): s = [] for f in ('code', 'resource_id', 'sequence_number', 'major_opcode', 'minor_opcode'): s.append('{0} = {1}'.format(f, self._data[f])) return '{0}: {1}'.format(self.__class__, ', '.join(s)) class XResourceError(XError): _fields = rq.Struct( rq.Card8('type'), # Always 0 rq.Card8('code'), rq.Card16('sequence_number'), rq.Resource('resource_id'), rq.Card16('minor_opcode'), rq.Card8('major_opcode'), rq.Pad(21) ) class BadRequest(XError): pass class BadValue(XError): pass class BadWindow(XResourceError): pass class BadPixmap(XResourceError): pass class BadAtom(XError): pass class BadCursor(XResourceError): pass class BadFont(XResourceError): pass class BadMatch(XError): pass class BadDrawable(XResourceError): pass class BadAccess(XError): pass class BadAlloc(XError): pass class BadColor(XResourceError): pass class BadGC(XResourceError): pass class BadIDChoice(XResourceError): pass class BadName(XError): pass class BadLength(XError): pass class BadImplementation(XError): pass xerror_class = { X.BadRequest: BadRequest, X.BadValue: BadValue, X.BadWindow: BadWindow, X.BadPixmap: BadPixmap, X.BadAtom: BadAtom, X.BadCursor: BadCursor, X.BadFont: BadFont, X.BadMatch: BadMatch, X.BadDrawable: BadDrawable, X.BadAccess: BadAccess, X.BadAlloc: BadAlloc, X.BadColor: BadColor, X.BadGC: BadGC, X.BadIDChoice: BadIDChoice, X.BadName: BadName, X.BadLength: BadLength, X.BadImplementation: BadImplementation, } class CatchError(object): def __init__(self, *errors): self.error_types = errors self.error = None self.request = None def __call__(self, error, request): if self.error_types: for etype in self.error_types: if isinstance(error, etype): self.error = error self.request = request return 1 return 0 else: self.error = error self.request = request return 1 def get_error(self): return self.error def get_request(self): return self.request def reset(self): self.error = None self.request = None python-xlib-0.33/Xlib/ext/000077500000000000000000000000001435211557500154225ustar00rootroot00000000000000python-xlib-0.33/Xlib/ext/__init__.py000066400000000000000000000031411435211557500175320ustar00rootroot00000000000000# Xlib.ext.__init__ -- X extension modules # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # __extensions__ is a list of tuples: (extname, extmod) # extname is the name of the extension according to the X # protocol. extmod is the name of the module in this package. __extensions__ = [ # We load this first so other extensions can register generic event data # structures. ('Generic Event Extension', 'ge'), ('XTEST', 'xtest'), ('SHAPE', 'shape'), ('XINERAMA', 'xinerama'), ('RECORD', 'record'), ('Composite', 'composite'), ('RANDR', 'randr'), ('XFIXES', 'xfixes'), ('SECURITY', 'security'), ('XInputExtension', 'xinput'), ('NV-CONTROL', 'nvcontrol'), ('DAMAGE', 'damage'), ('DPMS', 'dpms'), ('X-Resource', 'res'), ('MIT-SCREEN-SAVER', 'screensaver'), ] __all__ = map(lambda x: x[1], __extensions__) python-xlib-0.33/Xlib/ext/composite.py000066400000000000000000000206161435211557500200030ustar00rootroot00000000000000# $Id: xtest.py,v 1.1 2000/08/21 10:03:45 petli Exp $ # # Xlib.ext.composite -- Composite extension module # # Copyright (C) 2007 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA """Composite extension, allowing windows to be rendered to off-screen storage. For detailed description, see the protocol specification at http://freedesktop.org/wiki/Software/CompositeExt By itself this extension is not very useful, it is intended to be used together with the DAMAGE and XFIXES extensions. Typically you would also need RENDER or glX or some similar method of creating fancy graphics. """ from Xlib.protocol import rq from Xlib.xobject import drawable extname = 'Composite' RedirectAutomatic = 0 RedirectManual = 1 class QueryVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card32('major_version'), rq.Card32('minor_version') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('major_version'), rq.Card32('minor_version'), rq.Pad(16), ) def query_version(self): return QueryVersion( display = self.display, opcode = self.display.get_extension_major(extname), major_version=0, minor_version=4 ) class RedirectWindow(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), rq.Window('window'), rq.Set('update', 1, (RedirectAutomatic, RedirectManual)), rq.Pad(3), ) def redirect_window(self, update, onerror = None): """Redirect the hierarchy starting at this window to off-screen storage. """ RedirectWindow(display = self.display, onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, ) class RedirectSubwindows(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Window('window'), rq.Set('update', 1, (RedirectAutomatic, RedirectManual)), rq.Pad(3), ) def redirect_subwindows(self, update, onerror = None): """Redirect the hierarchies starting at all current and future children to this window to off-screen storage. """ RedirectSubwindows(display = self.display, onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, ) class UnredirectWindow(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), rq.Window('window'), rq.Set('update', 1, (RedirectAutomatic, RedirectManual)), rq.Pad(3), ) def unredirect_window(self, update, onerror = None): """Stop redirecting this window hierarchy. """ UnredirectWindow(display = self.display, onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, ) class UnredirectSubindows(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), rq.Window('window'), rq.Set('update', 1, (RedirectAutomatic, RedirectManual)), rq.Pad(3), ) def unredirect_subwindows(self, update, onerror = None): """Stop redirecting the hierarchies of children to this window. """ RedirectWindow(display = self.display, onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, ) class CreateRegionFromBorderClip(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(5), rq.RequestLength(), rq.Card32('region'), # FIXME: this should be a Region from XFIXES extension rq.Window('window'), ) def create_region_from_border_clip(self, onerror = None): """Create a region of the border clip of the window, i.e. the area that is not clipped by the parent and any sibling windows. """ rid = self.display.allocate_resource_id() CreateRegionFromBorderClip( display = self.display, onerror = onerror, opcode = self.display.get_extension_major(extname), region = rid, window = self, ) # FIXME: create Region object and return it return rid class NameWindowPixmap(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(6), rq.RequestLength(), rq.Window('window'), rq.Pixmap('pixmap'), ) def name_window_pixmap(self, onerror = None): """Create a new pixmap that refers to the off-screen storage of the window, including its border. This pixmap will remain allocated until freed whatever happens with the window. However, the window will get a new off-screen pixmap every time it is mapped or resized, so to keep track of the contents you must listen for these events and get a new pixmap after them. """ pid = self.display.allocate_resource_id() NameWindowPixmap(display = self.display, onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, pixmap = pid, ) cls = self.display.get_resource_class('pixmap', drawable.Pixmap) return cls(self.display, pid, owner = 1) class GetOverlayWindow(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(7), rq.RequestLength(), rq.Window('window') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('overlay_window'), rq.Pad(20), ) def get_overlay_window(self): """Return the overlay window of the root window. """ return GetOverlayWindow(display = self.display, opcode = self.display.get_extension_major(extname), window = self) def init(disp, info): disp.extension_add_method('display', 'composite_query_version', query_version) disp.extension_add_method('window', 'composite_redirect_window', redirect_window) disp.extension_add_method('window', 'composite_redirect_subwindows', redirect_subwindows) disp.extension_add_method('window', 'composite_unredirect_window', unredirect_window) disp.extension_add_method('window', 'composite_unredirect_subwindows', unredirect_subwindows) disp.extension_add_method('window', 'composite_create_region_from_border_clip', create_region_from_border_clip) disp.extension_add_method('window', 'composite_name_window_pixmap', name_window_pixmap) disp.extension_add_method('window', 'composite_get_overlay_window', get_overlay_window) python-xlib-0.33/Xlib/ext/damage.py000066400000000000000000000131251435211557500172140ustar00rootroot00000000000000# Xlib.ext.damage -- DAMAGE extension module # # Copyright (C) 2018 Joseph Kogut # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA from Xlib import X from Xlib.protocol import rq, structs from Xlib.error import XError extname = 'DAMAGE' # Event codes # DamageNotifyCode = 0 # Error codes # BadDamageCode = 0 class BadDamageError(XError): pass # DamageReportLevel options DamageReportRawRectangles = 0 DamageReportDeltaRectangles = 1 DamageReportBoundingBox = 2 DamageReportNonEmpty = 3 DamageReportLevel = ( DamageReportRawRectangles, DamageReportDeltaRectangles, DamageReportBoundingBox, DamageReportNonEmpty, ) DAMAGE = rq.Card32 # Methods class QueryVersion(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card32('major_version'), rq.Card32('minor_version'), ) _reply = rq.Struct(rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('major_version'), rq.Card32('minor_version'), rq.Pad(16), ) def query_version(self): return QueryVersion(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=1) class DamageCreate(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), DAMAGE('damage'), rq.Drawable('drawable'), rq.Set('level', 1, DamageReportLevel), rq.Pad(3), ) def damage_create(self, level): did = self.display.allocate_resource_id() DamageCreate(display=self.display, opcode=self.display.get_extension_major(extname), damage=did, drawable=self.id, level=level, ) return did class DamageDestroy(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), DAMAGE('damage') ) def damage_destroy(self, damage): DamageDestroy(display=self.display, opcode=self.display.get_extension_major(extname), damage=damage, ) self.display.free_resource_id(damage) class DamageSubtract(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), DAMAGE('damage'), rq.Card32('repair'), rq.Card32('parts') ) def damage_subtract(self, damage, repair=X.NONE, parts=X.NONE): DamageSubtract(display=self.display, opcode=self.display.get_extension_major(extname), damage=damage, repair=repair, parts=parts) class DamageAdd(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), rq.Card32('repair'), rq.Card32('parts'), ) def damage_add(self, repair, parts): DamageAdd(display=self.display, opcode=self.display.get_extension_major(extname), repair=repair, parts=parts) # Events # class DamageNotify(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('level'), rq.Card16('sequence_number'), rq.Drawable('drawable'), DAMAGE('damage'), rq.Card32('timestamp'), rq.Object('area', structs.Rectangle), rq.Object('drawable_geometry', structs.Rectangle) ) def init(disp, info): disp.extension_add_method('display', 'damage_query_version', query_version) disp.extension_add_method('drawable', 'damage_create', damage_create) disp.extension_add_method('display', 'damage_destroy', damage_destroy) disp.extension_add_method('display', 'damage_subtract', damage_subtract) disp.extension_add_method('drawable', 'damage_add', damage_add) disp.extension_add_event(info.first_event + DamageNotifyCode, DamageNotify) disp.extension_add_error(code=BadDamageCode, err=BadDamageError) python-xlib-0.33/Xlib/ext/dpms.py000066400000000000000000000150741435211557500167460ustar00rootroot00000000000000# Xlib.ext.dpms -- X Display Power Management Signaling # # Copyright (C) 2020 Thiago Kenji Okada # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA ''' This extension provides X Protocol control over the VESA Display Power Management Signaling (DPMS) characteristics of video boards under control of the X Window System. Documentation: https://www.x.org/releases/X11R7.7/doc/xextproto/dpms.html ''' from Xlib.protocol import rq extname = 'DPMS' # DPMS Extension Power Levels # 0 DPMSModeOn In use # 1 DPMSModeStandby Blanked, low power # 2 DPMSModeSuspend Blanked, lower power # 3 DPMSModeOff Shut off, awaiting activity DPMSModeOn = 0 DPMSModeStandby = 1 DPMSModeSuspend = 2 DPMSModeOff = 3 DPMSPowerLevel = ( DPMSModeOn, DPMSModeStandby, DPMSModeSuspend, DPMSModeOff, ) class DPMSGetVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card16('major_version'), rq.Card16('minor_version'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('major_version'), rq.Card16('minor_version'), rq.Pad(20), ) def get_version(self): return DPMSGetVersion(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=1) class DPMSCapable(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Bool('capable'), rq.Pad(23), ) def capable(self): return DPMSCapable(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=1) class DPMSGetTimeouts(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('standby_timeout'), rq.Card16('suspend_timeout'), rq.Card16('off_timeout'), rq.Pad(18), ) def get_timeouts(self): return DPMSGetTimeouts(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=1) class DPMSSetTimeouts(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), rq.Card16('standby_timeout'), rq.Card16('suspend_timeout'), rq.Card16('off_timeout'), rq.Pad(2) ) def set_timeouts(self, standby_timeout, suspend_timeout, off_timeout): return DPMSSetTimeouts(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=1, standby_timeout=standby_timeout, suspend_timeout=suspend_timeout, off_timeout=off_timeout) class DPMSEnable(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), ) def enable(self): return DPMSEnable(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=1) class DPMSDisable(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(5), rq.RequestLength(), ) def disable(self): return DPMSDisable(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=1) class DPMSForceLevel(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(6), rq.RequestLength(), rq.Resource('power_level', DPMSPowerLevel), ) def force_level(self, power_level): return DPMSForceLevel(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=1, power_level=power_level) class DPMSInfo(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(7), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('power_level'), rq.Bool('state'), rq.Pad(21), ) def info(self): return DPMSInfo(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=1) def init(disp, _info): disp.extension_add_method('display', 'dpms_get_version', get_version) disp.extension_add_method('display', 'dpms_capable', capable) disp.extension_add_method('display', 'dpms_get_timeouts', get_timeouts) disp.extension_add_method('display', 'dpms_set_timeouts', set_timeouts) disp.extension_add_method('display', 'dpms_enable', enable) disp.extension_add_method('display', 'dpms_disable', disable) disp.extension_add_method('display', 'dpms_force_level', force_level) disp.extension_add_method('display', 'dpms_info', info) python-xlib-0.33/Xlib/ext/ge.py000066400000000000000000000064511435211557500163750ustar00rootroot00000000000000# Xlib.ext.ge -- Generic Event extension module # # Copyright (C) 2012 Outpost Embedded, LLC # Forest Bond # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA ''' ge - Generic Event Extension ''' from Xlib.protocol import rq extname = 'Generic Event Extension' GenericEventCode = 35 class GEQueryVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card32('major_version'), rq.Card32('minor_version'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('major_version'), rq.Card32('minor_version'), rq.Pad(16), ) def query_version(self): return GEQueryVersion( display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=0, ) class GenericEvent(rq.Event): _code = GenericEventCode _fields = rq.Struct( rq.Card8('type'), rq.Card8('extension'), rq.Card16('sequence_number'), rq.Card32('length'), rq.Card16('evtype'), # Some generic events make use of this space, but with # others the data is simply discarded. In any case we # don't need to explicitly pad this out as we are # always given at least 32 bytes and we save # everything after the first ten as the "data" field. #rq.Pad(22), ) def __init__(self, binarydata = None, display = None, **keys): if binarydata: data = binarydata[10:] binarydata = binarydata[:10] else: data = '' rq.Event.__init__( self, binarydata=binarydata, display=display, **keys ) if display: ge_event_data = getattr(display, 'ge_event_data', None) if ge_event_data: estruct = ge_event_data.get((self.extension, self.evtype), None) if estruct: data, _ = estruct.parse_binary(data, display) self._data['data'] = data def add_event_data(self, extension, evtype, estruct): if not hasattr(self.display, 'ge_event_data'): self.display.ge_event_data = {} self.display.ge_event_data[(extension, evtype)] = estruct def init(disp, info): disp.extension_add_method('display', 'ge_query_version', query_version) disp.extension_add_method('display', 'ge_add_event_data', add_event_data) disp.extension_add_event(GenericEventCode, GenericEvent) python-xlib-0.33/Xlib/ext/nvcontrol.py000066400000000000000000005542341435211557500200350ustar00rootroot00000000000000# Xlib.ext.nvcontrol -- NV-CONTROL extension module # # Copyright (C) 2019 Roberto Leinardi # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA """NV-CONTROL - provide access to the NV-CONTROL extension information.""" from Xlib.protocol import rq extname = 'NV-CONTROL' def query_target_count(self, target): """Return the target count""" reply = NVCtrlQueryTargetCountReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_type=target.type()) return int(reply._data.get('count')) def query_int_attribute(self, target, display_mask, attr): """Return the value of an integer attribute""" reply = NVCtrlQueryAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), target_type=target.type(), display_mask=display_mask, attr=attr) if not reply._data.get('flags'): return None return int(reply._data.get('value')) def set_int_attribute(self, target, display_mask, attr, value): """Set the value of an integer attribute""" reply = NVCtrlSetAttributeAndGetStatusReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), target_type=target.type(), display_mask=display_mask, attr=attr, value=value) return reply._data.get('flags') != 0 def query_string_attribute(self, target, display_mask, attr): """Return the value of a string attribute""" reply = NVCtrlQueryStringAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), target_type=target.type(), display_mask=display_mask, attr=attr) if not reply._data.get('flags'): return None return str(reply._data.get('string')).strip('\0') def query_valid_attr_values(self, target, display_mask, attr): """Return the value of an integer attribute""" reply = NVCtrlQueryValidAttributeValuesReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), target_type=target.type(), display_mask=display_mask, attr=attr) if not reply._data.get('flags'): return None return int(reply._data.get('min')), int(reply._data.get('max')) def query_binary_data(self, target, display_mask, attr): """Return binary data""" reply = NVCtrlQueryBinaryDataReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), target_type=target.type(), display_mask=display_mask, attr=attr) if not reply._data.get('flags'): return None return reply._data.get('data') def get_coolers_used_by_gpu(self, target): reply = NVCtrlQueryListCard32ReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), target_type=target.type(), display_mask=0, attr=NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU) if not reply._data.get('flags'): return None fans = reply._data.get('list') if len(fans) > 1: return fans[1:] else: return None def get_gpu_count(self): """Return the number of GPU's present in the system.""" return int(query_target_count(self, Gpu())) def get_name(self, target): """Return the GPU product name on which the specified X screen is running""" return query_string_attribute(self, target, 0, NV_CTRL_STRING_PRODUCT_NAME) def get_driver_version(self, target): """Return the NVIDIA (kernel level) driver version for the specified screen or GPU""" return query_string_attribute(self, target, 0, NV_CTRL_STRING_NVIDIA_DRIVER_VERSION) def get_vbios_version(self, target): """Return the version of the VBIOS for the specified screen or GPU""" return query_string_attribute(self, target, 0, NV_CTRL_STRING_VBIOS_VERSION) def get_gpu_uuid(self, target): return query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_UUID) def get_utilization_rates(self, target): string = query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_UTILIZATION) result = {} if string is not None and string != '': for line in string.split(','): [key, value] = line.split('=')[:2] result[key.strip()] = int(value) if value.isdigit() else value return result def get_performance_modes(self, target): string = query_string_attribute(self, target, 0, NV_CTRL_STRING_PERFORMANCE_MODES) result = [] if string is not None and string != '': for perf in string.split(';'): perf_dict = {} for line in perf.split(','): [key, value] = line.split('=')[:2] perf_dict[key.strip()] = int(value) if value.isdigit() else value result.append(perf_dict) return result def get_clock_info(self, target): string = query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS) result = {} if string is not None and string != '': for line in string.split(','): [key, value] = line.split('=')[:2] result[key.strip()] = int(value) if value.isdigit() else value return result def get_vram(self, target): return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_RAM) def get_irq(self, target): """Return the interrupt request line used by the GPU driving the screen""" return query_int_attribute(self, target, 0, NV_CTRL_IRQ) def supports_framelock(self, target): """Return whether the underlying GPU supports Frame Lock. All of the other frame lock attributes are only applicable if this returns True. """ return query_int_attribute(self, target, 0, NV_CTRL_FRAMELOCK) == 1 def gvo_supported(self, screen): """Return whether this X screen supports GVO If this screen does not support GVO output, then all other GVO attributes are unavailable. """ return query_int_attribute(self, screen, [], NV_CTRL_GVO_SUPPORTED) def get_core_temp(self, target): """Return the current core temperature of the GPU driving the X screen.""" return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORE_TEMPERATURE) def get_core_threshold(self, target): """Return the current GPU core slowdown threshold temperature. It reflects the temperature at which the GPU is throttled to prevent overheating. """ return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORE_THRESHOLD) def get_default_core_threshold(self, target): """Return the default core threshold temperature.""" return query_int_attribute(self, target, 0, NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD) def get_max_core_threshold(self, target): """Return the maximum core threshold temperature.""" return query_int_attribute(self, target, 0, NV_CTRL_GPU_MAX_CORE_THRESHOLD) def get_ambient_temp(self, target): """Return the current temperature in the immediate neighbourhood of the GPU driving the X screen.""" return query_int_attribute(self, target, 0, NV_CTRL_AMBIENT_TEMPERATURE) def get_cuda_cores(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORES) def get_memory_bus_width(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_MEMORY_BUS_WIDTH) def get_total_dedicated_gpu_memory(self, target): return query_int_attribute(self, target, 0, NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY) def get_used_dedicated_gpu_memory(self, target): return query_int_attribute(self, target, 0, NV_CTRL_USED_DEDICATED_GPU_MEMORY) def get_curr_pcie_link_width(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH) def get_max_pcie_link_width(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH) def get_curr_pcie_link_generation(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_GENERATION) def get_encoder_utilization(self, target): return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_ENCODER_UTILIZATION) def get_decoder_utilization(self, target): return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_DECODER_UTILIZATION) def get_current_performance_level(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL) def get_gpu_nvclock_offset(self, target, perf_level): return query_int_attribute(self, target, perf_level, NV_CTRL_GPU_NVCLOCK_OFFSET) def set_gpu_nvclock_offset(self, target, perf_level, offset): return set_int_attribute(self, target, perf_level, NV_CTRL_GPU_NVCLOCK_OFFSET, offset) def set_gpu_nvclock_offset_all_levels(self, target, offset): return set_int_attribute(self, target, 0, NV_CTRL_GPU_NVCLOCK_OFFSET_ALL_PERFORMANCE_LEVELS, offset) def get_gpu_nvclock_offset_range(self, target, perf_level): return query_valid_attr_values(self, target, perf_level, NV_CTRL_GPU_NVCLOCK_OFFSET) def get_mem_transfer_rate_offset(self, target, perf_level): return query_int_attribute(self, target, perf_level, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) def set_mem_transfer_rate_offset(self, target, perf_level, offset): return set_int_attribute(self, target, perf_level, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET, offset) def set_mem_transfer_rate_offset_all_levels(self, target, offset): return set_int_attribute(self, target, 0, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET_ALL_PERFORMANCE_LEVELS, offset) def get_mem_transfer_rate_offset_range(self, target, perf_level): return query_valid_attr_values(self, target, perf_level, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) def get_cooler_manual_control_enabled(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL) def set_cooler_manual_control_enabled(self, target, enabled): return set_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) == 1 def get_fan_duty(self, target): return query_int_attribute(self, target, 0, NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) def set_fan_duty(self, cooler, speed): return set_int_attribute(self, cooler, 0, NV_CTRL_THERMAL_COOLER_LEVEL, speed) def get_fan_rpm(self, target): return query_int_attribute(self, target, 0, NV_CTRL_THERMAL_COOLER_SPEED) def get_max_displays(self, target): """Return the maximum number of display devices that can be driven simultaneously on a GPU. Note that this does not indicate the maximum number of bits that can be set in NV_CTRL_CONNECTED_DISPLAYS, because more display devices can be connected than are actively in use. """ return query_int_attribute(self, target, 0, NV_CTRL_MAX_DISPLAYS) def _displaystr2num(st): """Return a display number from a string""" num = None for s, n in [('DFP-', 16), ('TV-', 8), ('CRT-', 0)]: if st.startswith(s): try: curnum = int(st[len(s):]) if 0 <= curnum <= 7: num = n + curnum break except Exception: pass if num is not None: return num else: raise ValueError('Unrecognised display name: ' + st) def _displays2mask(displays): """Return a display mask from an array of display numbers.""" mask = 0 for d in displays: mask += (1 << _displaystr2num(d)) return mask def init(disp, info): disp.extension_add_method('display', 'nvcontrol_query_target_count', query_target_count) disp.extension_add_method('display', 'nvcontrol_query_int_attribute', query_int_attribute) disp.extension_add_method('display', 'nvcontrol_query_string_attribute', query_string_attribute) disp.extension_add_method('display', 'nvcontrol_query_valid_attr_values', query_valid_attr_values) disp.extension_add_method('display', 'nvcontrol_query_binary_data', query_binary_data) disp.extension_add_method('display', 'nvcontrol_get_gpu_count', get_gpu_count) disp.extension_add_method('display', 'nvcontrol_get_vram', get_vram) disp.extension_add_method('display', 'nvcontrol_get_irq', get_irq) disp.extension_add_method('display', 'nvcontrol_supports_framelock', supports_framelock) disp.extension_add_method('display', 'nvcontrol_get_core_temp', get_core_temp) disp.extension_add_method('display', 'nvcontrol_get_core_threshold', get_core_threshold) disp.extension_add_method('display', 'nvcontrol_get_default_core_threshold', get_default_core_threshold) disp.extension_add_method('display', 'nvcontrol_get_max_core_threshold', get_max_core_threshold) disp.extension_add_method('display', 'nvcontrol_get_ambient_temp', get_ambient_temp) disp.extension_add_method('display', 'nvcontrol_get_cuda_cores', get_cuda_cores) disp.extension_add_method('display', 'nvcontrol_get_memory_bus_width', get_memory_bus_width) disp.extension_add_method('display', 'nvcontrol_get_total_dedicated_gpu_memory', get_total_dedicated_gpu_memory) disp.extension_add_method('display', 'nvcontrol_get_used_dedicated_gpu_memory', get_used_dedicated_gpu_memory) disp.extension_add_method('display', 'nvcontrol_get_curr_pcie_link_width', get_curr_pcie_link_width) disp.extension_add_method('display', 'nvcontrol_get_max_pcie_link_width', get_max_pcie_link_width) disp.extension_add_method('display', 'nvcontrol_get_curr_pcie_link_generation', get_curr_pcie_link_generation) disp.extension_add_method('display', 'nvcontrol_get_encoder_utilization', get_encoder_utilization) disp.extension_add_method('display', 'nvcontrol_get_decoder_utilization', get_decoder_utilization) disp.extension_add_method('display', 'nvcontrol_get_current_performance_level', get_current_performance_level) disp.extension_add_method('display', 'nvcontrol_get_gpu_nvclock_offset', get_gpu_nvclock_offset) disp.extension_add_method('display', 'nvcontrol_set_gpu_nvclock_offset', set_gpu_nvclock_offset) disp.extension_add_method('display', 'nvcontrol_set_gpu_nvclock_offset_all_levels', set_gpu_nvclock_offset_all_levels) disp.extension_add_method('display', 'nvcontrol_get_mem_transfer_rate_offset', get_mem_transfer_rate_offset) disp.extension_add_method('display', 'nvcontrol_set_mem_transfer_rate_offset', set_mem_transfer_rate_offset) disp.extension_add_method('display', 'nvcontrol_set_mem_transfer_rate_offset_all_levels', set_mem_transfer_rate_offset_all_levels) disp.extension_add_method('display', 'nvcontrol_get_cooler_manual_control_enabled', get_cooler_manual_control_enabled) disp.extension_add_method('display', 'nvcontrol_get_fan_duty', get_fan_duty) disp.extension_add_method('display', 'nvcontrol_set_fan_duty', set_fan_duty) disp.extension_add_method('display', 'nvcontrol_get_fan_rpm', get_fan_rpm) disp.extension_add_method('display', 'nvcontrol_get_coolers_used_by_gpu', get_coolers_used_by_gpu) disp.extension_add_method('display', 'nvcontrol_get_max_displays', get_max_displays) disp.extension_add_method('display', 'nvcontrol_get_name', get_name) disp.extension_add_method('display', 'nvcontrol_get_driver_version', get_driver_version) disp.extension_add_method('display', 'nvcontrol_get_vbios_version', get_vbios_version) disp.extension_add_method('display', 'nvcontrol_get_gpu_uuid', get_gpu_uuid) disp.extension_add_method('display', 'nvcontrol_get_utilization_rates', get_utilization_rates) disp.extension_add_method('display', 'nvcontrol_get_performance_modes', get_performance_modes) disp.extension_add_method('display', 'nvcontrol_get_clock_info', get_clock_info) disp.extension_add_method('display', 'nvcontrol_set_cooler_manual_control_enabled', set_cooler_manual_control_enabled) disp.extension_add_method('display', 'nvcontrol_get_gpu_nvclock_offset_range', get_gpu_nvclock_offset_range) disp.extension_add_method('display', 'nvcontrol_get_mem_transfer_rate_offset_range', get_mem_transfer_rate_offset_range) ############################################################################ # # Attributes # # Some attributes may only be read; some may require a display_mask # argument and others may be valid only for specific target types. # This information is encoded in the "permission" comment after each # attribute #define, and can be queried at run time with # XNVCTRLQueryValidAttributeValues() and/or # XNVCTRLQueryValidTargetAttributeValues() # # Key to Integer Attribute "Permissions": # # R: The attribute is readable (in general, all attributes will be # readable) # # W: The attribute is writable (attributes may not be writable for # various reasons: they represent static system information, they # can only be changed by changing an XF86Config option, etc). # # D: The attribute requires the display mask argument. The # attributes NV_CTRL_CONNECTED_DISPLAYS and NV_CTRL_ENABLED_DISPLAYS # will be a bitmask of what display devices are connected and what # display devices are enabled for use in X, respectively. Each bit # in the bitmask represents a display device; it is these bits which # should be used as the display_mask when dealing with attributes # designated with "D" below. For attributes that do not require the # display mask, the argument is ignored. # # Alternatively, NV-CONTROL versions 1.27 and greater allow these # attributes to be accessed via display target types, in which case # the display_mask is ignored. # # G: The attribute may be queried using an NV_CTRL_TARGET_TYPE_GPU # target type via XNVCTRLQueryTargetAttribute(). # # F: The attribute may be queried using an NV_CTRL_TARGET_TYPE_FRAMELOCK # target type via XNVCTRLQueryTargetAttribute(). # # X: When Xinerama is enabled, this attribute is kept consistent across # all Physical X Screens; assignment of this attribute will be # broadcast by the NVIDIA X Driver to all X Screens. # # V: The attribute may be queried using an NV_CTRL_TARGET_TYPE_VCSC # target type via XNVCTRLQueryTargetAttribute(). # # I: The attribute may be queried using an NV_CTRL_TARGET_TYPE_GVI target type # via XNVCTRLQueryTargetAttribute(). # # Q: The attribute is a 64-bit integer attribute; use the 64-bit versions # of the appropriate query interfaces. # # C: The attribute may be queried using an NV_CTRL_TARGET_TYPE_COOLER target # type via XNVCTRLQueryTargetAttribute(). # # S: The attribute may be queried using an NV_CTRL_TARGET_TYPE_THERMAL_SENSOR # target type via XNVCTRLQueryTargetAttribute(). # # T: The attribute may be queried using an # NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER target type # via XNVCTRLQueryTargetAttribute(). # # NOTE: Unless mentioned otherwise, all attributes may be queried using # an NV_CTRL_TARGET_TYPE_X_SCREEN target type via # XNVCTRLQueryTargetAttribute(). # ############################################################################ # # Integer attributes: # # Integer attributes can be queried through the XNVCTRLQueryAttribute() and # XNVCTRLQueryTargetAttribute() function calls. # # Integer attributes can be set through the XNVCTRLSetAttribute() and # XNVCTRLSetTargetAttribute() function calls. # # Unless otherwise noted, all integer attributes can be queried/set # using an NV_CTRL_TARGET_TYPE_X_SCREEN target. Attributes that cannot # take an NV_CTRL_TARGET_TYPE_X_SCREEN also cannot be queried/set through # XNVCTRLQueryAttribute()/XNVCTRLSetAttribute() (Since these assume # an X Screen target). # # # NV_CTRL_FLATPANEL_SCALING - not supported # NV_CTRL_FLATPANEL_SCALING = 2 # not supported NV_CTRL_FLATPANEL_SCALING_DEFAULT = 0 # not supported NV_CTRL_FLATPANEL_SCALING_NATIVE = 1 # not supported NV_CTRL_FLATPANEL_SCALING_SCALED = 2 # not supported NV_CTRL_FLATPANEL_SCALING_CENTERED = 3 # not supported NV_CTRL_FLATPANEL_SCALING_ASPECT_SCALED = 4 # not supported # # NV_CTRL_FLATPANEL_DITHERING - not supported # # NV_CTRL_DITHERING should be used instead. # NV_CTRL_FLATPANEL_DITHERING = 3 # not supported NV_CTRL_FLATPANEL_DITHERING_DEFAULT = 0 # not supported NV_CTRL_FLATPANEL_DITHERING_ENABLED = 1 # not supported NV_CTRL_FLATPANEL_DITHERING_DISABLED = 2 # not supported # # NV_CTRL_DITHERING - the requested dithering configuration; # possible values are: # # 0: auto (the driver will decide when to dither) # 1: enabled (the driver will always dither when possible) # 2: disabled (the driver will never dither) # NV_CTRL_DITHERING = 3 # RWDG NV_CTRL_DITHERING_AUTO = 0 NV_CTRL_DITHERING_ENABLED = 1 NV_CTRL_DITHERING_DISABLED = 2 # # NV_CTRL_DIGITAL_VIBRANCE - sets the digital vibrance level for the # specified display device. # NV_CTRL_DIGITAL_VIBRANCE = 4 # RWDG # # NV_CTRL_BUS_TYPE - returns the bus type through which the specified device # is connected to the computer. # When this attribute is queried on an X screen target, the bus type of the # GPU driving the X screen is returned. # NV_CTRL_BUS_TYPE = 5 # R--GI NV_CTRL_BUS_TYPE_AGP = 0 NV_CTRL_BUS_TYPE_PCI = 1 NV_CTRL_BUS_TYPE_PCI_EXPRESS = 2 NV_CTRL_BUS_TYPE_INTEGRATED = 3 # # NV_CTRL_TOTAL_GPU_MEMORY - returns the total amount of memory available # to the specified GPU (or the GPU driving the specified X # screen). Note: if the GPU supports TurboCache(TM), the value # reported may exceed the amount of video memory installed on the # GPU. The value reported for integrated GPUs may likewise exceed # the amount of dedicated system memory set aside by the system # BIOS for use by the integrated GPU. # NV_CTRL_TOTAL_GPU_MEMORY = 6 # R--G NV_CTRL_VIDEO_RAM = NV_CTRL_TOTAL_GPU_MEMORY # # NV_CTRL_IRQ - returns the interrupt request line used by the specified # device. # When this attribute is queried on an X screen target, the IRQ of the GPU # driving the X screen is returned. # NV_CTRL_IRQ = 7 # R--GI # # NV_CTRL_OPERATING_SYSTEM - returns the operating system on which # the X server is running. # NV_CTRL_OPERATING_SYSTEM = 8 # R--G NV_CTRL_OPERATING_SYSTEM_LINUX = 0 NV_CTRL_OPERATING_SYSTEM_FREEBSD = 1 NV_CTRL_OPERATING_SYSTEM_SUNOS = 2 # # NV_CTRL_SYNC_TO_VBLANK - enables sync to vblank for OpenGL clients. # This setting is only applied to OpenGL clients that are started # after this setting is applied. # NV_CTRL_SYNC_TO_VBLANK = 9 # RW-X NV_CTRL_SYNC_TO_VBLANK_OFF = 0 NV_CTRL_SYNC_TO_VBLANK_ON = 1 # # NV_CTRL_LOG_ANISO - enables anisotropic filtering for OpenGL # clients; on some NVIDIA hardware, this can only be enabled or # disabled; on other hardware different levels of anisotropic # filtering can be specified. This setting is only applied to OpenGL # clients that are started after this setting is applied. # NV_CTRL_LOG_ANISO = 10 # RW-X # # NV_CTRL_FSAA_MODE - the FSAA setting for OpenGL clients; possible # FSAA modes: # # NV_CTRL_FSAA_MODE_2x "2x Bilinear Multisampling" # NV_CTRL_FSAA_MODE_2x_5t "2x Quincunx Multisampling" # NV_CTRL_FSAA_MODE_15x15 "1.5 x 1.5 Supersampling" # NV_CTRL_FSAA_MODE_2x2 "2 x 2 Supersampling" # NV_CTRL_FSAA_MODE_4x "4x Bilinear Multisampling" # NV_CTRL_FSAA_MODE_4x_9t "4x Gaussian Multisampling" # NV_CTRL_FSAA_MODE_8x "2x Bilinear Multisampling by 4x Supersampling" # NV_CTRL_FSAA_MODE_16x "4x Bilinear Multisampling by 4x Supersampling" # NV_CTRL_FSAA_MODE_8xS "4x Multisampling by 2x Supersampling" # # This setting is only applied to OpenGL clients that are started # after this setting is applied. # NV_CTRL_FSAA_MODE = 11 # RW-X NV_CTRL_FSAA_MODE_NONE = 0 NV_CTRL_FSAA_MODE_2x = 1 NV_CTRL_FSAA_MODE_2x_5t = 2 NV_CTRL_FSAA_MODE_15x15 = 3 NV_CTRL_FSAA_MODE_2x2 = 4 NV_CTRL_FSAA_MODE_4x = 5 NV_CTRL_FSAA_MODE_4x_9t = 6 NV_CTRL_FSAA_MODE_8x = 7 NV_CTRL_FSAA_MODE_16x = 8 NV_CTRL_FSAA_MODE_8xS = 9 NV_CTRL_FSAA_MODE_8xQ = 10 NV_CTRL_FSAA_MODE_16xS = 11 NV_CTRL_FSAA_MODE_16xQ = 12 NV_CTRL_FSAA_MODE_32xS = 13 NV_CTRL_FSAA_MODE_32x = 14 NV_CTRL_FSAA_MODE_64xS = 15 NV_CTRL_FSAA_MODE_MAX = NV_CTRL_FSAA_MODE_64xS # # NV_CTRL_UBB - returns whether UBB is enabled for the specified X # screen. # NV_CTRL_UBB = 13 # R-- NV_CTRL_UBB_OFF = 0 NV_CTRL_UBB_ON = 1 # # NV_CTRL_OVERLAY - returns whether the RGB overlay is enabled for # the specified X screen. # NV_CTRL_OVERLAY = 14 # R-- NV_CTRL_OVERLAY_OFF = 0 NV_CTRL_OVERLAY_ON = 1 # # NV_CTRL_STEREO - returns whether stereo (and what type) is enabled # for the specified X screen. # NV_CTRL_STEREO = 16 # R-- NV_CTRL_STEREO_OFF = 0 NV_CTRL_STEREO_DDC = 1 NV_CTRL_STEREO_BLUELINE = 2 NV_CTRL_STEREO_DIN = 3 NV_CTRL_STEREO_PASSIVE_EYE_PER_DPY = 4 NV_CTRL_STEREO_VERTICAL_INTERLACED = 5 NV_CTRL_STEREO_COLOR_INTERLACED = 6 NV_CTRL_STEREO_HORIZONTAL_INTERLACED = 7 NV_CTRL_STEREO_CHECKERBOARD_PATTERN = 8 NV_CTRL_STEREO_INVERSE_CHECKERBOARD_PATTERN = 9 NV_CTRL_STEREO_3D_VISION = 10 NV_CTRL_STEREO_3D_VISION_PRO = 11 NV_CTRL_STEREO_HDMI_3D = 12 NV_CTRL_STEREO_TRIDELITY_SL = 13 NV_CTRL_STEREO_INBAND_STEREO_SIGNALING = 14 NV_CTRL_STEREO_MAX = NV_CTRL_STEREO_INBAND_STEREO_SIGNALING # # NV_CTRL_EMULATE - not supported # NV_CTRL_EMULATE = 17 # not supported NV_CTRL_EMULATE_NONE = 0 # not supported # # NV_CTRL_TWINVIEW - returns whether TwinView is enabled for the # specified X screen. # NV_CTRL_TWINVIEW = 18 # R-- NV_CTRL_TWINVIEW_NOT_ENABLED = 0 NV_CTRL_TWINVIEW_ENABLED = 1 # # NV_CTRL_CONNECTED_DISPLAYS - deprecated # # NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU and # NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN should be used instead. # NV_CTRL_CONNECTED_DISPLAYS = 19 # deprecated # # NV_CTRL_ENABLED_DISPLAYS - Event that notifies when one or more display # devices are enabled or disabled on a GPU and/or X screen. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # # Note: Querying this value has been deprecated. # NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU, # NV_CTRL_DISPLAY_ENABLED, and # NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN should be used # instead to obtain the list of enabled displays. # NV_CTRL_ENABLED_DISPLAYS = 20 # ---G ############################################################################ # # Integer attributes specific to configuring Frame Lock on boards that # support it. # # # NV_CTRL_FRAMELOCK - returns whether the underlying GPU supports # Frame Lock. All of the other frame lock attributes are only # applicable if NV_CTRL_FRAMELOCK is _SUPPORTED. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_FRAMELOCK = 21 # R--G NV_CTRL_FRAMELOCK_NOT_SUPPORTED = 0 NV_CTRL_FRAMELOCK_SUPPORTED = 1 # # NV_CTRL_FRAMELOCK_MASTER - deprecated # # NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead. # NV_CTRL_FRAMELOCK_MASTER = 22 # deprecated NV_CTRL_FRAMELOCK_MASTER_FALSE = 0 # deprecated NV_CTRL_FRAMELOCK_MASTER_TRUE = 1 # deprecated # # NV_CTRL_FRAMELOCK_POLARITY - sync either to the rising edge of the # frame lock pulse, the falling edge of the frame lock pulse or both. # # On Quadro Sync II, this attribute is ignored when # NV_CTRL_USE_HOUSE_SYNC is OUTPUT. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_FRAMELOCK_POLARITY = 23 # RW-F NV_CTRL_FRAMELOCK_POLARITY_RISING_EDGE = 0x1 NV_CTRL_FRAMELOCK_POLARITY_FALLING_EDGE = 0x2 NV_CTRL_FRAMELOCK_POLARITY_BOTH_EDGES = 0x3 # # NV_CTRL_FRAMELOCK_SYNC_DELAY - delay between the frame lock pulse # and the GPU sync. This value must be multiplied by # NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION to determine the sync delay in # nanoseconds. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # # USAGE NOTE: NV_CTRL_FRAMELOCK_SYNC_DELAY_MAX and # NV_CTRL_FRAMELOCK_SYNC_DELAY_FACTOR are deprecated. # The Sync Delay _MAX and _FACTOR are different for different # Quadro Sync products and so, to be correct, the valid values for # NV_CTRL_FRAMELOCK_SYNC_DELAY must be queried to get the range # of acceptable sync delay values, and # NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION must be queried to # obtain the correct factor. # NV_CTRL_FRAMELOCK_SYNC_DELAY = 24 # RW-F NV_CTRL_FRAMELOCK_SYNC_DELAY_MAX = 2047 # deprecated NV_CTRL_FRAMELOCK_SYNC_DELAY_FACTOR = 7.81 # deprecated # # NV_CTRL_FRAMELOCK_SYNC_INTERVAL - how many house sync pulses # between the frame lock sync generation (0 == sync every house sync); # this only applies to the master when receiving house sync. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_FRAMELOCK_SYNC_INTERVAL = 25 # RW-F # # NV_CTRL_FRAMELOCK_PORT0_STATUS - status of the rj45 port0. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_FRAMELOCK_PORT0_STATUS = 26 # R--F NV_CTRL_FRAMELOCK_PORT0_STATUS_INPUT = 0 NV_CTRL_FRAMELOCK_PORT0_STATUS_OUTPUT = 1 # # NV_CTRL_FRAMELOCK_PORT1_STATUS - status of the rj45 port1. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_FRAMELOCK_PORT1_STATUS = 27 # R--F NV_CTRL_FRAMELOCK_PORT1_STATUS_INPUT = 0 NV_CTRL_FRAMELOCK_PORT1_STATUS_OUTPUT = 1 # # NV_CTRL_FRAMELOCK_HOUSE_STATUS - returns whether or not the house # sync input signal was detected on the BNC connector of the frame lock # board. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_FRAMELOCK_HOUSE_STATUS = 28 # R--F NV_CTRL_FRAMELOCK_HOUSE_STATUS_NOT_DETECTED = 0 NV_CTRL_FRAMELOCK_HOUSE_STATUS_DETECTED = 1 # # NV_CTRL_FRAMELOCK_SYNC - enable/disable the syncing of display # devices to the frame lock pulse as specified by previous calls to # NV_CTRL_FRAMELOCK_DISPLAY_CONFIG. # # This attribute can only be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be # queried using a NV_CTRL_TARGET_TYPE_X_SCREEN. # NV_CTRL_FRAMELOCK_SYNC = 29 # RW-G NV_CTRL_FRAMELOCK_SYNC_DISABLE = 0 NV_CTRL_FRAMELOCK_SYNC_ENABLE = 1 # # NV_CTRL_FRAMELOCK_SYNC_READY - reports whether a frame lock # board is receiving sync (regardless of whether or not any display # devices are using the sync). # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_FRAMELOCK_SYNC_READY = 30 # R--F NV_CTRL_FRAMELOCK_SYNC_READY_FALSE = 0 NV_CTRL_FRAMELOCK_SYNC_READY_TRUE = 1 # # NV_CTRL_FRAMELOCK_STEREO_SYNC - this indicates that the GPU stereo # signal is in sync with the frame lock stereo signal. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_FRAMELOCK_STEREO_SYNC = 31 # R--G NV_CTRL_FRAMELOCK_STEREO_SYNC_FALSE = 0 NV_CTRL_FRAMELOCK_STEREO_SYNC_TRUE = 1 # # NV_CTRL_FRAMELOCK_TEST_SIGNAL - to test the connections in the sync # group, tell the master to enable a test signal, then query port[01] # status and sync_ready on all slaves. When done, tell the master to # disable the test signal. Test signal should only be manipulated # while NV_CTRL_FRAMELOCK_SYNC is enabled. # # The TEST_SIGNAL is also used to reset the Universal Frame Count (as # returned by the glXQueryFrameCountNV() function in the # GLX_NV_swap_group extension). Note: for best accuracy of the # Universal Frame Count, it is recommended to toggle the TEST_SIGNAL # on and off after enabling frame lock. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_FRAMELOCK_TEST_SIGNAL = 32 # RW-G NV_CTRL_FRAMELOCK_TEST_SIGNAL_DISABLE = 0 NV_CTRL_FRAMELOCK_TEST_SIGNAL_ENABLE = 1 # # NV_CTRL_FRAMELOCK_ETHERNET_DETECTED - The frame lock boards are # cabled together using regular cat5 cable, connecting to rj45 ports # on the backplane of the card. There is some concern that users may # think these are ethernet ports and connect them to a # router/hub/etc. The hardware can detect this and will shut off to # prevent damage (either to itself or to the router). # NV_CTRL_FRAMELOCK_ETHERNET_DETECTED may be called to find out if # ethernet is connected to one of the rj45 ports. An appropriate # error message should then be displayed. The _PORT0 and _PORT1 # values may be or'ed together. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_FRAMELOCK_ETHERNET_DETECTED = 33 # R--F NV_CTRL_FRAMELOCK_ETHERNET_DETECTED_NONE = 0 NV_CTRL_FRAMELOCK_ETHERNET_DETECTED_PORT0 = 0x1 NV_CTRL_FRAMELOCK_ETHERNET_DETECTED_PORT1 = 0x2 # # NV_CTRL_FRAMELOCK_VIDEO_MODE - get/set what video mode is used # to interperate the house sync signal. This should only be set # on the master. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_FRAMELOCK_VIDEO_MODE = 34 # RW-F NV_CTRL_FRAMELOCK_VIDEO_MODE_NONE = 0 NV_CTRL_FRAMELOCK_VIDEO_MODE_TTL = 1 NV_CTRL_FRAMELOCK_VIDEO_MODE_NTSCPALSECAM = 2 NV_CTRL_FRAMELOCK_VIDEO_MODE_HDTV = 3 # # During FRAMELOCK bring-up, the above values were redefined to # these: # NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_AUTO = 0 NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_BI_LEVEL = 2 NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_TRI_LEVEL = 3 # # NV_CTRL_FRAMELOCK_SYNC_RATE - this is the refresh rate that the # frame lock board is sending to the GPU, in milliHz. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_FRAMELOCK_SYNC_RATE = 35 # R--F ############################################################################ # # NV_CTRL_FORCE_GENERIC_CPU - not supported # NV_CTRL_FORCE_GENERIC_CPU = 37 # not supported NV_CTRL_FORCE_GENERIC_CPU_DISABLE = 0 # not supported NV_CTRL_FORCE_GENERIC_CPU_ENABLE = 1 # not supported # # NV_CTRL_OPENGL_AA_LINE_GAMMA - for OpenGL clients, allow # Gamma-corrected antialiased lines to consider variances in the # color display capabilities of output devices when rendering smooth # lines. Only available on recent Quadro GPUs. This setting is only # applied to OpenGL clients that are started after this setting is # applied. # NV_CTRL_OPENGL_AA_LINE_GAMMA = 38 # RW-X NV_CTRL_OPENGL_AA_LINE_GAMMA_DISABLE = 0 NV_CTRL_OPENGL_AA_LINE_GAMMA_ENABLE = 1 # # NV_CTRL_FRAMELOCK_TIMING - this is TRUE when the gpu is both receiving # and locked to an input timing signal. Timing information may come from # the following places: Another frame lock device that is set to master, # the house sync signal, or the GPU's internal timing from a display # device. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_FRAMELOCK_TIMING = 39 # R--G NV_CTRL_FRAMELOCK_TIMING_FALSE = 0 NV_CTRL_FRAMELOCK_TIMING_TRUE = 1 # # NV_CTRL_FLIPPING_ALLOWED - when TRUE, OpenGL will swap by flipping # when possible; when FALSE, OpenGL will always swap by blitting. # NV_CTRL_FLIPPING_ALLOWED = 40 # RW-X NV_CTRL_FLIPPING_ALLOWED_FALSE = 0 NV_CTRL_FLIPPING_ALLOWED_TRUE = 1 # # NV_CTRL_ARCHITECTURE - returns the architecture on which the X server is # running. # NV_CTRL_ARCHITECTURE = 41 # R-- NV_CTRL_ARCHITECTURE_X86 = 0 NV_CTRL_ARCHITECTURE_X86_64 = 1 NV_CTRL_ARCHITECTURE_IA64 = 2 NV_CTRL_ARCHITECTURE_ARM = 3 NV_CTRL_ARCHITECTURE_AARCH64 = 4 NV_CTRL_ARCHITECTURE_PPC64LE = 5 # # NV_CTRL_TEXTURE_CLAMPING - texture clamping mode in OpenGL. By # default, _SPEC is used, which forces OpenGL texture clamping to # conform with the OpenGL specification. _EDGE forces NVIDIA's # OpenGL implementation to remap GL_CLAMP to GL_CLAMP_TO_EDGE, # which is not strictly conformant, but some applications rely on # the non-conformant behavior. # NV_CTRL_TEXTURE_CLAMPING = 42 # RW-X NV_CTRL_TEXTURE_CLAMPING_EDGE = 0 NV_CTRL_TEXTURE_CLAMPING_SPEC = 1 # # The NV_CTRL_CURSOR_SHADOW - not supported # # use an ARGB cursor instead. # NV_CTRL_CURSOR_SHADOW = 43 # not supported NV_CTRL_CURSOR_SHADOW_DISABLE = 0 # not supported NV_CTRL_CURSOR_SHADOW_ENABLE = 1 # not supported NV_CTRL_CURSOR_SHADOW_ALPHA = 44 # not supported NV_CTRL_CURSOR_SHADOW_RED = 45 # not supported NV_CTRL_CURSOR_SHADOW_GREEN = 46 # not supported NV_CTRL_CURSOR_SHADOW_BLUE = 47 # not supported NV_CTRL_CURSOR_SHADOW_X_OFFSET = 48 # not supported NV_CTRL_CURSOR_SHADOW_Y_OFFSET = 49 # not supported # # When Application Control for FSAA is enabled, then what the # application requests is used, and NV_CTRL_FSAA_MODE is ignored. If # this is disabled, then any application setting is overridden with # NV_CTRL_FSAA_MODE # NV_CTRL_FSAA_APPLICATION_CONTROLLED = 50 # RW-X NV_CTRL_FSAA_APPLICATION_CONTROLLED_ENABLED = 1 NV_CTRL_FSAA_APPLICATION_CONTROLLED_DISABLED = 0 # # When Application Control for LogAniso is enabled, then what the # application requests is used, and NV_CTRL_LOG_ANISO is ignored. If # this is disabled, then any application setting is overridden with # NV_CTRL_LOG_ANISO # NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED = 51 # RW-X NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED_ENABLED = 1 NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED_DISABLED = 0 # # IMAGE_SHARPENING adjusts the sharpness of the display's image # quality by amplifying high frequency content. Valid values will # normally be in the range [0,32). Only available on GeForceFX or # newer. # NV_CTRL_IMAGE_SHARPENING = 52 # RWDG # # NV_CTRL_TV_OVERSCAN - not supported # NV_CTRL_TV_OVERSCAN = 53 # not supported # # NV_CTRL_TV_FLICKER_FILTER - not supported # NV_CTRL_TV_FLICKER_FILTER = 54 # not supported # # NV_CTRL_TV_BRIGHTNESS - not supported # NV_CTRL_TV_BRIGHTNESS = 55 # not supported # # NV_CTRL_TV_HUE - not supported # NV_CTRL_TV_HUE = 56 # not supported # # NV_CTRL_TV_CONTRAST - not suppoerted # NV_CTRL_TV_CONTRAST = 57 # not supported # # NV_CTRL_TV_SATURATION - not supported # NV_CTRL_TV_SATURATION = 58 # not supported # # NV_CTRL_TV_RESET_SETTINGS - not supported # NV_CTRL_TV_RESET_SETTINGS = 59 # not supported # # NV_CTRL_GPU_CORE_TEMPERATURE reports the current core temperature # of the GPU driving the X screen. # NV_CTRL_GPU_CORE_TEMPERATURE = 60 # R--G # # NV_CTRL_GPU_CORE_THRESHOLD reports the current GPU core slowdown # threshold temperature, NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD and # NV_CTRL_GPU_MAX_CORE_THRESHOLD report the default and MAX core # slowdown threshold temperatures. # # NV_CTRL_GPU_CORE_THRESHOLD reflects the temperature at which the # GPU is throttled to prevent overheating. # NV_CTRL_GPU_CORE_THRESHOLD = 61 # R--G NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD = 62 # R--G NV_CTRL_GPU_MAX_CORE_THRESHOLD = 63 # R--G # # NV_CTRL_AMBIENT_TEMPERATURE reports the current temperature in the # immediate neighbourhood of the GPU driving the X screen. # NV_CTRL_AMBIENT_TEMPERATURE = 64 # R--G # # NV_CTRL_PBUFFER_SCANOUT_SUPPORTED - returns whether this X screen # supports scanout of FP pbuffers; # # if this screen does not support PBUFFER_SCANOUT, then all other # PBUFFER_SCANOUT attributes are unavailable. # # PBUFFER_SCANOUT is supported if and only if: # - Twinview is configured with clone mode. The secondary screen is used to # scanout the pbuffer. # - The desktop is running in with 16 bits per pixel. # NV_CTRL_PBUFFER_SCANOUT_SUPPORTED = 65 # not supported NV_CTRL_PBUFFER_SCANOUT_FALSE = 0 NV_CTRL_PBUFFER_SCANOUT_TRUE = 1 # # NV_CTRL_PBUFFER_SCANOUT_XID indicates the XID of the pbuffer used for # scanout. # NV_CTRL_PBUFFER_SCANOUT_XID = 66 # not supported ############################################################################ # # The NV_CTRL_GVO_* integer attributes are used to configure GVO # (Graphics to Video Out). This functionality is available, for # example, on the Quadro SDI Output card. # # The following is a typical usage pattern for the GVO attributes: # # - query NV_CTRL_GVO_SUPPORTED to determine if the X screen supports GV0. # # - specify NV_CTRL_GVO_SYNC_MODE (one of FREE_RUNNING, GENLOCK, or # FRAMELOCK); if you specify GENLOCK or FRAMELOCK, you should also # specify NV_CTRL_GVO_SYNC_SOURCE. # # - Use NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED and # NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED to detect what input syncs are # present. # # (If no analog sync is detected but it is known that a valid # bi-level or tri-level sync is connected set # NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE appropriately and # retest with NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED). # # - if syncing to input sync, query the # NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT attribute; note that Input video # format can only be queried after SYNC_SOURCE is specified. # # - specify the NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT # # - specify the NV_CTRL_GVO_DATA_FORMAT # # - specify any custom Color Space Conversion (CSC) matrix, offset, # and scale with XNVCTRLSetGvoColorConversion(). # # - if using the GLX_NV_video_out extension to display one or more # pbuffers, call glXGetVideoDeviceNV() to lock the GVO output for use # by the GLX client; then bind the pbuffer(s) to the GVO output with # glXBindVideoImageNV() and send pbuffers to the GVO output with # glXSendPbufferToVideoNV(); see the GLX_NV_video_out spec for more # details. # # - if using the GLX_NV_present_video extension, call # glXBindVideoDeviceNV() to bind the GVO video device to current # OpenGL context. # # Note that setting most GVO attributes only causes the value to be # cached in the X server. The values will be flushed to the hardware # either when the next MetaMode is set that uses the GVO display # device, or when a GLX pbuffer is bound to the GVO output (with # glXBindVideoImageNV()). # # Note that GLX_NV_video_out/GLX_NV_present_video and X screen use # are mutually exclusive. If a MetaMode is currently using the GVO # device, then glXGetVideoDeviceNV and glXBindVideoImageNV() will # fail. Similarly, if a GLX client has locked the GVO output (via # glXGetVideoDeviceNV or glXBindVideoImageNV), then setting a # MetaMode that uses the GVO device will fail. The # NV_CTRL_GVO_GLX_LOCKED event will be sent when a GLX client locks # the GVO output. # # # # NV_CTRL_GVO_SUPPORTED - returns whether this X screen supports GVO; # if this screen does not support GVO output, then all other GVO # attributes are unavailable. # NV_CTRL_GVO_SUPPORTED = 67 # R-- NV_CTRL_GVO_SUPPORTED_FALSE = 0 NV_CTRL_GVO_SUPPORTED_TRUE = 1 # # NV_CTRL_GVO_SYNC_MODE - selects the GVO sync mode; possible values # are: # # FREE_RUNNING - GVO does not sync to any external signal # # GENLOCK - the GVO output is genlocked to an incoming sync signal; # genlocking locks at hsync. This requires that the output video # format exactly match the incoming sync video format. # # FRAMELOCK - the GVO output is frame locked to an incoming sync # signal; frame locking locks at vsync. This requires that the output # video format have the same refresh rate as the incoming sync video # format. # NV_CTRL_GVO_SYNC_MODE = 68 # RW- NV_CTRL_GVO_SYNC_MODE_FREE_RUNNING = 0 NV_CTRL_GVO_SYNC_MODE_GENLOCK = 1 NV_CTRL_GVO_SYNC_MODE_FRAMELOCK = 2 # # NV_CTRL_GVO_SYNC_SOURCE - if NV_CTRL_GVO_SYNC_MODE is set to either # GENLOCK or FRAMELOCK, this controls which sync source is used as # the incoming sync signal (either Composite or SDI). If # NV_CTRL_GVO_SYNC_MODE is FREE_RUNNING, this attribute has no # effect. # NV_CTRL_GVO_SYNC_SOURCE = 69 # RW- NV_CTRL_GVO_SYNC_SOURCE_COMPOSITE = 0 NV_CTRL_GVO_SYNC_SOURCE_SDI = 1 # # NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT - specifies the desired output video # format for GVO devices or the desired input video format for GVI devices. # # Note that for GVO, the valid video formats may vary depending on # the NV_CTRL_GVO_SYNC_MODE and the incoming sync video format. See # the definition of NV_CTRL_GVO_SYNC_MODE. # # Note that when querying the ValidValues for this data type, the # values are reported as bits within a bitmask # (ATTRIBUTE_TYPE_INT_BITS); unfortunately, there are more valid # value bits than will fit in a single 32-bit value. To solve this, # query the ValidValues for NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT to # check which of the first 31 VIDEO_FORMATS are valid, query the # ValidValues for NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 to check which # of the 32-63 VIDEO_FORMATS are valid, and query the ValidValues of # NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3 to check which of the 64-95 # VIDEO_FORMATS are valid. # # Note: Setting this attribute on a GVI device may also result in the # following NV-CONTROL attributes being reset on that device (to # ensure the configuration remains valid): # NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT # NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING # NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT = 70 # RW--I NV_CTRL_GVIO_VIDEO_FORMAT_NONE = 0 NV_CTRL_GVIO_VIDEO_FORMAT_487I_59_94_SMPTE259_NTSC = 1 NV_CTRL_GVIO_VIDEO_FORMAT_576I_50_00_SMPTE259_PAL = 2 NV_CTRL_GVIO_VIDEO_FORMAT_720P_59_94_SMPTE296 = 3 NV_CTRL_GVIO_VIDEO_FORMAT_720P_60_00_SMPTE296 = 4 NV_CTRL_GVIO_VIDEO_FORMAT_1035I_59_94_SMPTE260 = 5 NV_CTRL_GVIO_VIDEO_FORMAT_1035I_60_00_SMPTE260 = 6 NV_CTRL_GVIO_VIDEO_FORMAT_1080I_50_00_SMPTE295 = 7 NV_CTRL_GVIO_VIDEO_FORMAT_1080I_50_00_SMPTE274 = 8 NV_CTRL_GVIO_VIDEO_FORMAT_1080I_59_94_SMPTE274 = 9 NV_CTRL_GVIO_VIDEO_FORMAT_1080I_60_00_SMPTE274 = 10 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_23_976_SMPTE274 = 11 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_24_00_SMPTE274 = 12 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_25_00_SMPTE274 = 13 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_29_97_SMPTE274 = 14 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_30_00_SMPTE274 = 15 NV_CTRL_GVIO_VIDEO_FORMAT_720P_50_00_SMPTE296 = 16 NV_CTRL_GVIO_VIDEO_FORMAT_1080I_48_00_SMPTE274 = 17 NV_CTRL_GVIO_VIDEO_FORMAT_1080I_47_96_SMPTE274 = 18 NV_CTRL_GVIO_VIDEO_FORMAT_720P_30_00_SMPTE296 = 19 NV_CTRL_GVIO_VIDEO_FORMAT_720P_29_97_SMPTE296 = 20 NV_CTRL_GVIO_VIDEO_FORMAT_720P_25_00_SMPTE296 = 21 NV_CTRL_GVIO_VIDEO_FORMAT_720P_24_00_SMPTE296 = 22 NV_CTRL_GVIO_VIDEO_FORMAT_720P_23_98_SMPTE296 = 23 NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_25_00_SMPTE274 = 24 NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_29_97_SMPTE274 = 25 NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_30_00_SMPTE274 = 26 NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_24_00_SMPTE274 = 27 NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_23_98_SMPTE274 = 28 NV_CTRL_GVIO_VIDEO_FORMAT_2048P_30_00_SMPTE372 = 29 NV_CTRL_GVIO_VIDEO_FORMAT_2048P_29_97_SMPTE372 = 30 NV_CTRL_GVIO_VIDEO_FORMAT_2048I_60_00_SMPTE372 = 31 NV_CTRL_GVIO_VIDEO_FORMAT_2048I_59_94_SMPTE372 = 32 NV_CTRL_GVIO_VIDEO_FORMAT_2048P_25_00_SMPTE372 = 33 NV_CTRL_GVIO_VIDEO_FORMAT_2048I_50_00_SMPTE372 = 34 NV_CTRL_GVIO_VIDEO_FORMAT_2048P_24_00_SMPTE372 = 35 NV_CTRL_GVIO_VIDEO_FORMAT_2048P_23_98_SMPTE372 = 36 NV_CTRL_GVIO_VIDEO_FORMAT_2048I_48_00_SMPTE372 = 37 NV_CTRL_GVIO_VIDEO_FORMAT_2048I_47_96_SMPTE372 = 38 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_50_00_3G_LEVEL_A_SMPTE274 = 39 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_59_94_3G_LEVEL_A_SMPTE274 = 40 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_60_00_3G_LEVEL_A_SMPTE274 = 41 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_60_00_3G_LEVEL_B_SMPTE274 = 42 NV_CTRL_GVIO_VIDEO_FORMAT_1080I_60_00_3G_LEVEL_B_SMPTE274 = 43 NV_CTRL_GVIO_VIDEO_FORMAT_2048I_60_00_3G_LEVEL_B_SMPTE372 = 44 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_50_00_3G_LEVEL_B_SMPTE274 = 45 NV_CTRL_GVIO_VIDEO_FORMAT_1080I_50_00_3G_LEVEL_B_SMPTE274 = 46 NV_CTRL_GVIO_VIDEO_FORMAT_2048I_50_00_3G_LEVEL_B_SMPTE372 = 47 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_30_00_3G_LEVEL_B_SMPTE274 = 48 NV_CTRL_GVIO_VIDEO_FORMAT_2048P_30_00_3G_LEVEL_B_SMPTE372 = 49 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_25_00_3G_LEVEL_B_SMPTE274 = 50 NV_CTRL_GVIO_VIDEO_FORMAT_2048P_25_00_3G_LEVEL_B_SMPTE372 = 51 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_24_00_3G_LEVEL_B_SMPTE274 = 52 NV_CTRL_GVIO_VIDEO_FORMAT_2048P_24_00_3G_LEVEL_B_SMPTE372 = 53 NV_CTRL_GVIO_VIDEO_FORMAT_1080I_48_00_3G_LEVEL_B_SMPTE274 = 54 NV_CTRL_GVIO_VIDEO_FORMAT_2048I_48_00_3G_LEVEL_B_SMPTE372 = 55 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_59_94_3G_LEVEL_B_SMPTE274 = 56 NV_CTRL_GVIO_VIDEO_FORMAT_1080I_59_94_3G_LEVEL_B_SMPTE274 = 57 NV_CTRL_GVIO_VIDEO_FORMAT_2048I_59_94_3G_LEVEL_B_SMPTE372 = 58 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_29_97_3G_LEVEL_B_SMPTE274 = 59 NV_CTRL_GVIO_VIDEO_FORMAT_2048P_29_97_3G_LEVEL_B_SMPTE372 = 60 NV_CTRL_GVIO_VIDEO_FORMAT_1080P_23_98_3G_LEVEL_B_SMPTE274 = 61 NV_CTRL_GVIO_VIDEO_FORMAT_2048P_23_98_3G_LEVEL_B_SMPTE372 = 62 NV_CTRL_GVIO_VIDEO_FORMAT_1080I_47_96_3G_LEVEL_B_SMPTE274 = 63 NV_CTRL_GVIO_VIDEO_FORMAT_2048I_47_96_3G_LEVEL_B_SMPTE372 = 64 # # The following have been renamed; NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT and the # corresponding NV_CTRL_GVIO_* formats should be used instead. # NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT = 70 # renamed NV_CTRL_GVO_VIDEO_FORMAT_NONE = 0 # renamed NV_CTRL_GVO_VIDEO_FORMAT_487I_59_94_SMPTE259_NTSC = 1 # renamed NV_CTRL_GVO_VIDEO_FORMAT_576I_50_00_SMPTE259_PAL = 2 # renamed NV_CTRL_GVO_VIDEO_FORMAT_720P_59_94_SMPTE296 = 3 # renamed NV_CTRL_GVO_VIDEO_FORMAT_720P_60_00_SMPTE296 = 4 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1035I_59_94_SMPTE260 = 5 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1035I_60_00_SMPTE260 = 6 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080I_50_00_SMPTE295 = 7 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080I_50_00_SMPTE274 = 8 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080I_59_94_SMPTE274 = 9 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080I_60_00_SMPTE274 = 10 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080P_23_976_SMPTE274 = 11 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080P_24_00_SMPTE274 = 12 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080P_25_00_SMPTE274 = 13 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080P_29_97_SMPTE274 = 14 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080P_30_00_SMPTE274 = 15 # renamed NV_CTRL_GVO_VIDEO_FORMAT_720P_50_00_SMPTE296 = 16 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080I_48_00_SMPTE274 = 17 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080I_47_96_SMPTE274 = 18 # renamed NV_CTRL_GVO_VIDEO_FORMAT_720P_30_00_SMPTE296 = 19 # renamed NV_CTRL_GVO_VIDEO_FORMAT_720P_29_97_SMPTE296 = 20 # renamed NV_CTRL_GVO_VIDEO_FORMAT_720P_25_00_SMPTE296 = 21 # renamed NV_CTRL_GVO_VIDEO_FORMAT_720P_24_00_SMPTE296 = 22 # renamed NV_CTRL_GVO_VIDEO_FORMAT_720P_23_98_SMPTE296 = 23 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_25_00_SMPTE274 = 24 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_29_97_SMPTE274 = 25 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_30_00_SMPTE274 = 26 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_24_00_SMPTE274 = 27 # renamed NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_23_98_SMPTE274 = 28 # renamed NV_CTRL_GVO_VIDEO_FORMAT_2048P_30_00_SMPTE372 = 29 # renamed NV_CTRL_GVO_VIDEO_FORMAT_2048P_29_97_SMPTE372 = 30 # renamed NV_CTRL_GVO_VIDEO_FORMAT_2048I_60_00_SMPTE372 = 31 # renamed NV_CTRL_GVO_VIDEO_FORMAT_2048I_59_94_SMPTE372 = 32 # renamed NV_CTRL_GVO_VIDEO_FORMAT_2048P_25_00_SMPTE372 = 33 # renamed NV_CTRL_GVO_VIDEO_FORMAT_2048I_50_00_SMPTE372 = 34 # renamed NV_CTRL_GVO_VIDEO_FORMAT_2048P_24_00_SMPTE372 = 35 # renamed NV_CTRL_GVO_VIDEO_FORMAT_2048P_23_98_SMPTE372 = 36 # renamed NV_CTRL_GVO_VIDEO_FORMAT_2048I_48_00_SMPTE372 = 37 # renamed NV_CTRL_GVO_VIDEO_FORMAT_2048I_47_96_SMPTE372 = 38 # renamed # # NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT - indicates the input video format # detected for GVO or GVI devices; the possible values are the # NV_CTRL_GVIO_VIDEO_FORMAT constants. # # For GVI devices, the jack number should be specified in the lower # 16 bits of the "display_mask" parameter, while the channel number should be # specified in the upper 16 bits. # NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT = 71 # R--I # # NV_CTRL_GVO_INPUT_VIDEO_FORMAT - renamed # # NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT should be used instead. # NV_CTRL_GVO_INPUT_VIDEO_FORMAT = 71 # renamed # # NV_CTRL_GVO_DATA_FORMAT - This controls how the data in the source # (either the X screen or the GLX pbuffer) is interpretted and # displayed. # # Note: some of the below DATA_FORMATS have been renamed. For # example, R8G8B8_TO_RGB444 has been renamed to X8X8X8_444_PASSTHRU. # This is to more accurately reflect DATA_FORMATS where the # per-channel data could be either RGB or YCrCb -- the point is that # the driver and GVO hardware do not perform any implicit color space # conversion on the data; it is passed through to the SDI out. # NV_CTRL_GVO_DATA_FORMAT = 72 # RW- NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_YCRCB444 = 0 NV_CTRL_GVO_DATA_FORMAT_R8G8B8A8_TO_YCRCBA4444 = 1 NV_CTRL_GVO_DATA_FORMAT_R8G8B8Z10_TO_YCRCBZ4444 = 2 NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_YCRCB422 = 3 NV_CTRL_GVO_DATA_FORMAT_R8G8B8A8_TO_YCRCBA4224 = 4 NV_CTRL_GVO_DATA_FORMAT_R8G8B8Z10_TO_YCRCBZ4224 = 5 NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_RGB444 = 6 # renamed NV_CTRL_GVO_DATA_FORMAT_X8X8X8_444_PASSTHRU = 6 NV_CTRL_GVO_DATA_FORMAT_R8G8B8A8_TO_RGBA4444 = 7 # renamed NV_CTRL_GVO_DATA_FORMAT_X8X8X8A8_4444_PASSTHRU = 7 NV_CTRL_GVO_DATA_FORMAT_R8G8B8Z10_TO_RGBZ4444 = 8 # renamed NV_CTRL_GVO_DATA_FORMAT_X8X8X8Z8_4444_PASSTHRU = 8 NV_CTRL_GVO_DATA_FORMAT_Y10CR10CB10_TO_YCRCB444 = 9 # renamed NV_CTRL_GVO_DATA_FORMAT_X10X10X10_444_PASSTHRU = 9 NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8_TO_YCRCB444 = 10 # renamed NV_CTRL_GVO_DATA_FORMAT_X10X8X8_444_PASSTHRU = 10 NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8A10_TO_YCRCBA4444 = 11 # renamed NV_CTRL_GVO_DATA_FORMAT_X10X8X8A10_4444_PASSTHRU = 11 NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8Z10_TO_YCRCBZ4444 = 12 # renamed NV_CTRL_GVO_DATA_FORMAT_X10X8X8Z10_4444_PASSTHRU = 12 NV_CTRL_GVO_DATA_FORMAT_DUAL_R8G8B8_TO_DUAL_YCRCB422 = 13 NV_CTRL_GVO_DATA_FORMAT_DUAL_Y8CR8CB8_TO_DUAL_YCRCB422 = 14 # renamed NV_CTRL_GVO_DATA_FORMAT_DUAL_X8X8X8_TO_DUAL_422_PASSTHRU = 14 NV_CTRL_GVO_DATA_FORMAT_R10G10B10_TO_YCRCB422 = 15 NV_CTRL_GVO_DATA_FORMAT_R10G10B10_TO_YCRCB444 = 16 NV_CTRL_GVO_DATA_FORMAT_Y12CR12CB12_TO_YCRCB444 = 17 # renamed NV_CTRL_GVO_DATA_FORMAT_X12X12X12_444_PASSTHRU = 17 NV_CTRL_GVO_DATA_FORMAT_R12G12B12_TO_YCRCB444 = 18 NV_CTRL_GVO_DATA_FORMAT_X8X8X8_422_PASSTHRU = 19 NV_CTRL_GVO_DATA_FORMAT_X8X8X8A8_4224_PASSTHRU = 20 NV_CTRL_GVO_DATA_FORMAT_X8X8X8Z8_4224_PASSTHRU = 21 NV_CTRL_GVO_DATA_FORMAT_X10X10X10_422_PASSTHRU = 22 NV_CTRL_GVO_DATA_FORMAT_X10X8X8_422_PASSTHRU = 23 NV_CTRL_GVO_DATA_FORMAT_X10X8X8A10_4224_PASSTHRU = 24 NV_CTRL_GVO_DATA_FORMAT_X10X8X8Z10_4224_PASSTHRU = 25 NV_CTRL_GVO_DATA_FORMAT_X12X12X12_422_PASSTHRU = 26 NV_CTRL_GVO_DATA_FORMAT_R12G12B12_TO_YCRCB422 = 27 # # NV_CTRL_GVO_DISPLAY_X_SCREEN - not supported # NV_CTRL_GVO_DISPLAY_X_SCREEN = 73 # not supported NV_CTRL_GVO_DISPLAY_X_SCREEN_ENABLE = 1 # not supported NV_CTRL_GVO_DISPLAY_X_SCREEN_DISABLE = 0 # not supported # # NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED - indicates whether # Composite Sync input is detected. # NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED = 74 # R-- NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED_FALSE = 0 NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED_TRUE = 1 # # NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE - get/set the # Composite Sync input detect mode. # NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE = 75 # RW- NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE_AUTO = 0 NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE_BI_LEVEL = 1 NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE_TRI_LEVEL = 2 # # NV_CTRL_GVO_SYNC_INPUT_DETECTED - indicates whether SDI Sync input # is detected, and what type. # NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED = 76 # R-- NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_NONE = 0 NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_HD = 1 NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_SD = 2 # # NV_CTRL_GVO_VIDEO_OUTPUTS - indicates which GVO video output # connectors are currently outputing data. # NV_CTRL_GVO_VIDEO_OUTPUTS = 77 # R-- NV_CTRL_GVO_VIDEO_OUTPUTS_NONE = 0 NV_CTRL_GVO_VIDEO_OUTPUTS_VIDEO1 = 1 NV_CTRL_GVO_VIDEO_OUTPUTS_VIDEO2 = 2 NV_CTRL_GVO_VIDEO_OUTPUTS_VIDEO_BOTH = 3 # # NV_CTRL_GVO_FIRMWARE_VERSION - deprecated # # NV_CTRL_STRING_GVIO_FIRMWARE_VERSION should be used instead. # NV_CTRL_GVO_FIRMWARE_VERSION = 78 # deprecated # # NV_CTRL_GVO_SYNC_DELAY_PIXELS - controls the delay between the # input sync and the output sync in numbers of pixels from hsync; # this is a 12 bit value. # # If the NV_CTRL_GVO_CAPABILITIES_ADVANCE_SYNC_SKEW bit is set, # then setting this value will set an advance instead of a delay. # NV_CTRL_GVO_SYNC_DELAY_PIXELS = 79 # RW- # # NV_CTRL_GVO_SYNC_DELAY_LINES - controls the delay between the input # sync and the output sync in numbers of lines from vsync; this is a # 12 bit value. # # If the NV_CTRL_GVO_CAPABILITIES_ADVANCE_SYNC_SKEW bit is set, # then setting this value will set an advance instead of a delay. # NV_CTRL_GVO_SYNC_DELAY_LINES = 80 # RW- # # NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE - must be set for a period # of about 2 seconds for the new InputVideoFormat to be properly # locked to. In nvidia-settings, we do a reacquire whenever genlock # or frame lock mode is entered into, when the user clicks the # "detect" button. This value can be written, but always reads back # _FALSE. # NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE = 81 # -W- NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE_FALSE = 0 NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE_TRUE = 1 # # NV_CTRL_GVO_GLX_LOCKED - deprecated # # NV_CTRL_GVO_LOCK_OWNER should be used instead. # NV_CTRL_GVO_GLX_LOCKED = 82 # deprecated NV_CTRL_GVO_GLX_LOCKED_FALSE = 0 # deprecated NV_CTRL_GVO_GLX_LOCKED_TRUE = 1 # deprecated # # NV_CTRL_GVIO_VIDEO_FORMAT_{WIDTH,HEIGHT,REFRESH_RATE} - query the # width, height, and refresh rate for the specified # NV_CTRL_GVIO_VIDEO_FORMAT_*. So that this can be queried with # existing interfaces, XNVCTRLQueryAttribute() should be used, and # the video format specified in the display_mask field; eg: # # XNVCTRLQueryAttribute (dpy, # screen, # NV_CTRL_GVIO_VIDEO_FORMAT_487I_59_94_SMPTE259_NTSC, # NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH, # &value); # # Note that Refresh Rate is in milliHertz values # NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH = 83 # R--I NV_CTRL_GVIO_VIDEO_FORMAT_HEIGHT = 84 # R--I NV_CTRL_GVIO_VIDEO_FORMAT_REFRESH_RATE = 85 # R--I # The following have been renamed; use the NV_CTRL_GVIO_* versions, instead NV_CTRL_GVO_VIDEO_FORMAT_WIDTH = 83 # renamed NV_CTRL_GVO_VIDEO_FORMAT_HEIGHT = 84 # renamed NV_CTRL_GVO_VIDEO_FORMAT_REFRESH_RATE = 85 # renamed # # NV_CTRL_GVO_X_SCREEN_PAN_[XY] - not supported # NV_CTRL_GVO_X_SCREEN_PAN_X = 86 # not supported NV_CTRL_GVO_X_SCREEN_PAN_Y = 87 # not supported # # NV_CTRL_GPU_OVERCLOCKING_STATE - not supported # NV_CTRL_GPU_OVERCLOCKING_STATE = 88 # not supported NV_CTRL_GPU_OVERCLOCKING_STATE_NONE = 0 # not supported NV_CTRL_GPU_OVERCLOCKING_STATE_MANUAL = 1 # not supported # # NV_CTRL_GPU_{2,3}D_CLOCK_FREQS - not supported # NV_CTRL_GPU_2D_CLOCK_FREQS = 89 # not supported NV_CTRL_GPU_3D_CLOCK_FREQS = 90 # not supported # # NV_CTRL_GPU_DEFAULT_{2,3}D_CLOCK_FREQS - not supported # NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS = 91 # not supported NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS = 92 # not supported # # NV_CTRL_GPU_CURRENT_CLOCK_FREQS - query the current GPU and memory # clocks of the graphics device driving the X screen. # # NV_CTRL_GPU_CURRENT_CLOCK_FREQS is a "packed" integer attribute; # the GPU clock is stored in the upper 16 bits of the integer, and # the memory clock is stored in the lower 16 bits of the integer. # All clock values are in MHz. All clock values are in MHz. # NV_CTRL_GPU_CURRENT_CLOCK_FREQS = 93 # R--G # # NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS - not supported # NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS = 94 # not supported NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_INVALID = 0 # not supported # # NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION - not supported # NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION = 95 # not supported NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_START = 0 # not supported NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_CANCEL = 1 # not supported # # NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE - not supported # NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE = 96 # not supported NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_IDLE = 0 # not supported NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_BUSY = 1 # not supported # # NV_CTRL_FLATPANEL_CHIP_LOCATION - for the specified display device, # report whether the flat panel is driven by the on-chip controller, # or a separate controller chip elsewhere on the graphics board. # This attribute is only available for flat panels. # NV_CTRL_FLATPANEL_CHIP_LOCATION = 215 # R-DG NV_CTRL_FLATPANEL_CHIP_LOCATION_INTERNAL = 0 NV_CTRL_FLATPANEL_CHIP_LOCATION_EXTERNAL = 1 # # NV_CTRL_FLATPANEL_LINK - report the number of links for a DVI connection, or # the main link's active lane count for DisplayPort. # This attribute is only available for flat panels. # NV_CTRL_FLATPANEL_LINK = 216 # R-DG NV_CTRL_FLATPANEL_LINK_SINGLE = 0 NV_CTRL_FLATPANEL_LINK_DUAL = 1 NV_CTRL_FLATPANEL_LINK_QUAD = 3 # # NV_CTRL_FLATPANEL_SIGNAL - for the specified display device, report # whether the flat panel is driven by an LVDS, TMDS, or DisplayPort signal. # This attribute is only available for flat panels. # NV_CTRL_FLATPANEL_SIGNAL = 217 # R-DG NV_CTRL_FLATPANEL_SIGNAL_LVDS = 0 NV_CTRL_FLATPANEL_SIGNAL_TMDS = 1 NV_CTRL_FLATPANEL_SIGNAL_DISPLAYPORT = 2 # # NV_CTRL_USE_HOUSE_SYNC - when INPUT, the server (master) frame lock # device will propagate the incoming house sync signal as the outgoing # frame lock sync signal. If the frame lock device cannot detect a # frame lock sync signal, it will default to using the internal timings # from the GPU connected to the primary connector. # # When set to OUTPUT, the server (master) frame lock device will # generate a house sync signal from its internal timing and output # this signal over the BNC connector on the frame lock device. This # is only allowed on a Quadro Sync II device. If an incoming house # sync signal is present on the BNC connector, this setting will # have no effect. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_USE_HOUSE_SYNC = 218 # RW-F NV_CTRL_USE_HOUSE_SYNC_DISABLED = 0 # aliases with FALSE NV_CTRL_USE_HOUSE_SYNC_INPUT = 1 # aliases with TRUE NV_CTRL_USE_HOUSE_SYNC_OUTPUT = 2 NV_CTRL_USE_HOUSE_SYNC_FALSE = 0 NV_CTRL_USE_HOUSE_SYNC_TRUE = 1 # # NV_CTRL_EDID_AVAILABLE - report if an EDID is available for the # specified display device. # # This attribute may also be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_EDID_AVAILABLE = 219 # R-DG NV_CTRL_EDID_AVAILABLE_FALSE = 0 NV_CTRL_EDID_AVAILABLE_TRUE = 1 # # NV_CTRL_FORCE_STEREO - when TRUE, OpenGL will force stereo flipping # even when no stereo drawables are visible (if the device is configured # to support it, see the "Stereo" X config option). # When false, fall back to the default behavior of only flipping when a # stereo drawable is visible. # NV_CTRL_FORCE_STEREO = 220 # RW- NV_CTRL_FORCE_STEREO_FALSE = 0 NV_CTRL_FORCE_STEREO_TRUE = 1 # # NV_CTRL_IMAGE_SETTINGS - the image quality setting for OpenGL clients. # # This setting is only applied to OpenGL clients that are started # after this setting is applied. # NV_CTRL_IMAGE_SETTINGS = 221 # RW-X NV_CTRL_IMAGE_SETTINGS_HIGH_QUALITY = 0 NV_CTRL_IMAGE_SETTINGS_QUALITY = 1 NV_CTRL_IMAGE_SETTINGS_PERFORMANCE = 2 NV_CTRL_IMAGE_SETTINGS_HIGH_PERFORMANCE = 3 # # NV_CTRL_XINERAMA - return whether xinerama is enabled # NV_CTRL_XINERAMA = 222 # R--G NV_CTRL_XINERAMA_OFF = 0 NV_CTRL_XINERAMA_ON = 1 # # NV_CTRL_XINERAMA_STEREO - when TRUE, OpenGL will allow stereo flipping # on multiple X screens configured with Xinerama. # When FALSE, flipping is allowed only on one X screen at a time. # NV_CTRL_XINERAMA_STEREO = 223 # RW- NV_CTRL_XINERAMA_STEREO_FALSE = 0 NV_CTRL_XINERAMA_STEREO_TRUE = 1 # # NV_CTRL_BUS_RATE - if the bus type of the specified device is AGP, then # NV_CTRL_BUS_RATE returns the configured AGP transfer rate. If the bus type # is PCI Express, then this attribute returns the maximum link width. # When this attribute is queried on an X screen target, the bus rate of the # GPU driving the X screen is returned. # NV_CTRL_BUS_RATE = 224 # R--GI # # NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH - returns the maximum # PCIe link width, in number of lanes. # NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH = NV_CTRL_BUS_RATE # # NV_CTRL_SHOW_SLI_VISUAL_INDICATOR - when TRUE, OpenGL will draw information # about the current SLI mode. # NV_CTRL_SHOW_SLI_VISUAL_INDICATOR = 225 # RW-X NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_FALSE = 0 NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_TRUE = 1 # # NV_CTRL_SHOW_SLI_HUD - when TRUE, OpenGL will draw information about the # current SLI mode. # Renamed this attribute to NV_CTRL_SHOW_SLI_VISUAL_INDICATOR # NV_CTRL_SHOW_SLI_HUD = NV_CTRL_SHOW_SLI_VISUAL_INDICATOR NV_CTRL_SHOW_SLI_HUD_FALSE = NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_FALSE NV_CTRL_SHOW_SLI_HUD_TRUE = NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_TRUE # # NV_CTRL_XV_SYNC_TO_DISPLAY - deprecated # # NV_CTRL_XV_SYNC_TO_DISPLAY_ID should be used instead. # NV_CTRL_XV_SYNC_TO_DISPLAY = 226 # deprecated # # NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 - this attribute is only # intended to be used to query the ValidValues for # NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT for VIDEO_FORMAT values between # 31 and 63. See NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT for details. # NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 = 227 # ---GI # # NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT2 - renamed # # NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 should be used instead. # NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT2 = 227 # renamed # # NV_CTRL_GVO_OVERRIDE_HW_CSC - Override the SDI hardware's Color Space # Conversion with the values controlled through # XNVCTRLSetGvoColorConversion() and XNVCTRLGetGvoColorConversion(). If # this attribute is FALSE, then the values specified through # XNVCTRLSetGvoColorConversion() are ignored. # NV_CTRL_GVO_OVERRIDE_HW_CSC = 228 # RW- NV_CTRL_GVO_OVERRIDE_HW_CSC_FALSE = 0 NV_CTRL_GVO_OVERRIDE_HW_CSC_TRUE = 1 # # NV_CTRL_GVO_CAPABILITIES - this read-only attribute describes GVO # capabilities that differ between NVIDIA SDI products. This value # is a bitmask where each bit indicates whether that capability is # available. # # APPLY_CSC_IMMEDIATELY - whether the CSC matrix, offset, and scale # specified through XNVCTRLSetGvoColorConversion() will take affect # immediately, or only after SDI output is disabled and enabled # again. # # APPLY_CSC_TO_X_SCREEN - whether the CSC matrix, offset, and scale # specified through XNVCTRLSetGvoColorConversion() will also apply # to GVO output of an X screen, or only to OpenGL GVO output, as # enabled through the GLX_NV_video_out extension. # # COMPOSITE_TERMINATION - whether the 75 ohm termination of the # SDI composite input signal can be programmed through the # NV_CTRL_GVO_COMPOSITE_TERMINATION attribute. # # SHARED_SYNC_BNC - whether the SDI device has a single BNC # connector used for both (SDI & Composite) incoming signals. # # MULTIRATE_SYNC - whether the SDI device supports synchronization # of input and output video modes that match in being odd or even # modes (ie, AA.00 Hz modes can be synched to other BB.00 Hz modes and # AA.XX Hz can match to BB.YY Hz where .XX and .YY are not .00) # NV_CTRL_GVO_CAPABILITIES = 229 # R-- NV_CTRL_GVO_CAPABILITIES_APPLY_CSC_IMMEDIATELY = 0x00000001 NV_CTRL_GVO_CAPABILITIES_APPLY_CSC_TO_X_SCREEN = 0x00000002 NV_CTRL_GVO_CAPABILITIES_COMPOSITE_TERMINATION = 0x00000004 NV_CTRL_GVO_CAPABILITIES_SHARED_SYNC_BNC = 0x00000008 NV_CTRL_GVO_CAPABILITIES_MULTIRATE_SYNC = 0x00000010 NV_CTRL_GVO_CAPABILITIES_ADVANCE_SYNC_SKEW = 0x00000020 # # NV_CTRL_GVO_COMPOSITE_TERMINATION - enable or disable 75 ohm # termination of the SDI composite input signal. # NV_CTRL_GVO_COMPOSITE_TERMINATION = 230 # RW- NV_CTRL_GVO_COMPOSITE_TERMINATION_ENABLE = 1 NV_CTRL_GVO_COMPOSITE_TERMINATION_DISABLE = 0 # # NV_CTRL_ASSOCIATED_DISPLAY_DEVICES - deprecated # # NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN should be used instead. # NV_CTRL_ASSOCIATED_DISPLAY_DEVICES = 231 # deprecated # # NV_CTRL_FRAMELOCK_SLAVES - deprecated # # NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead. # NV_CTRL_FRAMELOCK_SLAVES = 232 # deprecated # # NV_CTRL_FRAMELOCK_MASTERABLE - deprecated # # NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead. # NV_CTRL_FRAMELOCK_MASTERABLE = 233 # deprecated # # NV_CTRL_PROBE_DISPLAYS - re-probes the hardware to detect what # display devices are connected to the GPU or GPU driving the # specified X screen. The return value is deprecated and should not be used. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_PROBE_DISPLAYS = 234 # R--G # # NV_CTRL_REFRESH_RATE - Returns the refresh rate of the specified # display device in 100# Hz (ie. to get the refresh rate in Hz, divide # the returned value by 100.) # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_REFRESH_RATE = 235 # R-DG # # NV_CTRL_GVO_FLIP_QUEUE_SIZE - The Graphics to Video Out interface # exposed through NV-CONTROL and the GLX_NV_video_out extension uses # an internal flip queue when pbuffers are sent to the video device # (via glXSendPbufferToVideoNV()). The NV_CTRL_GVO_FLIP_QUEUE_SIZE # can be used to query and assign the flip queue size. This # attribute is applied to GLX when glXGetVideoDeviceNV() is called by # the application. # NV_CTRL_GVO_FLIP_QUEUE_SIZE = 236 # RW- # # NV_CTRL_CURRENT_SCANLINE - query the current scanline for the # specified display device. # NV_CTRL_CURRENT_SCANLINE = 237 # R-DG # # NV_CTRL_INITIAL_PIXMAP_PLACEMENT - Controls where X pixmaps are initially # created. # # NV_CTRL_INITIAL_PIXMAP_PLACEMENT_FORCE_SYSMEM causes pixmaps to stay in # system memory. These pixmaps can't be accelerated by the NVIDIA driver; this # will cause blank windows if used with an OpenGL compositing manager. # NV_CTRL_INITIAL_PIXMAP_PLACEMENT_SYSMEM creates pixmaps in system memory # initially, but allows them to migrate to video memory. # NV_CTRL_INITIAL_PIXMAP_PLACEMENT_VIDMEM creates pixmaps in video memory # when enough resources are available. # NV_CTRL_INITIAL_PIXMAP_PLACEMENT_RESERVED is currently reserved for future # use. Behavior is undefined. # NV_CTRL_INITIAL_PIXMAP_PLACEMENT_GPU_SYSMEM creates pixmaps in GPU accessible # system memory when enough resources are available. # NV_CTRL_INITIAL_PIXMAP_PLACEMENT = 238 # RW- NV_CTRL_INITIAL_PIXMAP_PLACEMENT_FORCE_SYSMEM = 0 NV_CTRL_INITIAL_PIXMAP_PLACEMENT_SYSMEM = 1 NV_CTRL_INITIAL_PIXMAP_PLACEMENT_VIDMEM = 2 NV_CTRL_INITIAL_PIXMAP_PLACEMENT_RESERVED = 3 NV_CTRL_INITIAL_PIXMAP_PLACEMENT_GPU_SYSMEM = 4 # # NV_CTRL_PCI_BUS - Returns the PCI bus number the specified device is using. # NV_CTRL_PCI_BUS = 239 # R--GI # # NV_CTRL_PCI_DEVICE - Returns the PCI device number the specified device is # using. # NV_CTRL_PCI_DEVICE = 240 # R--GI # # NV_CTRL_PCI_FUNCTION - Returns the PCI function number the specified device # is using. # NV_CTRL_PCI_FUNCTION = 241 # R--GI # # NV_CTRL_FRAMELOCK_FPGA_REVISION - Queries the FPGA revision of the # Frame Lock device. # # This attribute must be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK target. # NV_CTRL_FRAMELOCK_FPGA_REVISION = 242 # R--F # # NV_CTRL_MAX_SCREEN_{WIDTH,HEIGHT} - the maximum allowable size, in # pixels, of either the specified X screen (if the target_type of the # query is an X screen), or any X screen on the specified GPU (if the # target_type of the query is a GPU). # NV_CTRL_MAX_SCREEN_WIDTH = 243 # R--G NV_CTRL_MAX_SCREEN_HEIGHT = 244 # R--G # # NV_CTRL_MAX_DISPLAYS - The maximum number of display devices that # can be driven simultaneously on a GPU (e.g., that can be used in a # MetaMode at once). Note that this does not indicate the maximum # number of displays that are listed in NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU # and NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU because more display # devices can be connected than are actively in use. # NV_CTRL_MAX_DISPLAYS = 245 # R--G # # NV_CTRL_DYNAMIC_TWINVIEW - Returns whether or not the screen # supports dynamic twinview. # NV_CTRL_DYNAMIC_TWINVIEW = 246 # R-- # # NV_CTRL_MULTIGPU_DISPLAY_OWNER - Returns the (NV-CONTROL) GPU ID of # the GPU that has the display device(s) used for showing the X Screen. # NV_CTRL_MULTIGPU_DISPLAY_OWNER = 247 # R-- # # NV_CTRL_GPU_SCALING - not supported # NV_CTRL_GPU_SCALING = 248 # not supported NV_CTRL_GPU_SCALING_TARGET_INVALID = 0 # not supported NV_CTRL_GPU_SCALING_TARGET_FLATPANEL_BEST_FIT = 1 # not supported NV_CTRL_GPU_SCALING_TARGET_FLATPANEL_NATIVE = 2 # not supported NV_CTRL_GPU_SCALING_METHOD_INVALID = 0 # not supported NV_CTRL_GPU_SCALING_METHOD_STRETCHED = 1 # not supported NV_CTRL_GPU_SCALING_METHOD_CENTERED = 2 # not supported NV_CTRL_GPU_SCALING_METHOD_ASPECT_SCALED = 3 # not supported # # NV_CTRL_FRONTEND_RESOLUTION - not supported # NV_CTRL_FRONTEND_RESOLUTION = 249 # not supported # # NV_CTRL_BACKEND_RESOLUTION - not supported # NV_CTRL_BACKEND_RESOLUTION = 250 # not supported # # NV_CTRL_FLATPANEL_NATIVE_RESOLUTION - not supported # NV_CTRL_FLATPANEL_NATIVE_RESOLUTION = 251 # not supported # # NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION - not supported # NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION = 252 # not supported # # NV_CTRL_GPU_SCALING_ACTIVE - not supported # NV_CTRL_GPU_SCALING_ACTIVE = 253 # not supported # # NV_CTRL_DFP_SCALING_ACTIVE - not supported # NV_CTRL_DFP_SCALING_ACTIVE = 254 # not supported # # NV_CTRL_FSAA_APPLICATION_ENHANCED - Controls how the NV_CTRL_FSAA_MODE # is applied when NV_CTRL_FSAA_APPLICATION_CONTROLLED is set to # NV_CTRL_APPLICATION_CONTROLLED_DISABLED. When # NV_CTRL_FSAA_APPLICATION_ENHANCED is _DISABLED, OpenGL applications will # be forced to use the FSAA mode specified by NV_CTRL_FSAA_MODE. when set # to _ENABLED, only those applications that have selected a multisample # FBConfig will be made to use the NV_CTRL_FSAA_MODE specified. # # This attribute is ignored when NV_CTRL_FSAA_APPLICATION_CONTROLLED is # set to NV_CTRL_FSAA_APPLICATION_CONTROLLED_ENABLED. # NV_CTRL_FSAA_APPLICATION_ENHANCED = 255 # RW-X NV_CTRL_FSAA_APPLICATION_ENHANCED_ENABLED = 1 NV_CTRL_FSAA_APPLICATION_ENHANCED_DISABLED = 0 # # NV_CTRL_FRAMELOCK_SYNC_RATE_4 - This is the refresh rate that the # frame lock board is sending to the GPU with 4 digits of precision. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK. # NV_CTRL_FRAMELOCK_SYNC_RATE_4 = 256 # R--F # # NV_CTRL_GVO_LOCK_OWNER - indicates that the GVO device is available # or in use (by GLX or an X screen). # # The GVO device is locked by GLX when either glXGetVideoDeviceNV # (part of GLX_NV_video_out) or glXBindVideoDeviceNV (part of # GLX_NV_present_video) is called. All GVO output resources are # locked until released by the GLX_NV_video_out/GLX_NV_present_video # client. # # The GVO device is locked/unlocked by an X screen, when the GVO device is # used in a MetaMode on an X screen. # # When the GVO device is locked, setting of the following GVO NV-CONTROL # attributes will not happen immediately and will instead be cached. The # GVO resource will need to be disabled/released and re-enabled/claimed for # the values to be flushed. These attributes are: # # NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT # NV_CTRL_GVO_DATA_FORMAT # NV_CTRL_GVO_FLIP_QUEUE_SIZE # NV_CTRL_GVO_LOCK_OWNER = 257 # R-- NV_CTRL_GVO_LOCK_OWNER_NONE = 0 NV_CTRL_GVO_LOCK_OWNER_GLX = 1 NV_CTRL_GVO_LOCK_OWNER_CLONE = 2 # not supported NV_CTRL_GVO_LOCK_OWNER_X_SCREEN = 3 # # NV_CTRL_HWOVERLAY - when a workstation overlay is in use, reports # whether the hardware overlay is used, or if the overlay is emulated. # NV_CTRL_HWOVERLAY = 258 # R-- NV_CTRL_HWOVERLAY_FALSE = 0 NV_CTRL_HWOVERLAY_TRUE = 1 # # NV_CTRL_NUM_GPU_ERRORS_RECOVERED - Returns the number of GPU errors # occured. This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_NUM_GPU_ERRORS_RECOVERED = 259 # R--- # # NV_CTRL_REFRESH_RATE_3 - Returns the refresh rate of the specified # display device in 1000# Hz (ie. to get the refresh rate in Hz, divide # the returned value by 1000.) # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_REFRESH_RATE_3 = 260 # R-DG # # NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS - not supported # NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS = 261 # not supported NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS_OFF = 0 # not supported NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS_ON = 1 # not supported # # NV_CTRL_GPU_POWER_SOURCE reports the type of power source # of the GPU driving the X screen. # NV_CTRL_GPU_POWER_SOURCE = 262 # R--G NV_CTRL_GPU_POWER_SOURCE_AC = 0 NV_CTRL_GPU_POWER_SOURCE_BATTERY = 1 # # NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE - not supported # NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE = 263 # not supported NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE_DESKTOP = 0 # not supported NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE_MAXPERF = 1 # not supported # NV_CTRL_GLYPH_CACHE - Enables RENDER Glyph Caching to VRAM NV_CTRL_GLYPH_CACHE = 264 # RW- NV_CTRL_GLYPH_CACHE_DISABLED = 0 NV_CTRL_GLYPH_CACHE_ENABLED = 1 # # NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL reports the current # Performance level of the GPU driving the X screen. Each # Performance level has associated NVClock and Mem Clock values. # NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL = 265 # R--G # # NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE reports if Adaptive Clocking # is Enabled on the GPU driving the X screen. # NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE = 266 # R--G NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE_DISABLED = 0 NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE_ENABLED = 1 # # NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED - Returns whether or not the GVO output # video is locked to the GPU. # NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED = 267 # R--- NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED_FALSE = 0 NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED_TRUE = 1 # # NV_CTRL_GVO_SYNC_LOCK_STATUS - Returns whether or not the GVO device # is locked to the input ref signal. If the sync mode is set to # NV_CTRL_GVO_SYNC_MODE_GENLOCK, then this returns the genlock # sync status, and if the sync mode is set to NV_CTRL_GVO_SYNC_MODE_FRAMELOCK, # then this reports the frame lock status. # NV_CTRL_GVO_SYNC_LOCK_STATUS = 268 # R--- NV_CTRL_GVO_SYNC_LOCK_STATUS_UNLOCKED = 0 NV_CTRL_GVO_SYNC_LOCK_STATUS_LOCKED = 1 # # NV_CTRL_GVO_ANC_TIME_CODE_GENERATION - Allows SDI device to generate # time codes in the ANC region of the SDI video output stream. # NV_CTRL_GVO_ANC_TIME_CODE_GENERATION = 269 # RW-- NV_CTRL_GVO_ANC_TIME_CODE_GENERATION_DISABLE = 0 NV_CTRL_GVO_ANC_TIME_CODE_GENERATION_ENABLE = 1 # # NV_CTRL_GVO_COMPOSITE - Enables/Disables SDI compositing. This attribute # is only available when an SDI input source is detected and is in genlock # mode. # NV_CTRL_GVO_COMPOSITE = 270 # RW-- NV_CTRL_GVO_COMPOSITE_DISABLE = 0 NV_CTRL_GVO_COMPOSITE_ENABLE = 1 # # NV_CTRL_GVO_COMPOSITE_ALPHA_KEY - When compositing is enabled, this # enables/disables alpha blending. # NV_CTRL_GVO_COMPOSITE_ALPHA_KEY = 271 # RW-- NV_CTRL_GVO_COMPOSITE_ALPHA_KEY_DISABLE = 0 NV_CTRL_GVO_COMPOSITE_ALPHA_KEY_ENABLE = 1 # # NV_CTRL_GVO_COMPOSITE_LUMA_KEY_RANGE - Set the values of a luma # channel range. This is a packed int that has the following format # (in order of high-bits to low bits): # # Range # (11 bits), (Enabled 1 bit), min value (10 bits), max value (10 bits) # # To query the current values, pass the range # throught the display_mask # variable. # NV_CTRL_GVO_COMPOSITE_LUMA_KEY_RANGE = 272 # RW-- # # NV_CTRL_GVO_COMPOSITE_CR_KEY_RANGE - Set the values of a CR # channel range. This is a packed int that has the following format # (in order of high-bits to low bits): # # Range # (11 bits), (Enabled 1 bit), min value (10 bits), max value (10 bits) # # To query the current values, pass the range # throught he display_mask # variable. # NV_CTRL_GVO_COMPOSITE_CR_KEY_RANGE = 273 # RW-- # # NV_CTRL_GVO_COMPOSITE_CB_KEY_RANGE - Set the values of a CB # channel range. This is a packed int that has the following format # (in order of high-bits to low bits): # # Range # (11 bits), (Enabled 1 bit), min value (10 bits), max value (10 bits) # # To query the current values, pass the range # throught he display_mask # variable. # NV_CTRL_GVO_COMPOSITE_CB_KEY_RANGE = 274 # RW-- # # NV_CTRL_GVO_COMPOSITE_NUM_KEY_RANGES - Returns the number of ranges # available for each channel (Y/Luma, Cr, and Cb.) # NV_CTRL_GVO_COMPOSITE_NUM_KEY_RANGES = 275 # R--- # # NV_CTRL_SWITCH_TO_DISPLAYS - not supported # NV_CTRL_SWITCH_TO_DISPLAYS = 276 # not supported # # NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT - not supported # NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT = 277 # not supported # # NV_CTRL_NOTEBOOK_INTERNAL_LCD - deprecated # NV_CTRL_NOTEBOOK_INTERNAL_LCD = 278 # deprecated # # NV_CTRL_DEPTH_30_ALLOWED - returns whether the NVIDIA X driver supports # depth 30 on the specified X screen or GPU. # NV_CTRL_DEPTH_30_ALLOWED = 279 # R--G # # NV_CTRL_MODE_SET_EVENT This attribute is sent as an event # when hotkey, ctrl-alt-+/- or randr event occurs. Note that # This attribute cannot be set or queried and is meant to # be received by clients that wish to be notified of when # mode set events occur. # NV_CTRL_MODE_SET_EVENT = 280 # --- # # NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE - the gamma value used by # OpenGL when NV_CTRL_OPENGL_AA_LINE_GAMMA is enabled # NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE = 281 # RW-X # # NV_CTRL_VCSC_HIGH_PERF_MODE - deprecated # # Is used to both query High Performance Mode status on the Visual Computing # System, and also to enable or disable High Performance Mode. # NV_CTRL_VCSC_HIGH_PERF_MODE = 282 # RW-V NV_CTRL_VCSC_HIGH_PERF_MODE_DISABLE = 0 NV_CTRL_VCSC_HIGH_PERF_MODE_ENABLE = 1 # # NV_CTRL_DISPLAYPORT_LINK_RATE - returns the negotiated lane bandwidth of the # DisplayPort main link. The numerical value of this attribute is the link # rate in bps divided by 27000000. # This attribute is only available for DisplayPort flat panels. # NV_CTRL_DISPLAYPORT_LINK_RATE = 291 # R-DG NV_CTRL_DISPLAYPORT_LINK_RATE_DISABLED = 0x0 NV_CTRL_DISPLAYPORT_LINK_RATE_1_62GBPS = 0x6 # deprecated NV_CTRL_DISPLAYPORT_LINK_RATE_2_70GBPS = 0xA # deprecated # # NV_CTRL_STEREO_EYES_EXCHANGE - Controls whether or not the left and right # eyes of a stereo image are flipped. # NV_CTRL_STEREO_EYES_EXCHANGE = 292 # RW-X NV_CTRL_STEREO_EYES_EXCHANGE_OFF = 0 NV_CTRL_STEREO_EYES_EXCHANGE_ON = 1 # # NV_CTRL_NO_SCANOUT - returns whether the special "NoScanout" mode is # enabled on the specified X screen or GPU; for details on this mode, # see the description of the "none" value for the "UseDisplayDevice" # X configuration option in the NVIDIA driver README. # NV_CTRL_NO_SCANOUT = 293 # R--G NV_CTRL_NO_SCANOUT_DISABLED = 0 NV_CTRL_NO_SCANOUT_ENABLED = 1 # # NV_CTRL_GVO_CSC_CHANGED_EVENT This attribute is sent as an event # when the color space conversion matrix has been altered by another # client. # NV_CTRL_GVO_CSC_CHANGED_EVENT = 294 # --- # # NV_CTRL_FRAMELOCK_SLAVEABLE - deprecated # # NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead. # NV_CTRL_FRAMELOCK_SLAVEABLE = 295 # deprecated # # NV_CTRL_GVO_SYNC_TO_DISPLAY This attribute controls whether or not # the non-SDI display device will be sync'ed to the SDI display device # (when configured in TwinView, Clone Mode or when using the SDI device # with OpenGL). # NV_CTRL_GVO_SYNC_TO_DISPLAY = 296 # --- NV_CTRL_GVO_SYNC_TO_DISPLAY_DISABLE = 0 NV_CTRL_GVO_SYNC_TO_DISPLAY_ENABLE = 1 # # NV_CTRL_X_SERVER_UNIQUE_ID - returns a pseudo-unique identifier for this # X server. Intended for use in cases where an NV-CONTROL client communicates # with multiple X servers, and wants some level of confidence that two # X Display connections correspond to the same or different X servers. # NV_CTRL_X_SERVER_UNIQUE_ID = 297 # R--- # # NV_CTRL_PIXMAP_CACHE - This attribute controls whether the driver attempts to # store video memory pixmaps in a cache. The cache speeds up allocation and # deallocation of pixmaps, but could use more memory than when the cache is # disabled. # NV_CTRL_PIXMAP_CACHE = 298 # RW-X NV_CTRL_PIXMAP_CACHE_DISABLE = 0 NV_CTRL_PIXMAP_CACHE_ENABLE = 1 # # NV_CTRL_PIXMAP_CACHE_ROUNDING_SIZE_KB - When the pixmap cache is enabled and # there is not enough free space in the cache to fit a new pixmap, the driver # will round up to the next multiple of this number of kilobytes when # allocating more memory for the cache. # NV_CTRL_PIXMAP_CACHE_ROUNDING_SIZE_KB = 299 # RW-X # # NV_CTRL_IS_GVO_DISPLAY - returns whether or not a given display is an # SDI device. # NV_CTRL_IS_GVO_DISPLAY = 300 # R-D NV_CTRL_IS_GVO_DISPLAY_FALSE = 0 NV_CTRL_IS_GVO_DISPLAY_TRUE = 1 # # NV_CTRL_PCI_ID - Returns the PCI vendor and device ID of the specified # device. # # NV_CTRL_PCI_ID is a "packed" integer attribute; the PCI vendor ID is stored # in the upper 16 bits of the integer, and the PCI device ID is stored in the # lower 16 bits of the integer. # NV_CTRL_PCI_ID = 301 # R--GI # # NV_CTRL_GVO_FULL_RANGE_COLOR - Allow full range color data [4-1019] # without clamping to [64-940]. # NV_CTRL_GVO_FULL_RANGE_COLOR = 302 # RW- NV_CTRL_GVO_FULL_RANGE_COLOR_DISABLED = 0 NV_CTRL_GVO_FULL_RANGE_COLOR_ENABLED = 1 # # NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE - Returns whether or not # SLI Mosaic Mode supported. # NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE = 303 # R-- NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE_FALSE = 0 NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE_TRUE = 1 # # NV_CTRL_GVO_ENABLE_RGB_DATA - Allows clients to specify when # the GVO board should process colors as RGB when the output data # format is one of the NV_CTRL_GVO_DATA_FORMAT_???_PASSTRHU modes. # NV_CTRL_GVO_ENABLE_RGB_DATA = 304 # RW- NV_CTRL_GVO_ENABLE_RGB_DATA_DISABLE = 0 NV_CTRL_GVO_ENABLE_RGB_DATA_ENABLE = 1 # # NV_CTRL_IMAGE_SHARPENING_DEFAULT - Returns default value of # Image Sharpening. # NV_CTRL_IMAGE_SHARPENING_DEFAULT = 305 # R-- # # NV_CTRL_PCI_DOMAIN - Returns the PCI domain number the specified device is # using. # NV_CTRL_PCI_DOMAIN = 306 # R--GI # # NV_CTRL_GVI_NUM_JACKS - Returns the number of input BNC jacks available # on a GVI device. # NV_CTRL_GVI_NUM_JACKS = 307 # R--I # # NV_CTRL_GVI_MAX_LINKS_PER_STREAM - Returns the maximum supported number of # links that can be tied to one stream. # NV_CTRL_GVI_MAX_LINKS_PER_STREAM = 308 # R--I # # NV_CTRL_GVI_DETECTED_CHANNEL_BITS_PER_COMPONENT - Returns the detected # number of bits per component (BPC) of data on the given input jack+ # channel. # # The jack number should be specified in the lower 16 bits of the # "display_mask" parameter, while the channel number should be specified in # the upper 16 bits. # NV_CTRL_GVI_DETECTED_CHANNEL_BITS_PER_COMPONENT = 309 # R--I NV_CTRL_GVI_BITS_PER_COMPONENT_UNKNOWN = 0 NV_CTRL_GVI_BITS_PER_COMPONENT_8 = 1 NV_CTRL_GVI_BITS_PER_COMPONENT_10 = 2 NV_CTRL_GVI_BITS_PER_COMPONENT_12 = 3 # # NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT - Specify the number of # bits per component (BPC) of data for the captured stream. # The stream number should be specified in the "display_mask" parameter. # # Note: Setting this attribute may also result in the following # NV-CONTROL attributes being reset on the GVI device (to ensure # the configuration remains valid): # NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING # NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT = 310 # RW-I # # NV_CTRL_GVI_DETECTED_CHANNEL_COMPONENT_SAMPLING - Returns the detected # sampling format for the input jack+channel. # # The jack number should be specified in the lower 16 bits of the # "display_mask" parameter, while the channel number should be specified in # the upper 16 bits. # NV_CTRL_GVI_DETECTED_CHANNEL_COMPONENT_SAMPLING = 311 # R--I NV_CTRL_GVI_COMPONENT_SAMPLING_UNKNOWN = 0 NV_CTRL_GVI_COMPONENT_SAMPLING_4444 = 1 NV_CTRL_GVI_COMPONENT_SAMPLING_4224 = 2 NV_CTRL_GVI_COMPONENT_SAMPLING_444 = 3 NV_CTRL_GVI_COMPONENT_SAMPLING_422 = 4 NV_CTRL_GVI_COMPONENT_SAMPLING_420 = 5 # # NV_CTRL_GVI_REQUESTED_COMPONENT_SAMPLING - Specify the sampling format for # the captured stream. # The possible values are the NV_CTRL_GVI_DETECTED_COMPONENT_SAMPLING # constants. # The stream number should be specified in the "display_mask" parameter. # NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING = 312 # RW-I # # NV_CTRL_GVI_CHROMA_EXPAND - Enable or disable 4:2:2 -> 4:4:4 chroma # expansion for the captured stream. This value is ignored when a # COMPONENT_SAMPLING format is selected that does not use chroma subsampling, # or if a BITS_PER_COMPONENT value is selected that is not supported. # The stream number should be specified in the "display_mask" parameter. # NV_CTRL_GVI_REQUESTED_STREAM_CHROMA_EXPAND = 313 # RW-I NV_CTRL_GVI_CHROMA_EXPAND_FALSE = 0 NV_CTRL_GVI_CHROMA_EXPAND_TRUE = 1 # # NV_CTRL_GVI_DETECTED_CHANNEL_COLOR_SPACE - Returns the detected color space # of the input jack+channel. # # The jack number should be specified in the lower 16 bits of the # "display_mask" parameter, while the channel number should be specified in # the upper 16 bits. # NV_CTRL_GVI_DETECTED_CHANNEL_COLOR_SPACE = 314 # R--I NV_CTRL_GVI_COLOR_SPACE_UNKNOWN = 0 NV_CTRL_GVI_COLOR_SPACE_GBR = 1 NV_CTRL_GVI_COLOR_SPACE_GBRA = 2 NV_CTRL_GVI_COLOR_SPACE_GBRD = 3 NV_CTRL_GVI_COLOR_SPACE_YCBCR = 4 NV_CTRL_GVI_COLOR_SPACE_YCBCRA = 5 NV_CTRL_GVI_COLOR_SPACE_YCBCRD = 6 # # NV_CTRL_GVI_DETECTED_CHANNEL_LINK_ID - Returns the detected link identifier # for the given input jack+channel. # # The jack number should be specified in the lower 16 bits of the # "display_mask" parameter, while the channel number should be specified in # the upper 16 bits. # NV_CTRL_GVI_DETECTED_CHANNEL_LINK_ID = 315 # R--I NV_CTRL_GVI_LINK_ID_UNKNOWN = 0xFFFF # # NV_CTRL_GVI_DETECTED_CHANNEL_SMPTE352_IDENTIFIER - Returns the 4-byte # SMPTE 352 identifier from the given input jack+channel. # # The jack number should be specified in the lower 16 bits of the # "display_mask" parameter, while the channel number should be specified in # the upper 16 bits. # NV_CTRL_GVI_DETECTED_CHANNEL_SMPTE352_IDENTIFIER = 316 # R--I # # NV_CTRL_GVI_GLOBAL_IDENTIFIER - Returns a global identifier for the # GVI device. This identifier can be used to relate GVI devices named # in NV-CONTROL with those enumerated in OpenGL. # NV_CTRL_GVI_GLOBAL_IDENTIFIER = 317 # R--I # # NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION - Returns the number of nanoseconds # that one unit of NV_CTRL_FRAMELOCK_SYNC_DELAY corresponds to. # NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION = 318 # R-- # # NV_CTRL_GPU_COOLER_MANUAL_CONTROL - Query the current or set a new # cooler control state; the value of this attribute controls the # availability of additional cooler control attributes (see below). # # Note: this attribute is unavailable unless cooler control support # has been enabled in the X server (by the user). # NV_CTRL_GPU_COOLER_MANUAL_CONTROL = 319 # RW-G NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE = 0 NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE = 1 # # NV_CTRL_THERMAL_COOLER_LEVEL - The cooler's target level. # Normally, the driver dynamically adjusts the cooler based on # the needs of the GPU. But when NV_CTRL_GPU_COOLER_MANUAL_CONTROL=TRUE, # the driver will attempt to make the cooler achieve the setting in # NV_CTRL_THERMAL_COOLER_LEVEL. The actual current level of the cooler # is reported in NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL. # NV_CTRL_THERMAL_COOLER_LEVEL = 320 # RW-C # NV_CTRL_THERMAL_COOLER_LEVEL_SET_DEFAULT - Sets default values of # cooler. # NV_CTRL_THERMAL_COOLER_LEVEL_SET_DEFAULT = 321 # -W-C # # NV_CTRL_THERMAL_COOLER_CONTROL_TYPE - # Returns a cooler's control signal characteristics. # The possible types are restricted, Variable and Toggle. # NV_CTRL_THERMAL_COOLER_CONTROL_TYPE = 322 # R--C NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_NONE = 0 NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_TOGGLE = 1 NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_VARIABLE = 2 # # NV_CTRL_THERMAL_COOLER_TARGET - Returns objects that cooler cools. # Targets may be GPU, Memory, Power Supply or All of these. # GPU_RELATED = GPU | MEMORY | POWER_SUPPLY # # NV_CTRL_THERMAL_COOLER_TARGET = 323 # R--C NV_CTRL_THERMAL_COOLER_TARGET_NONE = 0 NV_CTRL_THERMAL_COOLER_TARGET_GPU = 1 NV_CTRL_THERMAL_COOLER_TARGET_MEMORY = 2 NV_CTRL_THERMAL_COOLER_TARGET_POWER_SUPPLY = 4 NV_CTRL_THERMAL_COOLER_TARGET_GPU_RELATED = NV_CTRL_THERMAL_COOLER_TARGET_GPU | NV_CTRL_THERMAL_COOLER_TARGET_MEMORY | NV_CTRL_THERMAL_COOLER_TARGET_POWER_SUPPLY # # NV_CTRL_GPU_ECC_SUPPORTED - Reports whether ECC is supported by the # targeted GPU. # NV_CTRL_GPU_ECC_SUPPORTED = 324 # R--G NV_CTRL_GPU_ECC_SUPPORTED_FALSE = 0 NV_CTRL_GPU_ECC_SUPPORTED_TRUE = 1 # # NV_CTRL_GPU_ECC_STATUS - Returns the current hardware ECC setting # for the targeted GPU. # NV_CTRL_GPU_ECC_STATUS = 325 # R--G NV_CTRL_GPU_ECC_STATUS_DISABLED = 0 NV_CTRL_GPU_ECC_STATUS_ENABLED = 1 # # NV_CTRL_GPU_ECC_CONFIGURATION - Reports whether ECC can be configured # dynamically for the GPU in question. # NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED = 326 # R--G NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED_FALSE = 0 NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED_TRUE = 1 # # NV_CTRL_GPU_ECC_CONFIGURATION_SETTING - Returns the current ECC # configuration setting or specifies new settings. New settings do not # take effect until the next POST. # NV_CTRL_GPU_ECC_CONFIGURATION = 327 # RW-G NV_CTRL_GPU_ECC_CONFIGURATION_DISABLED = 0 NV_CTRL_GPU_ECC_CONFIGURATION_ENABLED = 1 # # NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION_SETTING - Returns the default # ECC configuration setting. # NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION = 328 # R--G NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION_DISABLED = 0 NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION_ENABLED = 1 # # NV_CTRL_GPU_ECC_SINGLE_BIT_ERRORS - Returns the number of single-bit # ECC errors detected by the targeted GPU since the last POST. # Note: this attribute is a 64-bit integer attribute. # NV_CTRL_GPU_ECC_SINGLE_BIT_ERRORS = 329 # R--GQ # # NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS - Returns the number of double-bit # ECC errors detected by the targeted GPU since the last POST. # Note: this attribute is a 64-bit integer attribute. # NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS = 330 # R--GQ # # NV_CTRL_GPU_ECC_AGGREGATE_SINGLE_BIT_ERRORS - Returns the number of # single-bit ECC errors detected by the targeted GPU since the # last counter reset. # Note: this attribute is a 64-bit integer attribute. # NV_CTRL_GPU_ECC_AGGREGATE_SINGLE_BIT_ERRORS = 331 # R--GQ # # NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS - Returns the number of # double-bit ECC errors detected by the targeted GPU since the # last counter reset. # Note: this attribute is a 64-bit integer attribute. # NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS = 332 # R--GQ # # NV_CTRL_GPU_ECC_RESET_ERROR_STATUS - Resets the volatile/aggregate # single-bit and double-bit error counters. This attribute is a # bitmask attribute. # NV_CTRL_GPU_ECC_RESET_ERROR_STATUS = 333 # -W-G NV_CTRL_GPU_ECC_RESET_ERROR_STATUS_VOLATILE = 0x00000001 NV_CTRL_GPU_ECC_RESET_ERROR_STATUS_AGGREGATE = 0x00000002 # # NV_CTRL_GPU_POWER_MIZER_MODE - Provides a hint to the driver # as to how to manage the performance of the GPU. # # ADAPTIVE - adjust GPU clocks based on GPU # utilization # PREFER_MAXIMUM_PERFORMANCE - raise GPU clocks to favor # maximum performance, to the extent # that thermal and other constraints # allow # AUTO - let the driver choose the performance # policy # PREFER_CONSISTENT_PERFORMANCE - lock to GPU base clocks # NV_CTRL_GPU_POWER_MIZER_MODE = 334 # RW-G NV_CTRL_GPU_POWER_MIZER_MODE_ADAPTIVE = 0 NV_CTRL_GPU_POWER_MIZER_MODE_PREFER_MAXIMUM_PERFORMANCE = 1 NV_CTRL_GPU_POWER_MIZER_MODE_AUTO = 2 NV_CTRL_GPU_POWER_MIZER_MODE_PREFER_CONSISTENT_PERFORMANCE = 3 # # NV_CTRL_GVI_SYNC_OUTPUT_FORMAT - Returns the output sync signal # from the GVI device. # NV_CTRL_GVI_SYNC_OUTPUT_FORMAT = 335 # R--I # # NV_CTRL_GVI_MAX_CHANNELS_PER_JACK - Returns the maximum # supported number of (logical) channels within a single physical jack of # a GVI device. For most SDI video formats, there is only one channel # (channel 0). But for 3G video formats (as specified in SMPTE 425), # as an example, there are two channels (channel 0 and channel 1) per # physical jack. # NV_CTRL_GVI_MAX_CHANNELS_PER_JACK = 336 # R--I # # NV_CTRL_GVI_MAX_STREAMS - Returns the maximum number of streams # that can be configured on the GVI device. # NV_CTRL_GVI_MAX_STREAMS = 337 # R--I # # NV_CTRL_GVI_NUM_CAPTURE_SURFACES - The GVI interface exposed through # NV-CONTROL and the GLX_NV_video_input extension uses internal capture # surfaces when frames are read from the GVI device. The # NV_CTRL_GVI_NUM_CAPTURE_SURFACES can be used to query and assign the # number of capture surfaces. This attribute is applied when # glXBindVideoCaptureDeviceNV() is called by the application. # # A lower number of capture surfaces will mean less video memory is used, # but can result in frames being dropped if the application cannot keep up # with the capture device. A higher number will prevent frames from being # dropped, making capture more reliable but will consume move video memory. # NV_CTRL_GVI_NUM_CAPTURE_SURFACES = 338 # RW-I # # NV_CTRL_OVERSCAN_COMPENSATION - not supported # NV_CTRL_OVERSCAN_COMPENSATION = 339 # not supported # # NV_CTRL_GPU_PCIE_GENERATION - Reports the current PCIe generation. # NV_CTRL_GPU_PCIE_GENERATION = 341 # R--GI NV_CTRL_GPU_PCIE_GENERATION1 = 0x00000001 NV_CTRL_GPU_PCIE_GENERATION2 = 0x00000002 NV_CTRL_GPU_PCIE_GENERATION3 = 0x00000003 # # NV_CTRL_GVI_BOUND_GPU - Returns the NV_CTRL_TARGET_TYPE_GPU target_id of # the GPU currently bound to the GVI device. Returns -1 if no GPU is # currently bound to the GVI device. # NV_CTRL_GVI_BOUND_GPU = 342 # R--I # # NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3 - this attribute is only # intended to be used to query the ValidValues for # NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT for VIDEO_FORMAT values between # 64 and 95. See NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT for details. # NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3 = 343 # ---GI # # NV_CTRL_ACCELERATE_TRAPEZOIDS - Toggles RENDER Trapezoid acceleration # NV_CTRL_ACCELERATE_TRAPEZOIDS = 344 # RW- NV_CTRL_ACCELERATE_TRAPEZOIDS_DISABLE = 0 NV_CTRL_ACCELERATE_TRAPEZOIDS_ENABLE = 1 # # NV_CTRL_GPU_CORES - Returns number of GPU cores supported by the graphics # pipeline. # NV_CTRL_GPU_CORES = 345 # R--G # # NV_CTRL_GPU_MEMORY_BUS_WIDTH - Returns memory bus bandwidth on the associated # subdevice. # NV_CTRL_GPU_MEMORY_BUS_WIDTH = 346 # R--G # # NV_CTRL_GVI_TEST_MODE - This attribute controls the GVI test mode. When # enabled, the GVI device will generate fake data as quickly as possible. All # GVI settings are still valid when this is enabled (e.g., the requested video # format is honored and sets the video size). # This may be used to test the pipeline. # NV_CTRL_GVI_TEST_MODE = 347 # R--I NV_CTRL_GVI_TEST_MODE_DISABLE = 0 NV_CTRL_GVI_TEST_MODE_ENABLE = 1 # # NV_CTRL_COLOR_SPACE - This option controls the preferred color space of the # video signal. This may not match the current color space depending on the # current mode on this display. # # NV_CTRL_CURRENT_COLOR_SPACE will reflect the actual color space in use. # NV_CTRL_COLOR_SPACE = 348 # RWDG NV_CTRL_COLOR_SPACE_RGB = 0 NV_CTRL_COLOR_SPACE_YCbCr422 = 1 NV_CTRL_COLOR_SPACE_YCbCr444 = 2 # # NV_CTRL_COLOR_RANGE - This option controls the preferred color range of the # video signal. # # If the current color space requires it, the actual color range will be # limited. # # NV_CTRL_CURRENT_COLOR_RANGE will reflect the actual color range in use. # NV_CTRL_COLOR_RANGE = 349 # RWDG NV_CTRL_COLOR_RANGE_FULL = 0 NV_CTRL_COLOR_RANGE_LIMITED = 1 # # NV_CTRL_GPU_SCALING_DEFAULT_TARGET - not supported # NV_CTRL_GPU_SCALING_DEFAULT_TARGET = 350 # not supported # # NV_CTRL_GPU_SCALING_DEFAULT_METHOD - not supported # NV_CTRL_GPU_SCALING_DEFAULT_METHOD = 351 # not supported # # NV_CTRL_DITHERING_MODE - Controls the dithering mode, when # NV_CTRL_CURRENT_DITHERING is Enabled. # # AUTO: allow the driver to choose the dithering mode automatically. # # DYNAMIC_2X2: use a 2x2 matrix to dither from the GPU's pixel # pipeline to the bit depth of the flat panel. The matrix values # are changed from frame to frame. # # STATIC_2X2: use a 2x2 matrix to dither from the GPU's pixel # pipeline to the bit depth of the flat panel. The matrix values # do not change from frame to frame. # # TEMPORAL: use a pseudorandom value from a uniform distribution calculated at # every pixel to achieve stochastic dithering. This method produces a better # visual result than 2x2 matrix approaches. # NV_CTRL_DITHERING_MODE = 352 # RWDG NV_CTRL_DITHERING_MODE_AUTO = 0 NV_CTRL_DITHERING_MODE_DYNAMIC_2X2 = 1 NV_CTRL_DITHERING_MODE_STATIC_2X2 = 2 NV_CTRL_DITHERING_MODE_TEMPORAL = 3 # # NV_CTRL_CURRENT_DITHERING - Returns the current dithering state. # NV_CTRL_CURRENT_DITHERING = 353 # R-DG NV_CTRL_CURRENT_DITHERING_DISABLED = 0 NV_CTRL_CURRENT_DITHERING_ENABLED = 1 # # NV_CTRL_CURRENT_DITHERING_MODE - Returns the current dithering # mode. # NV_CTRL_CURRENT_DITHERING_MODE = 354 # R-DG NV_CTRL_CURRENT_DITHERING_MODE_NONE = 0 NV_CTRL_CURRENT_DITHERING_MODE_DYNAMIC_2X2 = 1 NV_CTRL_CURRENT_DITHERING_MODE_STATIC_2X2 = 2 NV_CTRL_CURRENT_DITHERING_MODE_TEMPORAL = 3 # # NV_CTRL_THERMAL_SENSOR_READING - Returns the thermal sensor's current # reading. # NV_CTRL_THERMAL_SENSOR_READING = 355 # R--S # # NV_CTRL_THERMAL_SENSOR_PROVIDER - Returns the hardware device that # provides the thermal sensor. # NV_CTRL_THERMAL_SENSOR_PROVIDER = 356 # R--S NV_CTRL_THERMAL_SENSOR_PROVIDER_NONE = 0 NV_CTRL_THERMAL_SENSOR_PROVIDER_GPU_INTERNAL = 1 NV_CTRL_THERMAL_SENSOR_PROVIDER_ADM1032 = 2 NV_CTRL_THERMAL_SENSOR_PROVIDER_ADT7461 = 3 NV_CTRL_THERMAL_SENSOR_PROVIDER_MAX6649 = 4 NV_CTRL_THERMAL_SENSOR_PROVIDER_MAX1617 = 5 NV_CTRL_THERMAL_SENSOR_PROVIDER_LM99 = 6 NV_CTRL_THERMAL_SENSOR_PROVIDER_LM89 = 7 NV_CTRL_THERMAL_SENSOR_PROVIDER_LM64 = 8 NV_CTRL_THERMAL_SENSOR_PROVIDER_G781 = 9 NV_CTRL_THERMAL_SENSOR_PROVIDER_ADT7473 = 10 NV_CTRL_THERMAL_SENSOR_PROVIDER_SBMAX6649 = 11 NV_CTRL_THERMAL_SENSOR_PROVIDER_VBIOSEVT = 12 NV_CTRL_THERMAL_SENSOR_PROVIDER_OS = 13 NV_CTRL_THERMAL_SENSOR_PROVIDER_UNKNOWN = 0xFFFFFFFF # # NV_CTRL_THERMAL_SENSOR_TARGET - Returns what hardware component # the thermal sensor is measuring. # NV_CTRL_THERMAL_SENSOR_TARGET = 357 # R--S NV_CTRL_THERMAL_SENSOR_TARGET_NONE = 0 NV_CTRL_THERMAL_SENSOR_TARGET_GPU = 1 NV_CTRL_THERMAL_SENSOR_TARGET_MEMORY = 2 NV_CTRL_THERMAL_SENSOR_TARGET_POWER_SUPPLY = 4 NV_CTRL_THERMAL_SENSOR_TARGET_BOARD = 8 NV_CTRL_THERMAL_SENSOR_TARGET_UNKNOWN = 0xFFFFFFFF # # NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR - when TRUE, OpenGL will # draw information about the current MULTIGPU mode. # NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR = 358 # RW-X NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR_FALSE = 0 NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR_TRUE = 1 # # NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS - Returns GPU's processor # clock freqs. # NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS = 359 # RW-G # # NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS - query the flags (various information # for the specified NV_CTRL_GVIO_VIDEO_FORMAT_*. So that this can be # queried with existing interfaces, the video format should be specified # in the display_mask field; eg: # # XNVCTRLQueryTargetAttribute(dpy, # NV_CTRL_TARGET_TYPE_GVI, # gvi, # NV_CTRL_GVIO_VIDEO_FORMAT_720P_60_00_SMPTE296, # NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS, # &flags); # # Note: The NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_1080P_NO_12BPC flag is set # for those 1080P 3G modes (level A and B) that do not support # 12 bits per component (when configuring a GVI stream.) # NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS = 360 # R--I NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_NONE = 0x00000000 NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_INTERLACED = 0x00000001 NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_PROGRESSIVE = 0x00000002 NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_PSF = 0x00000004 NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_LEVEL_A = 0x00000008 NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_LEVEL_B = 0x00000010 NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G = NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_LEVEL_A | NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_LEVEL_B NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_1080P_NO_12BPC = 0x00000020 # # NV_CTRL_GPU_PCIE_MAX_LINK_SPEED - returns maximum PCIe link speed, # in gigatransfers per second (GT/s). # NV_CTRL_GPU_PCIE_MAX_LINK_SPEED = 361 # R--GI # # NV_CTRL_3D_VISION_PRO_RESET_TRANSCEIVER_TO_FACTORY_SETTINGS - Resets the # 3D Vision Pro transceiver to its factory settings. # NV_CTRL_3D_VISION_PRO_RESET_TRANSCEIVER_TO_FACTORY_SETTINGS = 363 # -W-T # # NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL - Controls the channel that is # currently used by the 3D Vision Pro transceiver. # NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL = 364 # RW-T # # NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE - Controls the mode in which the # 3D Vision Pro transceiver operates. # NV_CTRL_3D_VISION_PRO_TM_LOW_RANGE is bidirectional # NV_CTRL_3D_VISION_PRO_TM_MEDIUM_RANGE is bidirectional # NV_CTRL_3D_VISION_PRO_TM_HIGH_RANGE may be bidirectional just up to a # given range, and unidirectional beyond it # NV_CTRL_3D_VISION_PRO_TM_COUNT is the total number of # 3D Vision Pro transceiver modes # NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE = 365 # RW-T NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_INVALID = 0 NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_LOW_RANGE = 1 NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_MEDIUM_RANGE = 2 NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_HIGH_RANGE = 3 NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_COUNT = 4 # # NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES - controls whether updates to the color # lookup table (LUT) are synchronous with respect to X rendering. For example, # if an X client sends XStoreColors followed by XFillRectangle, the driver will # guarantee that the FillRectangle request is not processed until after the # updated LUT colors are actually visible on the screen if # NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES is enabled. Otherwise, the rendering may # occur first. # # This makes a difference for applications that use the LUT to animate, such as # XPilot. If you experience flickering in applications that use LUT # animations, try enabling this attribute. # # When synchronous updates are enabled, XStoreColors requests will be processed # at your screen's refresh rate. # NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES = 367 # RWDG NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES_DISABLE = 0 NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES_ENABLE = 1 # # NV_CTRL_DITHERING_DEPTH - Controls the dithering depth when # NV_CTRL_CURRENT_DITHERING is ENABLED. Some displays connected # to the GPU via the DVI or LVDS interfaces cannot display the # full color range of ten bits per channel, so the GPU will # dither to either 6 or 8 bits per channel. # NV_CTRL_DITHERING_DEPTH = 368 # RWDG NV_CTRL_DITHERING_DEPTH_AUTO = 0 NV_CTRL_DITHERING_DEPTH_6_BITS = 1 NV_CTRL_DITHERING_DEPTH_8_BITS = 2 # # NV_CTRL_CURRENT_DITHERING_DEPTH - Returns the current dithering # depth value. # NV_CTRL_CURRENT_DITHERING_DEPTH = 369 # R-DG NV_CTRL_CURRENT_DITHERING_DEPTH_NONE = 0 NV_CTRL_CURRENT_DITHERING_DEPTH_6_BITS = 1 NV_CTRL_CURRENT_DITHERING_DEPTH_8_BITS = 2 # # NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_FREQUENCY - Returns the # frequency of the channel(in kHz) of the 3D Vision Pro transceiver. # Use the display_mask parameter to specify the channel number. # NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_FREQUENCY = 370 # R--T # # NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY - Returns the # quality of the channel(in percentage) of the 3D Vision Pro transceiver. # Use the display_mask parameter to specify the channel number. # NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY = 371 # R--T # # NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_COUNT - Returns the number of # channels on the 3D Vision Pro transceiver. # NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_COUNT = 372 # R--T # # NV_CTRL_3D_VISION_PRO_PAIR_GLASSES - Puts the 3D Vision Pro # transceiver into pairing mode to gather additional glasses. # NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_STOP - stops any pairing # NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_BEACON - starts continuous # pairing via beacon mode # Any other value, N - Puts the 3D Vision Pro transceiver into # authenticated pairing mode for N seconds. # NV_CTRL_3D_VISION_PRO_PAIR_GLASSES = 373 # -W-T NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_STOP = 0 NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_BEACON = 0xFFFFFFFF # # NV_CTRL_3D_VISION_PRO_UNPAIR_GLASSES - Tells a specific pair # of glasses to unpair. The glasses will "forget" the address # of the 3D Vision Pro transceiver to which they have been paired. # To unpair all the currently paired glasses, specify # the glasses id as 0. # NV_CTRL_3D_VISION_PRO_UNPAIR_GLASSES = 374 # -W-T # # NV_CTRL_3D_VISION_PRO_DISCOVER_GLASSES - Tells the 3D Vision Pro # transceiver about the glasses that have been paired using # NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_BEACON. Unless this is done, # the 3D Vision Pro transceiver will not know about glasses paired in # beacon mode. # NV_CTRL_3D_VISION_PRO_DISCOVER_GLASSES = 375 # -W-T # # NV_CTRL_3D_VISION_PRO_IDENTIFY_GLASSES - Causes glasses LEDs to # flash for a short period of time. # NV_CTRL_3D_VISION_PRO_IDENTIFY_GLASSES = 376 # -W-T # # NV_CTRL_3D_VISION_PRO_GLASSES_SYNC_CYCLE - Controls the # sync cycle duration(in milliseconds) of the glasses. # Use the display_mask parameter to specify the glasses id. # NV_CTRL_3D_VISION_PRO_GLASSES_SYNC_CYCLE = 378 # RW-T # # NV_CTRL_3D_VISION_PRO_GLASSES_MISSED_SYNC_CYCLES - Returns the # number of state sync cycles recently missed by the glasses. # Use the display_mask parameter to specify the glasses id. # NV_CTRL_3D_VISION_PRO_GLASSES_MISSED_SYNC_CYCLES = 379 # R--T # # NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL - Returns the # battery level(in percentage) of the glasses. # Use the display_mask parameter to specify the glasses id. # NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL = 380 # R--T # # NV_CTRL_GVO_ANC_PARITY_COMPUTATION - Controls the SDI device's computation # of the parity bit (bit 8) for ANC data words. # NV_CTRL_GVO_ANC_PARITY_COMPUTATION = 381 # RW--- NV_CTRL_GVO_ANC_PARITY_COMPUTATION_AUTO = 0 NV_CTRL_GVO_ANC_PARITY_COMPUTATION_ON = 1 NV_CTRL_GVO_ANC_PARITY_COMPUTATION_OFF = 2 # # NV_CTRL_3D_VISION_PRO_GLASSES_PAIR_EVENT - This attribute is sent # as an event when glasses get paired in response to pair command # from any of the clients. # NV_CTRL_3D_VISION_PRO_GLASSES_PAIR_EVENT = 382 # ---T # # NV_CTRL_3D_VISION_PRO_GLASSES_UNPAIR_EVENT - This attribute is sent # as an event when glasses get unpaired in response to unpair command # from any of the clients. # NV_CTRL_3D_VISION_PRO_GLASSES_UNPAIR_EVENT = 383 # ---T # # NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH - returns the current # PCIe link width, in number of lanes. # NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH = 384 # R--GI # # NV_CTRL_GPU_PCIE_CURRENT_LINK_SPEED - returns the current # PCIe link speed, in megatransfers per second (GT/s). # NV_CTRL_GPU_PCIE_CURRENT_LINK_SPEED = 385 # R--GI # # NV_CTRL_GVO_AUDIO_BLANKING - specifies whether the GVO device should delete # audio ancillary data packets when frames are repeated. # # When a new frame is not ready in time, the current frame, including all # ancillary data packets, is repeated. When this data includes audio packets, # this can result in stutters or clicks. When this option is enabled, the GVO # device will detect when frames are repeated, identify audio ancillary data # packets, and mark them for deletion. # # This option is applied when the GVO device is bound. # NV_CTRL_GVO_AUDIO_BLANKING = 386 # RW- NV_CTRL_GVO_AUDIO_BLANKING_DISABLE = 0 NV_CTRL_GVO_AUDIO_BLANKING_ENABLE = 1 # # NV_CTRL_CURRENT_METAMODE_ID - switch modes to the MetaMode with # the specified ID. # NV_CTRL_CURRENT_METAMODE_ID = 387 # RW- # # NV_CTRL_DISPLAY_ENABLED - Returns whether or not the display device # is currently enabled. # NV_CTRL_DISPLAY_ENABLED = 388 # R-D NV_CTRL_DISPLAY_ENABLED_TRUE = 1 NV_CTRL_DISPLAY_ENABLED_FALSE = 0 # # NV_CTRL_FRAMELOCK_INCOMING_HOUSE_SYNC_RATE: this is the rate # of an incomming house sync signal to the frame lock board, in milliHz. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN # target. # NV_CTRL_FRAMELOCK_INCOMING_HOUSE_SYNC_RATE = 389 # R--F # # NV_CTRL_FXAA - enables FXAA. A pixel shader based anti- # aliasing method. # NV_CTRL_FXAA = 390 # RW-X NV_CTRL_FXAA_DISABLE = 0 NV_CTRL_FXAA_ENABLE = 1 # # NV_CTRL_DISPLAY_RANDR_OUTPUT_ID - the RandR Output ID (type RROutput) # that corresponds to the specified Display Device target. If a new # enough version of RandR is not available in the X server, # DISPLAY_RANDR_OUTPUT_ID will be 0. # NV_CTRL_DISPLAY_RANDR_OUTPUT_ID = 391 # R-D- # # NV_CTRL_FRAMELOCK_DISPLAY_CONFIG - Configures whether the display device # should listen, ignore or drive the framelock sync signal. # # Note that whether or not a display device may be set as a client/server # depends on the current configuration. For example, only one server may be # set per Quadro Sync device, and displays can only be configured as a client # if their refresh rate sufficiently matches the refresh rate of the server # device. # # Note that when querying the ValidValues for this data type, the values are # reported as bits within a bitmask (ATTRIBUTE_TYPE_INT_BITS); # NV_CTRL_FRAMELOCK_DISPLAY_CONFIG = 392 # RWD NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_DISABLED = 0 NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_CLIENT = 1 NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_SERVER = 2 # # NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY - Returns the total amount of dedicated # GPU video memory, in MB, on the specified GPU. This excludes any TurboCache # padding included in the value returned by NV_CTRL_TOTAL_GPU_MEMORY. # NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY = 393 # R--G # # NV_CTRL_USED_DEDICATED_GPU_MEMORY- Returns the amount of video memory # currently used on the graphics card in MB. # NV_CTRL_USED_DEDICATED_GPU_MEMORY = 394 # R--G # # NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE # Some GPUs can make a tradeoff between double-precision floating-point # performance and clock speed. Enabling double-precision floating point # performance may benefit CUDA or OpenGL applications that require high # bandwidth double-precision performance. Disabling this feature may benefit # graphics applications that require higher clock speeds. # # This attribute is only available when toggling double precision boost # can be done immediately (without need for a rebooot). # NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE = 395 # RW-G NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE_DISABLED = 0 NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE_ENABLED = 1 # # NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT # Some GPUs can make a tradeoff between double-precision floating-point # performance and clock speed. Enabling double-precision floating point # performance may benefit CUDA or OpenGL applications that require high # bandwidth double-precision performance. Disabling this feature may benefit # graphics applications that require higher clock speeds. # # This attribute is only available when toggling double precision boost # requires a reboot. # NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT = 396 # RW-G NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT_DISABLED = 0 NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT_ENALED = 1 # # NV_CTRL_DPY_HDMI_3D - Returns whether the specified display device is # currently using HDMI 3D Frame Packed Stereo mode. Clients may use this # to help interpret the refresh rate returned by NV_CTRL_REFRESH_RATE or # NV_CTRL_REFRESH_RATE_3, which will be doubled when using HDMI 3D mode. # # This attribute may be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_GPU target. # NV_CTRL_DPY_HDMI_3D = 397 # R-DG NV_CTRL_DPY_HDMI_3D_DISABLED = 0 NV_CTRL_DPY_HDMI_3D_ENABLED = 1 # # NV_CTRL_BASE_MOSAIC - Returns whether Base Mosaic is currently enabled on the # given GPU. Querying the valid values of this attribute returns capabilities. # NV_CTRL_BASE_MOSAIC = 398 # R--G NV_CTRL_BASE_MOSAIC_DISABLED = 0 NV_CTRL_BASE_MOSAIC_FULL = 1 NV_CTRL_BASE_MOSAIC_LIMITED = 2 # # NV_CTRL_MULTIGPU_MASTER_POSSIBLE - Returns whether the GPU can be configured # as the master GPU in a Multi GPU configuration (SLI, SLI Mosaic, # Base Mosaic). # NV_CTRL_MULTIGPU_MASTER_POSSIBLE = 399 # R--G NV_CTRL_MULTIGPU_MASTER_POSSIBLE_FALSE = 0 NV_CTRL_MULTIGPU_MASTER_POSSIBLE_TRUE = 1 # # NV_CTRL_GPU_POWER_MIZER_DEFAULT_MODE - Returns the default PowerMizer mode # for the given GPU. # NV_CTRL_GPU_POWER_MIZER_DEFAULT_MODE = 400 # R--G # # NV_CTRL_XV_SYNC_TO_DISPLAY_ID - When XVideo Sync To VBlank is enabled, this # controls which display device will be synched to if the display is enabled. # Returns NV_CTRL_XV_SYNC_TO_DISPLAY_ID_AUTO if no display has been # selected. # NV_CTRL_XV_SYNC_TO_DISPLAY_ID = 401 # RW- NV_CTRL_XV_SYNC_TO_DISPLAY_ID_AUTO = 0xFFFFFFFF # # NV_CTRL_BACKLIGHT_BRIGHTNESS - The backlight brightness of an internal panel. # NV_CTRL_BACKLIGHT_BRIGHTNESS = 402 # RWD- # # NV_CTRL_GPU_LOGO_BRIGHTNESS - Controls brightness # of the logo on the GPU, if any. The value is variable from 0% - 100%. # NV_CTRL_GPU_LOGO_BRIGHTNESS = 403 # RW-G # # NV_CTRL_GPU_SLI_LOGO_BRIGHTNESS - Controls brightness of the logo # on the SLI bridge, if any. The value is variable from 0% - 100%. # NV_CTRL_GPU_SLI_LOGO_BRIGHTNESS = 404 # RW-G # # NV_CTRL_THERMAL_COOLER_SPEED - Returns cooler's current operating speed in # rotations per minute (RPM). # NV_CTRL_THERMAL_COOLER_SPEED = 405 # R--C # # NV_CTRL_PALETTE_UPDATE_EVENT - The Color Palette has been changed and the # color correction info needs to be updated. # NV_CTRL_PALETTE_UPDATE_EVENT = 406 # --- # # NV_CTRL_VIDEO_ENCODER_UTILIZATION - Returns the video encoder engine # utilization as a percentage. # NV_CTRL_VIDEO_ENCODER_UTILIZATION = 407 # R--G # # NV_CTRL_GSYNC_ALLOWED - when TRUE, OpenGL will enable G-SYNC when possible; # when FALSE, OpenGL will always use a fixed monitor refresh rate. # NV_CTRL_GSYNC_ALLOWED = 408 # RW-X NV_CTRL_GSYNC_ALLOWED_FALSE = 0 NV_CTRL_GSYNC_ALLOWED_TRUE = 1 # # NV_CTRL_GPU_NVCLOCK_OFFSET - This attribute controls the GPU clock offsets # (in MHz) used for overclocking per performance level. # Use the display_mask parameter to specify the performance level. # # Note: To enable overclocking support, set the X configuration # option "Coolbits" to value "8". # # This offset can have any integer value between # NVCTRLAttributeValidValues.u.range.min and # NVCTRLAttributeValidValues.u.range.max (inclusive). # # This attribute is available on GeForce GTX 400 series and later # Geforce GPUs. # NV_CTRL_GPU_NVCLOCK_OFFSET = 409 # RW-G # # NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET - This attribute controls # the memory transfer rate offsets (in MHz) used for overclocking # per performance level. # Use the display_mask parameter to specify the performance level. # # Note: To enable overclocking support, set the X configuration # option "Coolbits" to value "8". # # This offset can have any integer value between # NVCTRLAttributeValidValues.u.range.min and # NVCTRLAttributeValidValues.u.range.max (inclusive). # # This attribute is available on GeForce GTX 400 series and later # Geforce GPUs. # NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET = 410 # RW-G # # NV_CTRL_VIDEO_DECODER_UTILIZATION - Returns the video decoder engine # utilization as a percentage. # NV_CTRL_VIDEO_DECODER_UTILIZATION = 411 # R--G # # NV_CTRL_GPU_OVER_VOLTAGE_OFFSET - This attribute controls # the overvoltage offset in microvolts (uV). # # Note: To enable overvoltage support, set the X configuration # option "Coolbits" to value "16". # # This offset can have any integer value between # NVCTRLAttributeValidValues.u.range.min and # NVCTRLAttributeValidValues.u.range.max (inclusive). # # This attribute is available on GeForce GTX 400 series and later # Geforce GPUs. # NV_CTRL_GPU_OVER_VOLTAGE_OFFSET = 412 # RW-G # # NV_CTRL_GPU_CURRENT_CORE_VOLTAGE - This attribute returns the # GPU's current operating voltage in microvolts (uV). # # This attribute is available on GPUs that support # NV_CTRL_GPU_OVER_VOLTAGE_OFFSET. # NV_CTRL_GPU_CURRENT_CORE_VOLTAGE = 413 # R--G # # NV_CTRL_CURRENT_COLOR_SPACE - Returns the current color space of the video # signal. # # This will match NV_CTRL_COLOR_SPACE unless the current mode on this display # device is an HDMI 2.0 4K@60Hz mode and the display device or GPU does not # support driving this mode in RGB, in which case YCbCr420 will be returned. # NV_CTRL_CURRENT_COLOR_SPACE = 414 # R-DG NV_CTRL_CURRENT_COLOR_SPACE_RGB = 0 NV_CTRL_CURRENT_COLOR_SPACE_YCbCr422 = 1 NV_CTRL_CURRENT_COLOR_SPACE_YCbCr444 = 2 NV_CTRL_CURRENT_COLOR_SPACE_YCbCr420 = 3 # # NV_CTRL_CURRENT_COLOR_RANGE - Returns the current color range of the video # signal. # NV_CTRL_CURRENT_COLOR_RANGE = 415 # R-DG NV_CTRL_CURRENT_COLOR_RANGE_FULL = 0 NV_CTRL_CURRENT_COLOR_RANGE_LIMITED = 1 # # NV_CTRL_SHOW_GSYNC_VISUAL_INDICATOR - when TRUE, OpenGL will indicate when # G-SYNC is in use for full-screen applications. # NV_CTRL_SHOW_GSYNC_VISUAL_INDICATOR = 416 # RW-X NV_CTRL_SHOW_GSYNC_VISUAL_INDICATOR_FALSE = 0 NV_CTRL_SHOW_GSYNC_VISUAL_INDICATOR_TRUE = 1 # # NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL - Returns cooler's current # operating level. This may fluctuate dynamically. When # NV_CTRL_GPU_COOLER_MANUAL_CONTROL=TRUE, the driver attempts # to make this match NV_CTRL_THERMAL_COOLER_LEVEL. When # NV_CTRL_GPU_COOLER_MANUAL_CONTROL=FALSE, the driver adjusts the # current level based on the needs of the GPU. # NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL = 417 # R--C # # NV_CTRL_STEREO_SWAP_MODE - This attribute controls the swap mode when # Quad-Buffered stereo is used. # NV_CTRL_STEREO_SWAP_MODE_APPLICATION_CONTROL : Stereo swap mode is derived # from the value of swap interval. # If it's odd, the per eye swap mode is used. # If it's even, the per eye pair swap mode is used. # NV_CTRL_STEREO_SWAP_MODE_PER_EYE : The driver swaps each eye as it is ready. # NV_CTRL_STEREO_SWAP_MODE_PER_EYE_PAIR : The driver waits for both eyes to # complete rendering before swapping. # NV_CTRL_STEREO_SWAP_MODE = 418 # RW-X NV_CTRL_STEREO_SWAP_MODE_APPLICATION_CONTROL = 0 NV_CTRL_STEREO_SWAP_MODE_PER_EYE = 1 NV_CTRL_STEREO_SWAP_MODE_PER_EYE_PAIR = 2 # # NV_CTRL_CURRENT_XV_SYNC_TO_DISPLAY_ID - When XVideo Sync To VBlank is # enabled, this returns the display id of the device currently synched to. # Returns NV_CTRL_XV_SYNC_TO_DISPLAY_ID_AUTO if no display is currently # set. # NV_CTRL_CURRENT_XV_SYNC_TO_DISPLAY_ID = 419 # R-- # # NV_CTRL_GPU_FRAMELOCK_FIRMWARE_UNSUPPORTED - Returns true if the # Quadro Sync card connected to this GPU has a firmware version incompatible # with this GPU. # NV_CTRL_GPU_FRAMELOCK_FIRMWARE_UNSUPPORTED = 420 # R--G NV_CTRL_GPU_FRAMELOCK_FIRMWARE_UNSUPPORTED_FALSE = 0 NV_CTRL_GPU_FRAMELOCK_FIRMWARE_UNSUPPORTED_TRUE = 1 # # NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE - Returns the connector type used by # a DisplayPort display. # NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE = 421 # R-DG NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_UNKNOWN = 0 NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_DISPLAYPORT = 1 NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_HDMI = 2 NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_DVI = 3 NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_VGA = 4 # # NV_CTRL_DISPLAYPORT_IS_MULTISTREAM - Returns multi-stream support for # DisplayPort displays. # NV_CTRL_DISPLAYPORT_IS_MULTISTREAM = 422 # R-DG # # NV_CTRL_DISPLAYPORT_SINK_IS_AUDIO_CAPABLE - Returns whether a DisplayPort # device supports audio. # NV_CTRL_DISPLAYPORT_SINK_IS_AUDIO_CAPABLE = 423 # R-DG # # NV_CTRL_GPU_NVCLOCK_OFFSET_ALL_PERFORMANCE_LEVELS - This attribute # controls the GPU clock offsets (in MHz) used for overclocking. # The offset is applied to all performance levels. # # Note: To enable overclocking support, set the X configuration # option "Coolbits" to value "8". # # This offset can have any integer value between # NVCTRLAttributeValidValues.u.range.min and # NVCTRLAttributeValidValues.u.range.max (inclusive). # # This attribute is available on GeForce GTX 1000 series and later # Geforce GPUs. # NV_CTRL_GPU_NVCLOCK_OFFSET_ALL_PERFORMANCE_LEVELS = 424 # RW-G # # NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET_ALL_PERFORMANCE_LEVELS - This # attribute controls the memory transfer rate offsets (in MHz) used # for overclocking. The offset is applied to all performance levels. # # Note: To enable overclocking support, set the X configuration # option "Coolbits" to value "8". # # This offset can have any integer value between # NVCTRLAttributeValidValues.u.range.min and # NVCTRLAttributeValidValues.u.range.max (inclusive). # # This attribute is available on GeForce GTX 1000 series and later # Geforce GPUs. # NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET_ALL_PERFORMANCE_LEVELS = 425 # RW-G # # NV_CTRL_FRAMELOCK_FIRMWARE_VERSION - Queries the firmware major version of # the Frame Lock device. # # This attribute must be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK target. # NV_CTRL_FRAMELOCK_FIRMWARE_VERSION = 426 # R--F # # NV_CTRL_FRAMELOCK_FIRMWARE_MINOR_VERSION - Queries the firmware minor # version of the Frame Lock device. # # This attribute must be queried through XNVCTRLQueryTargetAttribute() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK target. # NV_CTRL_FRAMELOCK_FIRMWARE_MINOR_VERSION = 427 # R--F # # NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR - when TRUE, graphics APIs will # indicate various runtime information such as flip/blit, vsync status, API # in use. # NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR = 428 # RW-X NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR_FALSE = 0 NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR_TRUE = 1 NV_CTRL_LAST_ATTRIBUTE = NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR ############################################################################ # # String Attributes: # # String attributes can be queryied through the XNVCTRLQueryStringAttribute() # and XNVCTRLQueryTargetStringAttribute() function calls. # # String attributes can be set through the XNVCTRLSetStringAttribute() # function call. (There are currently no string attributes that can be # set on non-X Screen targets.) # # Unless otherwise noted, all string attributes can be queried/set using an # NV_CTRL_TARGET_TYPE_X_SCREEN target. Attributes that cannot take an # NV_CTRL_TARGET_TYPE_X_SCREEN target also cannot be queried/set through # XNVCTRLQueryStringAttribute()/XNVCTRLSetStringAttribute() (Since # these assume an X Screen target). # # # NV_CTRL_STRING_PRODUCT_NAME - the product name on which the # specified X screen is running, or the product name of the specified # Frame Lock device. # # This attribute may be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target to # return the product name of the GPU, or a NV_CTRL_TARGET_TYPE_FRAMELOCK to # return the product name of the Frame Lock device. # NV_CTRL_STRING_PRODUCT_NAME = 0 # R--GF # # NV_CTRL_STRING_VBIOS_VERSION - the video bios version on the GPU on # which the specified X screen is running. # NV_CTRL_STRING_VBIOS_VERSION = 1 # R--G # # NV_CTRL_STRING_NVIDIA_DRIVER_VERSION - string representation of the # NVIDIA driver version number for the NVIDIA X driver in use. # NV_CTRL_STRING_NVIDIA_DRIVER_VERSION = 3 # R--G # # NV_CTRL_STRING_DISPLAY_DEVICE_NAME - name of the display device # specified in the display_mask argument. # # This attribute may be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_STRING_DISPLAY_DEVICE_NAME = 4 # R-DG # # NV_CTRL_STRING_TV_ENCODER_NAME - not supported # NV_CTRL_STRING_TV_ENCODER_NAME = 5 # not supported # # NV_CTRL_STRING_GVIO_FIRMWARE_VERSION - indicates the version of the # Firmware on the GVIO device. # NV_CTRL_STRING_GVIO_FIRMWARE_VERSION = 8 # R--I # # NV_CTRL_STRING_GVO_FIRMWARE_VERSION - renamed # # NV_CTRL_STRING_GVIO_FIRMWARE_VERSION should be used instead. # NV_CTRL_STRING_GVO_FIRMWARE_VERSION = 8 # renamed # # NV_CTRL_STRING_CURRENT_MODELINE - Return the ModeLine currently # being used by the specified display device. # # This attribute may be queried through XNVCTRLQueryTargetStringAttribute() # using an NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # # The ModeLine string may be prepended with a comma-separated list of # "token=value" pairs, separated from the ModeLine string by "::". # This "token=value" syntax is the same as that used in # NV_CTRL_BINARY_DATA_MODELINES # NV_CTRL_STRING_CURRENT_MODELINE = 9 # R-DG # # NV_CTRL_STRING_ADD_MODELINE - Adds a ModeLine to the specified # display device. The ModeLine is not added if validation fails. # # The ModeLine string should have the same syntax as a ModeLine in # the X configuration file; e.g., # # "1600x1200" 229.5 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync # NV_CTRL_STRING_ADD_MODELINE = 10 # -WDG # # NV_CTRL_STRING_DELETE_MODELINE - Deletes an existing ModeLine # from the specified display device. The currently selected # ModeLine cannot be deleted. (This also means you cannot delete # the last ModeLine.) # # The ModeLine string should have the same syntax as a ModeLine in # the X configuration file; e.g., # # "1600x1200" 229.5 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync # NV_CTRL_STRING_DELETE_MODELINE = 11 # -WDG # # NV_CTRL_STRING_CURRENT_METAMODE - Returns the metamode currently # being used by the specified X screen. The MetaMode string has the # same syntax as the MetaMode X configuration option, as documented # in the NVIDIA driver README. # # The returned string may be prepended with a comma-separated list of # "token=value" pairs, separated from the MetaMode string by "::". # This "token=value" syntax is the same as that used in # NV_CTRL_BINARY_DATA_METAMODES. # NV_CTRL_STRING_CURRENT_METAMODE = 12 # RW-- NV_CTRL_STRING_CURRENT_METAMODE_VERSION_1 = NV_CTRL_STRING_CURRENT_METAMODE # # NV_CTRL_STRING_ADD_METAMODE - Adds a MetaMode to the specified # X Screen. # # It is recommended to not use this attribute, but instead use # NV_CTRL_STRING_OPERATION_ADD_METAMODE. # NV_CTRL_STRING_ADD_METAMODE = 13 # -W-- # # NV_CTRL_STRING_DELETE_METAMODE - Deletes an existing MetaMode from # the specified X Screen. The currently selected MetaMode cannot be # deleted. (This also means you cannot delete the last MetaMode). # The MetaMode string should have the same syntax as the MetaMode X # configuration option, as documented in the NVIDIA driver README. # NV_CTRL_STRING_DELETE_METAMODE = 14 # -WD-- # # NV_CTRL_STRING_VCSC_PRODUCT_NAME - deprecated # # Queries the product name of the VCSC device. # # This attribute must be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_VCSC target. # NV_CTRL_STRING_VCSC_PRODUCT_NAME = 15 # R---V # # NV_CTRL_STRING_VCSC_PRODUCT_ID - deprecated # # Queries the product ID of the VCSC device. # # This attribute must be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_VCSC target. # NV_CTRL_STRING_VCSC_PRODUCT_ID = 16 # R---V # # NV_CTRL_STRING_VCSC_SERIAL_NUMBER - deprecated # # Queries the unique serial number of the VCS device. # # This attribute must be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_VCSC target. # NV_CTRL_STRING_VCSC_SERIAL_NUMBER = 17 # R---V # # NV_CTRL_STRING_VCSC_BUILD_DATE - deprecated # # Queries the date of the VCS device. the returned string is in the following # format: "Week.Year" # # This attribute must be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_VCSC target. # NV_CTRL_STRING_VCSC_BUILD_DATE = 18 # R---V # # NV_CTRL_STRING_VCSC_FIRMWARE_VERSION - deprecated # # Queries the firmware version of the VCS device. # # This attribute must be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_VCSC target. # NV_CTRL_STRING_VCSC_FIRMWARE_VERSION = 19 # R---V # # NV_CTRL_STRING_VCSC_FIRMWARE_REVISION - deprecated # # Queries the firmware revision of the VCS device. # # This attribute must be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_VCS target. # NV_CTRL_STRING_VCSC_FIRMWARE_REVISION = 20 # R---V # # NV_CTRL_STRING_VCSC_HARDWARE_VERSION - deprecated # # Queries the hardware version of the VCS device. # # This attribute must be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_VCSC target. # NV_CTRL_STRING_VCSC_HARDWARE_VERSION = 21 # R---V # # NV_CTRL_STRING_VCSC_HARDWARE_REVISION - deprecated # # Queries the hardware revision of the VCS device. # # This attribute must be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_VCSC target. # NV_CTRL_STRING_VCSC_HARDWARE_REVISION = 22 # R---V # # NV_CTRL_STRING_MOVE_METAMODE - Moves a MetaMode to the specified # index location. The MetaMode must already exist in the X Screen's # list of MetaModes (as returned by the NV_CTRL_BINARY_DATA_METAMODES # attribute). If the index is larger than the number of MetaModes in # the list, the MetaMode is moved to the end of the list. The # MetaMode string should have the same syntax as the MetaMode X # configuration option, as documented in the NVIDIA driver README. # The MetaMode string must be prepended with a comma-separated list # of "token=value" pairs, separated from the MetaMode string by "::". # Currently, the only valid token is "index", which indicates where # in the MetaMode list the MetaMode should be moved to. # # Other tokens may be added in the future. # # E.g., # "index=5 :: CRT-0: 1024x768 @1024x768 +0+0" # NV_CTRL_STRING_MOVE_METAMODE = 23 # -W-- # # NV_CTRL_STRING_VALID_HORIZ_SYNC_RANGES - returns the valid # horizontal sync ranges used to perform mode validation for the # specified display device. The ranges are in the same format as the # "HorizSync" X config option: # # "horizsync-range may be a comma separated list of either discrete # values or ranges of values. A range of values is two values # separated by a dash." # # The values are in kHz. # # Additionally, the string may be prepended with a comma-separated # list of "token=value" pairs, separated from the HorizSync string by # "::". Valid tokens: # # Token Value # "source" "edid" - HorizSync is from the display device's EDID # "xconfig" - HorizSync is from the "HorizSync" entry in # the Monitor section of the X config file # "option" - HorizSync is from the "HorizSync" NVIDIA X # config option # "builtin" - HorizSync is from NVIDIA X driver builtin # default values # # Additional tokens and/or values may be added in the future. # # Example: "source=edid :: 30.000-62.000" # NV_CTRL_STRING_VALID_HORIZ_SYNC_RANGES = 24 # R-DG # # NV_CTRL_STRING_VALID_VERT_REFRESH_RANGES - returns the valid # vertical refresh ranges used to perform mode validation for the # specified display device. The ranges are in the same format as the # "VertRefresh" X config option: # # "vertrefresh-range may be a comma separated list of either discrete # values or ranges of values. A range of values is two values # separated by a dash." # # The values are in Hz. # # Additionally, the string may be prepended with a comma-separated # list of "token=value" pairs, separated from the VertRefresh string by # "::". Valid tokens: # # Token Value # "source" "edid" - VertRefresh is from the display device's EDID # "xconfig" - VertRefresh is from the "VertRefresh" entry in # the Monitor section of the X config file # "option" - VertRefresh is from the "VertRefresh" NVIDIA X # config option # "builtin" - VertRefresh is from NVIDIA X driver builtin # default values # # Additional tokens and/or values may be added in the future. # # Example: "source=edid :: 50.000-75.000" # NV_CTRL_STRING_VALID_VERT_REFRESH_RANGES = 25 # R-DG # # NV_CTRL_STRING_SCREEN_RECTANGLE - returns the physical X Screen's # initial position and size (in absolute coordinates) within the # desktop as the "token=value" string: "x=#, y=#, width=#, height=#" # # Querying this attribute returns success only when Xinerama is enabled # or the X server ABI is greater than equal to 12. # NV_CTRL_STRING_SCREEN_RECTANGLE = 26 # R--- # # NV_CTRL_STRING_XINERAMA_SCREEN_INFO - renamed # # NV_CTRL_STRING_SCREEN_RECTANGLE should be used instead. # NV_CTRL_STRING_XINERAMA_SCREEN_INFO = 26 # renamed # # NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER - used to specify the # order that display devices will be returned via Xinerama when # nvidiaXineramaInfo is enabled. Follows the same syntax as the # nvidiaXineramaInfoOrder X config option. # NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER = 27 # RW-- NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER = NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER # for backwards compatibility: # # NV_CTRL_STRING_SLI_MODE - returns a string describing the current # SLI mode, if any, or FALSE if SLI is not currently enabled. # # This string should be used for informational purposes only, and # should not be used to distinguish between SLI modes, other than to # recognize when SLI is disabled (FALSE is returned) or # enabled (the returned string is non-NULL and describes the current # SLI configuration). # NV_CTRL_STRING_SLI_MODE = 28 # R---*/ # # NV_CTRL_STRING_PERFORMANCE_MODES - returns a string with all the # performance modes defined for this GPU along with their associated # NV Clock and Memory Clock values. # Not all tokens will be reported on all GPUs, and additional tokens # may be added in the future. # For backwards compatibility we still provide nvclock, memclock, and # processorclock those are the same as nvclockmin, memclockmin and # processorclockmin. # # Note: These clock values take into account the offset # set by clients through NV_CTRL_GPU_NVCLOCK_OFFSET and # NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET. # # Each performance modes are returned as a comma-separated list of # "token=value" pairs. Each set of performance mode tokens are separated # by a ";". Valid tokens: # # Token Value # "perf" integer - the Performance level # "nvclock" integer - the GPU clocks (in MHz) for the perf level # "nvclockmin" integer - the GPU clocks min (in MHz) for the perf level # "nvclockmax" integer - the GPU clocks max (in MHz) for the perf level # "nvclockeditable" integer - if the GPU clock domain is editable # for the perf level # "memclock" integer - the memory clocks (in MHz) for the perf level # "memclockmin" integer - the memory clocks min (in MHz) for the perf level # "memclockmax" integer - the memory clocks max (in MHz) for the perf level # "memclockeditable" integer - if the memory clock domain is editable # for the perf level # "memtransferrate" integer - the memory transfer rate (in MHz) # for the perf level # "memtransferratemin" integer - the memory transfer rate min (in MHz) # for the perf level # "memtransferratemax" integer - the memory transfer rate max (in MHz) # for the perf level # "memtransferrateeditable" integer - if the memory transfer rate is editable # for the perf level # "processorclock" integer - the processor clocks (in MHz) # for the perf level # "processorclockmin" integer - the processor clocks min (in MHz) # for the perf level # "processorclockmax" integer - the processor clocks max (in MHz) # for the perf level # "processorclockeditable" integer - if the processor clock domain is editable # for the perf level # # Example: # # perf=0, nvclock=324, nvclockmin=324, nvclockmax=324, nvclockeditable=0, # memclock=324, memclockmin=324, memclockmax=324, memclockeditable=0, # memtransferrate=648, memtransferratemin=648, memtransferratemax=648, # memtransferrateeditable=0 ; # perf=1, nvclock=324, nvclockmin=324, nvclockmax=640, nvclockeditable=0, # memclock=810, memclockmin=810, memclockmax=810, memclockeditable=0, # memtransferrate=1620, memtransferrate=1620, memtransferrate=1620, # memtransferrateeditable=0 ; # # This attribute may be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_STRING_PERFORMANCE_MODES = 29 # R--G # # NV_CTRL_STRING_VCSC_FAN_STATUS - deprecated # # Returns a string with status of all the fans in the Visual Computing System, # if such a query is supported. Fan information is reported along with its # tachometer reading (in RPM) and a flag indicating whether the fan has failed # or not. # # Valid tokens: # # Token Value # "fan" integer - the Fan index # "speed" integer - the tachometer reading of the fan in rpm # "fail" integer - flag to indicate whether the fan has failed # # Example: # # fan=0, speed=694, fail=0 ; fan=1, speed=693, fail=0 # # This attribute must be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_VCSC target. # # NV_CTRL_STRING_VCSC_FAN_STATUS = 30 # R---V # # NV_CTRL_STRING_VCSC_TEMPERATURES - Deprecated # # Returns a string with all Temperature readings in the Visual Computing # System, if such a query is supported. Intake, Exhaust and Board Temperature # values are reported in Celcius. # # Valid tokens: # # Token Value # "intake" integer - the intake temperature for the VCS # "exhaust" integer - the exhaust temperature for the VCS # "board" integer - the board temperature of the VCS # # Example: # # intake=29, exhaust=46, board=41 # # This attribute must be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_VCSC target. # # NV_CTRL_STRING_VCSC_TEMPERATURES = 31 # R---V # # NV_CTRL_STRING_VCSC_PSU_INFO - Deprecated # # Returns a string with all Power Supply Unit related readings in the Visual # Computing System, if such a query is supported. Current in amperes, Power # in watts, Voltage in volts and PSU state may be reported. Not all PSU types # support all of these values, and therefore some readings may be unknown. # # Valid tokens: # # Token Value # "current" integer - the current drawn in amperes by the VCS # "power" integer - the power drawn in watts by the VCS # "voltage" integer - the voltage reading of the VCS # "state" integer - flag to indicate whether PSU is operating normally # # Example: # # current=10, power=15, voltage=unknown, state=normal # # This attribute must be queried through XNVCTRLQueryTargetStringAttribute() # using a NV_CTRL_TARGET_TYPE_VCSC target. # # NV_CTRL_STRING_VCSC_PSU_INFO = 32 # R---V # # NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME - query the name for the specified # NV_CTRL_GVIO_VIDEO_FORMAT_*. So that this can be queried with existing # interfaces, XNVCTRLQueryStringAttribute() should be used, and the video # format specified in the display_mask field; eg: # # XNVCTRLQueryStringAttribute(dpy, # screen, # NV_CTRL_GVIO_VIDEO_FORMAT_720P_60_00_SMPTE296, # NV_CTRL_GVIO_VIDEO_FORMAT_NAME, # &name); # NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME = 33 # R--GI # # NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME - renamed # # NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME should be used instead. # NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME = 33 # renamed # # NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS - returns a string with the # associated NV Clock, Memory Clock and Processor Clock values. # # Current valid tokens are "nvclock", "nvclockmin", "nvclockmax", # "memclock", "memclockmin", "memclockmax", "processorclock", # "processorclockmin" and "processorclockmax". # Not all tokens will be reported on all GPUs, and additional tokens # may be added in the future. # # Note: These clock values take into account the offset # set by clients through NV_CTRL_GPU_NVCLOCK_OFFSET and # NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET. # # Clock values are returned as a comma-separated list of # "token=value" pairs. # Valid tokens: # # Token Value # "nvclock" integer - the GPU clocks (in MHz) for the perf level # "nvclockmin" integer - the GPU clocks min (in MHz) for the perf level # "nvclockmax" integer - the GPU clocks max (in MHz) for the perf level # "nvclockeditable" integer - if the GPU clock domain is editable # for the perf level # "memclock" integer - the memory clocks (in MHz) for the perf level # "memclockmin" integer - the memory clocks min (in MHz) for the perf level # "memclockmax" integer - the memory clocks (max in MHz) for the perf level # "memclockeditable" integer - if the memory clock domain is editable # for the perf level # "memtransferrate" integer - the memory transfer rate (in MHz) # for the perf level # "memtransferratemin" integer - the memory transfer rate min (in MHz) # for the perf level # "memtransferratemax" integer - the memory transfer rate max (in MHz) # for the perf level # "memtransferrateeditable" integer - if the memory transfer rate is editable # for the perf level # "processorclock" integer - the processor clocks (in MHz) # for the perf level # "processorclockmin" integer - the processor clocks min (in MHz) # for the perf level # "processorclockmax" integer - the processor clocks max (in MHz) # for the perf level # "processorclockeditable" integer - if the processor clock domain is editable # for the perf level # # Example: # # nvclock=324, nvclockmin=324, nvclockmax=324, nvclockeditable=0 # memclock=324, memclockmin=324, memclockmax=324, memclockeditable=0 # memtrasferrate=628 # # This attribute may be queried through XNVCTRLQueryTargetStringAttribute() # using an NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS = 34 # RW-G # # NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_HARDWARE_REVISION - Returns the # hardware revision of the 3D Vision Pro transceiver. # NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_HARDWARE_REVISION = 35 # R--T # # NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_A - Returns the # firmware version of chip A of the 3D Vision Pro transceiver. # NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_A = 36 # R--T # # NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_A - Returns the # date of the firmware of chip A of the 3D Vision Pro transceiver. # NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_A = 37 # R--T # # NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_B - Returns the # firmware version of chip B of the 3D Vision Pro transceiver. # NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_B = 38 # R--T # # NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_B - Returns the # date of the firmware of chip B of the 3D Vision Pro transceiver. # NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_B = 39 # R--T # # NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_ADDRESS - Returns the RF address # of the 3D Vision Pro transceiver. # NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_ADDRESS = 40 # R--T # # NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_VERSION_A - Returns the # firmware version of chip A of the glasses. # Use the display_mask parameter to specify the glasses id. # NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_VERSION_A = 41 # R--T # # NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_DATE_A - Returns the # date of the firmware of chip A of the glasses. # Use the display_mask parameter to specify the glasses id. # NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_DATE_A = 42 # R--T # # NV_CTRL_STRING_3D_VISION_PRO_GLASSES_ADDRESS - Returns the RF address # of the glasses. # Use the display_mask parameter to specify the glasses id. # NV_CTRL_STRING_3D_VISION_PRO_GLASSES_ADDRESS = 43 # R--T # # NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME - Controls the name the # glasses should use. # Use the display_mask parameter to specify the glasses id. # Glasses' name should start and end with an alpha-numeric character. # NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME = 44 # RW-T # # NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2 - Returns the metamode currently # being used by the specified X screen. The MetaMode string has the same # syntax as the MetaMode X configuration option, as documented in the NVIDIA # driver README. Also, see NV_CTRL_BINARY_DATA_METAMODES_VERSION_2 for more # details on the base syntax. # # The returned string may also be prepended with a comma-separated list of # "token=value" pairs, separated from the MetaMode string by "::". # NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2 = 45 # RW-- # # NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME - Returns a type name for the # display device ("CRT", "DFP", or "TV"). However, note that the determination # of the name is based on the protocol through which the X driver communicates # to the display device. E.g., if the driver communicates using VGA ,then the # basename is "CRT"; if the driver communicates using TMDS, LVDS, or DP, then # the name is "DFP". # NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME = 46 # R-D- # # NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID - Returns the type-based name + ID for # the display device, e.g. "CRT-0", "DFP-1", "TV-2". If this device is a # DisplayPort multistream device, then this name will also be prepended with the # device's port address like so: "DFP-1.0.1.2.3". See # NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME for more information about the # construction of type-based names. # NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID = 47 # R-D- # # NV_CTRL_STRING_DISPLAY_NAME_DP_GUID - Returns the GUID of the DisplayPort # display device. e.g. "DP-GUID-f16a5bde-79f3-11e1-b2ae-8b5a8969ba9c" # # The display device must be a DisplayPort 1.2 device. # NV_CTRL_STRING_DISPLAY_NAME_DP_GUID = 48 # R-D- # # NV_CTRL_STRING_DISPLAY_NAME_EDID_HASH - Returns the SHA-1 hash of the # display device's EDID in 8-4-4-4-12 UID format. e.g. # "DPY-EDID-f16a5bde-79f3-11e1-b2ae-8b5a8969ba9c" # # The display device must have a valid EDID. # NV_CTRL_STRING_DISPLAY_NAME_EDID_HASH = 49 # R-D- # # NV_CTRL_STRING_DISPLAY_NAME_TARGET_INDEX - Returns the current NV-CONTROL # target ID (name) of the display device. e.g. "DPY-1", "DPY-4" # # This name for the display device is not guarenteed to be the same between # different runs of the X server. # NV_CTRL_STRING_DISPLAY_NAME_TARGET_INDEX = 50 # R-D- # # NV_CTRL_STRING_DISPLAY_NAME_RANDR - Returns the RandR output name for the # display device. e.g. "VGA-1", "DVI-I-0", "DVI-D-3", "LVDS-1", "DP-2", # "HDMI-3", "eDP-6". This name should match If this device is a DisplayPort # 1.2 device, then this name will also be prepended with the device's port # address like so: "DVI-I-3.0.1.2.3" # NV_CTRL_STRING_DISPLAY_NAME_RANDR = 51 # R-D- # # NV_CTRL_STRING_GPU_UUID - Returns the UUID of the given GPU. # NV_CTRL_STRING_GPU_UUID = 52 # R--G # # NV_CTRL_STRING_GPU_UTILIZATION - Returns the current percentage usage # of the various components of the GPU. # # Current valid tokens are "graphics", "memory", "video" and "PCIe". # Not all tokens will be reported on all GPUs, and additional tokens # may be added in the future. # # Utilization values are returned as a comma-separated list of # "token=value" pairs. # Valid tokens: # # Token Value # "graphics" integer - the percentage usage of graphics engine. # "memory" integer - the percentage usage of FB. # "video" integer - the percentage usage of video engine. # "PCIe" integer - the percentage usage of PCIe bandwidth. # # # Example: # # graphics=45, memory=6, video=0, PCIe=0 # # This attribute may be queried through XNVCTRLQueryTargetStringAttribute() # using an NV_CTRL_TARGET_TYPE_GPU. # NV_CTRL_STRING_GPU_UTILIZATION = 53 # R--G # # NV_CTRL_STRING_MULTIGPU_MODE - returns a string describing the current # MULTIGPU mode, if any, or FALSE if MULTIGPU is not currently enabled. # NV_CTRL_STRING_MULTIGPU_MODE = 54 # R--- # # NV_CTRL_STRING_PRIME_OUTPUTS_DATA - returns a semicolon delimited list of # strings that describe all PRIME configured displays. # # ex. "xpos=1920, ypos=0, width=1280, height=1024, screen=0;xpos=3200, # ypos=0, width=800, height=600, screen=0;" # NV_CTRL_STRING_PRIME_OUTPUTS_DATA = 55 # R--- NV_CTRL_STRING_LAST_ATTRIBUTE = NV_CTRL_STRING_PRIME_OUTPUTS_DATA ############################################################################ # # Binary Data Attributes: # # Binary data attributes can be queryied through the XNVCTRLQueryBinaryData() # and XNVCTRLQueryTargetBinaryData() function calls. # # There are currently no binary data attributes that can be set. # # Unless otherwise noted, all Binary data attributes can be queried # using an NV_CTRL_TARGET_TYPE_X_SCREEN target. Attributes that cannot take # an NV_CTRL_TARGET_TYPE_X_SCREEN target also cannot be queried through # XNVCTRLQueryBinaryData() (Since an X Screen target is assumed). # # # NV_CTRL_BINARY_DATA_EDID - Returns a display device's EDID information # data. # # This attribute may be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_BINARY_DATA_EDID = 0 # R-DG # # NV_CTRL_BINARY_DATA_MODELINES - Returns a display device's supported # ModeLines. ModeLines are returned in a buffer, separated by a single # '\0' and terminated by two consecutive '\0' s like so: # # "ModeLine 1\0ModeLine 2\0ModeLine 3\0Last ModeLine\0\0" # # This attribute may be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. # # Each ModeLine string may be prepended with a comma-separated list # of "token=value" pairs, separated from the ModeLine string with a # "::". Valid tokens: # # Token Value # "source" "xserver" - the ModeLine is from the core X server # "xconfig" - the ModeLine was specified in the X config file # "builtin" - the NVIDIA driver provided this builtin ModeLine # "vesa" - this is a VESA standard ModeLine # "edid" - the ModeLine was in the display device's EDID # "nv-control" - the ModeLine was specified via NV-CONTROL # # "xconfig-name" - for ModeLines that were specified in the X config # file, this is the name the X config file # gave for the ModeLine. # # Note that a ModeLine can have several sources; the "source" token # can appear multiple times in the "token=value" pairs list. # Additional source values may be specified in the future. # # Additional tokens may be added in the future, so it is recommended # that any token parser processing the returned string from # NV_CTRL_BINARY_DATA_MODELINES be implemented to gracefully ignore # unrecognized tokens. # # E.g., # # "source=xserver, source=vesa, source=edid :: "1024x768_70" 75.0 1024 1048 1184 1328 768 771 777 806 -HSync -VSync" # "source=xconfig, xconfig-name=1600x1200_60.00 :: "1600x1200_60_0" 161.0 1600 1704 1880 2160 1200 1201 1204 1242 -HSync +VSync" # NV_CTRL_BINARY_DATA_MODELINES = 1 # R-DG # # NV_CTRL_BINARY_DATA_METAMODES - Returns an X Screen's supported # MetaModes. MetaModes are returned in a buffer separated by a # single '\0' and terminated by two consecutive '\0' s like so: # # "MetaMode 1\0MetaMode 2\0MetaMode 3\0Last MetaMode\0\0" # # The MetaMode string should have the same syntax as the MetaMode X # configuration option, as documented in the NVIDIA driver README. # Each MetaMode string may be prepended with a comma-separated list # of "token=value" pairs, separated from the MetaMode string with # "::". Currently, valid tokens are: # # Token Value # "id" - the id of this MetaMode; this is stored in # the Vertical Refresh field, as viewed # by the XRandR and XF86VidMode X# # extensions. # # "switchable" "yes"/"no" - whether this MetaMode may be switched to via # ctrl-alt-+/-; Implicit MetaModes (see # the "IncludeImplicitMetaModes" X # config option), for example, are not # normally made available through # ctrl-alt-+/-. # # "source" "xconfig" - the MetaMode was specified in the X # config file. # "implicit" - the MetaMode was implicitly added; see the # "IncludeImplicitMetaModes" X config option # for details. # "nv-control" - the MetaMode was added via the NV-CONTROL X # extension to the currently running X server. # "RandR" - the MetaMode was modified in response to an # RandR RRSetCrtcConfig request. # # Additional tokens may be added in the future, so it is recommended # that any token parser processing the returned string from # NV_CTRL_BINARY_DATA_METAMODES be implemented to gracefully ignore # unrecognized tokens. # # E.g., # # "id=50, switchable=yes, source=xconfig :: CRT-0: 1024x768 @1024x768 +0+0" # NV_CTRL_BINARY_DATA_METAMODES = 2 # R-D- NV_CTRL_BINARY_DATA_METAMODES_VERSION_1 = NV_CTRL_BINARY_DATA_METAMODES # # NV_CTRL_BINARY_DATA_XSCREENS_USING_GPU - Returns the list of X # screens currently driven by the given GPU. # # The format of the returned data is: # # 4 CARD32 number of screens # 4# n CARD32 screen indices # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be # queried using a NV_CTRL_TARGET_TYPE_X_SCREEN. # NV_CTRL_BINARY_DATA_XSCREENS_USING_GPU = 3 # R-DG # # NV_CTRL_BINARY_DATA_GPUS_USED_BY_XSCREEN - Returns the list of GPUs # currently in use by the given X screen. # # The format of the returned data is: # # 4 CARD32 number of GPUs # 4# n CARD32 GPU indices # NV_CTRL_BINARY_DATA_GPUS_USED_BY_XSCREEN = 4 # R--- # # NV_CTRL_BINARY_DATA_GPUS_USING_FRAMELOCK - Returns the list of # GPUs currently connected to the given frame lock board. # # The format of the returned data is: # # 4 CARD32 number of GPUs # 4# n CARD32 GPU indices # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_FRAMELOCK target. This attribute cannot be # queried using a NV_CTRL_TARGET_TYPE_X_SCREEN. # NV_CTRL_BINARY_DATA_GPUS_USING_FRAMELOCK = 5 # R-DF # # NV_CTRL_BINARY_DATA_DISPLAY_VIEWPORT - Returns the Display Device's # viewport box into the given X Screen (in X Screen coordinates.) # # The format of the returned data is: # # 4 CARD32 Offset X # 4 CARD32 Offset Y # 4 CARD32 Width # 4 CARD32 Height # NV_CTRL_BINARY_DATA_DISPLAY_VIEWPORT = 6 # R-DG # # NV_CTRL_BINARY_DATA_FRAMELOCKS_USED_BY_GPU - Returns the list of # Framelock devices currently connected to the given GPU. # # The format of the returned data is: # # 4 CARD32 number of Framelocks # 4# n CARD32 Framelock indices # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be # queried using a NV_CTRL_TARGET_TYPE_X_SCREEN. # NV_CTRL_BINARY_DATA_FRAMELOCKS_USED_BY_GPU = 7 # R-DG # # NV_CTRL_BINARY_DATA_GPUS_USING_VCSC - Deprecated # # Returns the list of GPU devices connected to the given VCS. # # The format of the returned data is: # # 4 CARD32 number of GPUs # 4# n CARD32 GPU indices # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_VCSC target. This attribute cannot be # queried using a NV_CTRL_TARGET_TYPE_X_SCREEN and cannot be queried using # a NV_CTRL_TARGET_TYPE_X_GPU # NV_CTRL_BINARY_DATA_GPUS_USING_VCSC = 8 # R-DV # # NV_CTRL_BINARY_DATA_VCSCS_USED_BY_GPU - Deprecated # # Returns the VCSC device that is controlling the given GPU. # # The format of the returned data is: # # 4 CARD32 number of VCS (always 1) # 4# n CARD32 VCS indices # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be # queried using a NV_CTRL_TARGET_TYPE_X_SCREEN # NV_CTRL_BINARY_DATA_VCSCS_USED_BY_GPU = 9 # R-DG # # NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU - Returns the coolers that # are cooling the given GPU. # # The format of the returned data is: # # 4 CARD32 number of COOLER # 4# n CARD32 COOLER indices # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be # queried using a NV_CTRL_TARGET_TYPE_X_SCREEN # NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU = 10 # R-DG # # NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN - Returns the list of # GPUs currently driving the given X screen. If Xinerama is enabled, this # will return all GPUs that are driving any X screen. # # The format of the returned data is: # # 4 CARD32 number of GPUs # 4# n CARD32 GPU indices # NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN = 11 # R--- # # NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU - Returns the sensors that # are attached to the given GPU. # # The format of the returned data is: # # 4 CARD32 number of SENSOR # 4# n CARD32 SENSOR indices # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be # queried using a NV_CTRL_TARGET_TYPE_X_SCREEN # NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU = 12 # R--G # # NV_CTRL_BINARY_DATA_GLASSES_PAIRED_TO_3D_VISION_PRO_TRANSCEIVER - Returns # the id of the glasses that are currently paired to the given # 3D Vision Pro transceiver. # # The format of the returned data is: # # 4 CARD32 number of glasses # 4# n CARD32 id of glasses # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER target. # NV_CTRL_BINARY_DATA_GLASSES_PAIRED_TO_3D_VISION_PRO_TRANSCEIVER = 13 # R--T # # NV_CTRL_BINARY_DATA_DISPLAY_TARGETS - Returns all the display devices # currently connected to any GPU on the X server. # # The format of the returned data is: # # 4 CARD32 number of display devices # 4# n CARD32 display device indices # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData(). # NV_CTRL_BINARY_DATA_DISPLAY_TARGETS = 14 # R--- # # NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU - Returns the list of # display devices that are connected to the GPU target. # # The format of the returned data is: # # 4 CARD32 number of display devices # 4# n CARD32 display device indices # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_GPU target. # NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU = 15 # R--G # # NV_CTRL_BINARY_DATA_METAMODES_VERSION_2 - Returns values similar to # NV_CTRL_BINARY_DATA_METAMODES(_VERSION_1) but also returns extended syntax # information to indicate a specific display device, as well as other per- # display deviceflags as "token=value" pairs. For example: # # "DPY-1: 1280x1024 {Stereo=PassiveLeft}, # DPY-2: 1280x1024 {Stereo=PassiveRight}," # # The display device names have the form "DPY-%d", where the integer # part of the name is the NV-CONTROL target ID for that display device # for this instance of the X server. Note that display device NV-CONTROL # target IDs are not guaranteed to be the same from one run of the X # server to the next. # NV_CTRL_BINARY_DATA_METAMODES_VERSION_2 = 16 # R-D- # # NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN - Returns the list of # display devices that are currently scanning out the X screen target. # # The format of the returned data is: # # 4 CARD32 number of display devices # 4# n CARD32 display device indices # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN = 17 # R--- # # NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN - Returns the list of # display devices that are currently assigned the X screen target. # # The format of the returned data is: # # 4 CARD32 number of display devices # 4# n CARD32 display device indices # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_X_SCREEN target. # NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN = 18 # R--- # # NV_CTRL_BINARY_DATA_GPU_FLAGS - Returns a list of flags for the # given GPU. A flag can, for instance, be a capability which enables # or disables some features according to the GPU state. # # The format of the returned data is: # # 4 CARD32 number of GPU flags # 4# n CARD32 GPU flag # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_GPU target. # NV_CTRL_BINARY_DATA_GPU_FLAGS = 19 # R--- # Stereo and display composition transformations are mutually exclusive. NV_CTRL_BINARY_DATA_GPU_FLAGS_STEREO_DISPLAY_TRANSFORM_EXCLUSIVE = 0 # Overlay and display composition transformations are mutually exclusive. NV_CTRL_BINARY_DATA_GPU_FLAGS_OVERLAY_DISPLAY_TRANSFORM_EXCLUSIVE = 1 # Depth 8 and display composition transformations are mutually exclusive. NV_CTRL_BINARY_DATA_GPU_FLAGS_DEPTH_8_DISPLAY_TRANSFORM_EXCLUSIVE = 2 # # NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU - Returns the list of valid # display devices that can be connected to the GPU target. # # The format of the returned data is: # # 4 CARD32 number of display devices # 4# n CARD32 display device indices # # This attribute can only be queried through XNVCTRLQueryTargetBinaryData() # using a NV_CTRL_TARGET_TYPE_GPU target. # NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU = 20 # R--G NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE = NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU ############################################################################ # # String Operation Attributes: # # These attributes are used with the XNVCTRLStringOperation() # function; a string is specified as input, and a string is returned # as output. # # Unless otherwise noted, all attributes can be operated upon using # an NV_CTRL_TARGET_TYPE_X_SCREEN target. # # # NV_CTRL_STRING_OPERATION_ADD_METAMODE - provide a MetaMode string # as input, and returns a string containing comma-separated list of # "token=value" pairs as output. Currently, the only output token is # "id", which indicates the id that was assigned to the MetaMode. # # All ModeLines referenced in the MetaMode must already exist for # each display device (as returned by the # NV_CTRL_BINARY_DATA_MODELINES attribute). # # The MetaMode string should have the same syntax as the MetaMode X # configuration option, as documented in the NVIDIA driver README. # # The input string can optionally be prepended with a string of # comma-separated "token=value" pairs, separated from the MetaMode # string by "::". Currently, the only valid token is "index" which # indicates the insertion index for the MetaMode. # # E.g., # # Input: "index=5 :: 1600x1200+0+0, 1600x1200+1600+0" # Output: "id=58" # # which causes the MetaMode to be inserted at position 5 in the # MetaMode list (all entries after 5 will be shifted down one slot in # the list), and the X server's containing mode stores 58 as the # VRefresh, so that the MetaMode can be uniquely identifed through # XRandR and XF86VidMode. # NV_CTRL_STRING_OPERATION_ADD_METAMODE = 0 # ---- # # NV_CTRL_STRING_OPERATION_GTF_MODELINE - provide as input a string # of comma-separated "token=value" pairs, and returns a ModeLine # string, computed using the GTF formula using the parameters from # the input string. Valid tokens for the input string are "width", # "height", and "refreshrate". # # E.g., # # Input: "width=1600, height=1200, refreshrate=60" # Output: "160.96 1600 1704 1880 2160 1200 1201 1204 1242 -HSync +VSync" # # This operation does not have any impact on any display device's # modePool, and the ModeLine is not validated; it is simply intended # for generating ModeLines. # NV_CTRL_STRING_OPERATION_GTF_MODELINE = 1 # --- # # NV_CTRL_STRING_OPERATION_CVT_MODELINE - provide as input a string # of comma-separated "token=value" pairs, and returns a ModeLine # string, computed using the CVT formula using the parameters from # the input string. Valid tokens for the input string are "width", # "height", "refreshrate", and "reduced-blanking". The # "reduced-blanking" argument can be "0" or "1", to enable or disable # use of reduced blanking for the CVT formula. # # E.g., # # Input: "width=1600, height=1200, refreshrate=60, reduced-blanking=1" # Output: "130.25 1600 1648 1680 1760 1200 1203 1207 1235 +HSync -VSync" # # This operation does not have any impact on any display device's # modePool, and the ModeLine is not validated; it is simply intended # for generating ModeLines. # NV_CTRL_STRING_OPERATION_CVT_MODELINE = 2 # --- # # NV_CTRL_STRING_OPERATION_BUILD_MODEPOOL - build a ModePool for the # specified display device on the specified target (either an X # screen or a GPU). This is typically used to generate a ModePool # for a display device on a GPU on which no X screens are present. # # Currently, a display device's ModePool is static for the life of # the X server, so XNVCTRLStringOperation will return FALSE if # requested to build a ModePool on a display device that already has # a ModePool. # # The string input to BUILD_MODEPOOL may be NULL. If it is not NULL, # then it is interpreted as a double-colon ("::") separated list # of "option=value" pairs, where the options and the syntax of their # values are the X configuration options that impact the behavior of # modePool construction; namely: # # "ModeValidation" # "HorizSync" # "VertRefresh" # "FlatPanelProperties" # "ExactModeTimingsDVI" # "UseEdidFreqs" # # An example input string might look like: # # "ModeValidation=NoVesaModes :: HorizSync=50-110 :: VertRefresh=50-150" # # This request currently does not return a string. # NV_CTRL_STRING_OPERATION_BUILD_MODEPOOL = 3 # DG # # NV_CTRL_STRING_OPERATION_GVI_CONFIGURE_STREAMS - Configure the streams- # to-jack+channel topology for a GVI (Graphics capture board). # # The string input to GVI_CONFIGURE_STREAMS may be NULL. If this is the # case, then the current topology is returned. # # If the input string to GVI_CONFIGURE_STREAMS is not NULL, the string # is interpreted as a semicolon (";") separated list of comma-separated # lists of "option=value" pairs that define a stream's composition. The # available options and their values are: # # "stream": Defines which stream this comma-separated list describes. # Valid values are the integers between 0 and # NV_CTRL_GVI_NUM_STREAMS-1 (inclusive). # # "linkN": Defines a jack+channel pair to use for the given link N. # Valid options are the string "linkN", where N is an integer # between 0 and NV_CTRL_GVI_MAX_LINKS_PER_STREAM-1 (inclusive). # Valid values for these options are strings of the form # "jackX" and/or "jackX.Y", where X is an integer between 0 and # NV_CTRL_GVI_NUM_JACKS-1 (inclusive), and Y (optional) is an # integer between 0 and NV_CTRL_GVI_MAX_CHANNELS_PER_JACK-1 # (inclusive). # # An example input string might look like: # # "stream=0, link0=jack0, link1=jack1; stream=1, link0=jack2.1" # # This example specifies two streams, stream 0 and stream 1. Stream 0 # is defined to capture link0 data from the first channel (channel 0) of # BNC jack 0 and link1 data from the first channel of BNC jack 1. The # second stream (Stream 1) is defined to capture link0 data from channel 1 # (second channel) of BNC jack 2. # # This example shows a possible configuration for capturing 3G input: # # "stream=0, link0=jack0.0, link1=jack0.1" # # Applications should query the following attributes to determine # possible combinations: # # NV_CTRL_GVI_MAX_STREAMS # NV_CTRL_GVI_MAX_LINKS_PER_STREAM # NV_CTRL_GVI_NUM_JACKS # NV_CTRL_GVI_MAX_CHANNELS_PER_JACK # # Note: A jack+channel pair can only be tied to one link/stream. # # Upon successful configuration or querying of this attribute, a string # representing the current topology for all known streams on the device # will be returned. On failure, NULL is returned. # # Note: Setting this attribute may also result in the following # NV-CONTROL attributes being reset on the GVI device (to ensure # the configuration remains valid): # NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT # NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT # NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING # NV_CTRL_STRING_OPERATION_GVI_CONFIGURE_STREAMS = 4 # RW-I # # NV_CTRL_STRING_OPERATION_PARSE_METAMODE - Parses the given MetaMode string # and returns the validated MetaMode string - possibly re-calculating various # values such as ViewPortIn. If the MetaMode matches an existing MetaMode, # the details of the existing MetaMode are returned. If the MetaMode fails to # be parsed, NULL is returned. # NV_CTRL_STRING_OPERATION_PARSE_METAMODE = 5 # R--- NV_CTRL_STRING_OPERATION_LAST_ATTRIBUTE = NV_CTRL_STRING_OPERATION_PARSE_METAMODE ############################################################################### # NV-CONTROL major op numbers. these constants identify the request type # X_nvCtrlQueryExtension = 0 X_nvCtrlQueryAttribute = 2 X_nvCtrlQueryStringAttribute = 4 X_nvCtrlQueryValidAttributeValues = 5 X_nvCtrlSetStringAttribute = 9 X_nvCtrlSetAttributeAndGetStatus = 19 X_nvCtrlQueryBinaryData = 20 X_nvCtrlQueryTargetCount = 24 X_nvCtrlStringOperation = 25 ############################################################################### # various lists that go with attrs, but are handled more compactly # this way. these lists are indexed by the possible values of their attrs # and are explained in NVCtrl.h # ATTRIBUTE_TYPE_UNKNOWN = 0 ATTRIBUTE_TYPE_INTEGER = 1 ATTRIBUTE_TYPE_BITMASK = 2 ATTRIBUTE_TYPE_BOOL = 3 ATTRIBUTE_TYPE_RANGE = 4 ATTRIBUTE_TYPE_INT_BITS = 5 ATTRIBUTE_TYPE_READ = 0x01 ATTRIBUTE_TYPE_WRITE = 0x02 ATTRIBUTE_TYPE_DISPLAY = 0x04 ATTRIBUTE_TYPE_GPU = 0x08 ATTRIBUTE_TYPE_FRAMELOCK = 0x10 ATTRIBUTE_TYPE_X_SCREEN = 0x20 ATTRIBUTE_TYPE_XINERAMA = 0x40 ATTRIBUTE_TYPE_VCSC = 0x80 ############################################################################ # # Attribute Targets # # Targets define attribute groups. For example, some attributes are only # valid to set on a GPU, others are only valid when talking about an # X Screen. Target types are then what is used to identify the target # group of the attribute you wish to set/query. # # Here are the supported target types: # NV_CTRL_TARGET_TYPE_X_SCREEN = 0 NV_CTRL_TARGET_TYPE_GPU = 1 NV_CTRL_TARGET_TYPE_FRAMELOCK = 2 # Visual Computing System - deprecated. To be removed along with all # VCS-specific attributes in a later release. NV_CTRL_TARGET_TYPE_VCSC = 3 NV_CTRL_TARGET_TYPE_GVI = 4 NV_CTRL_TARGET_TYPE_COOLER = 5 # e.g., fan NV_CTRL_TARGET_TYPE_THERMAL_SENSOR = 6 NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER = 7 NV_CTRL_TARGET_TYPE_DISPLAY = 8 ############################################################################### # Targets, to indicate where a command should be executed. # class Target(object): def __init__(self): self._id = -1 self._type = -1 self._name = '' def id(self): return self._id def type(self): return self._type def __str__(self): return ''.format(self._name, self.id()) class Gpu(Target): def __init__(self, ngpu=0): """Target a GPU""" super(self.__class__, self).__init__() self._id = ngpu self._type = NV_CTRL_TARGET_TYPE_GPU self._name = 'GPU' class Screen(Target): def __init__(self, nscr=0): """Target an X screen""" super(self.__class__, self).__init__() self._id = nscr self._type = NV_CTRL_TARGET_TYPE_X_SCREEN self._name = 'X screen' class Cooler(Target): def __init__(self, nfan=0): """Target a fann""" super(self.__class__, self).__init__() self._id = nfan self._type = NV_CTRL_TARGET_TYPE_COOLER self._name = 'Cooler' class NVCtrlQueryTargetCountReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlQueryTargetCount), rq.RequestLength(), rq.Card32('target_type'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('padb1'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('count'), rq.Card32('pad4'), rq.Card32('pad5'), rq.Card32('pad6'), rq.Card32('pad7'), rq.Card32('pad8'), ) class NVCtrlQueryAttributeReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlQueryAttribute), rq.RequestLength(), rq.Card16('target_id'), rq.Card16('target_type'), rq.Card32('display_mask'), rq.Card32('attr'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('pad0'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('flags'), rq.Int32('value'), rq.Card32('pad4'), rq.Card32('pad5'), rq.Card32('pad6'), rq.Card32('pad7'), ) class NVCtrlSetAttributeAndGetStatusReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlSetAttributeAndGetStatus), rq.RequestLength(), rq.Card16('target_id'), rq.Card16('target_type'), rq.Card32('display_mask'), rq.Card32('attr'), rq.Int32('value') ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('pad0'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('flags'), rq.Card32('pad3'), rq.Card32('pad4'), rq.Card32('pad5'), rq.Card32('pad6'), rq.Card32('pad7'), ) class NVCtrlQueryStringAttributeReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlQueryStringAttribute), rq.RequestLength(), rq.Card16('target_id'), rq.Card16('target_type'), rq.Card32('display_mask'), rq.Card32('attr'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('pad0'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('flags'), rq.Card32('string', 4), rq.Card32('pad4'), rq.Card32('pad5'), rq.Card32('pad6'), rq.Card32('pad7'), rq.String8('string'), ) class NVCtrlQueryValidAttributeValuesReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlQueryValidAttributeValues), rq.RequestLength(), rq.Card16('target_id'), rq.Card16('target_type'), rq.Card32('display_mask'), rq.Card32('attr'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('pad0'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('flags'), rq.Int32('attr_type'), rq.Int32('min'), rq.Int32('max'), rq.Card32('bits'), rq.Card32('perms'), ) class NVCtrlQueryBinaryDataReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlQueryBinaryData), rq.RequestLength(), rq.Card16('target_id'), rq.Card16('target_type'), rq.Card32('display_mask'), rq.Card32('attr'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('pad0'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('flags'), rq.Card32('data', 4), rq.Card32('pad4'), rq.Card32('pad5'), rq.Card32('pad6'), rq.Card32('pad7'), rq.Binary('data'), ) class NVCtrlQueryListCard32ReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlQueryBinaryData), rq.RequestLength(), rq.Card16('target_id'), rq.Card16('target_type'), rq.Card32('display_mask'), rq.Card32('attr'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('pad0'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('flags'), rq.Card32('list', 4), rq.Card32('pad4'), rq.Card32('pad5'), rq.Card32('pad6'), rq.Card32('pad7'), rq.List('list', rq.Card32), ) python-xlib-0.33/Xlib/ext/randr.py000066400000000000000000001106271435211557500171110ustar00rootroot00000000000000# Xlib.ext.randr -- RandR extension module # # Copyright (C) 2006 Mike Meyer # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA """RandR - provide access to the RandR extension information. This implementation is based off version 1.5 of the XRandR protocol, and may not be compatible with other versions. Version 1.5 of the protocol is documented at: http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt Version 1.3.1 here: http://www.x.org/releases/X11R7.5/doc/randrproto/randrproto.txt """ from Xlib import X from Xlib.protocol import rq extname = 'RANDR' # Event codes # RRScreenChangeNotify = 0 # V1.2 additions RRNotify = 1 # RRNotify Subcodes RRNotify_CrtcChange = 0 RRNotify_OutputChange = 1 RRNotify_OutputProperty = 2 # Event selection bits # RRScreenChangeNotifyMask = (1 << 0) # V1.2 additions RRCrtcChangeNotifyMask = (1 << 1) RROutputChangeNotifyMask = (1 << 2) RROutputPropertyNotifyMask = (1 << 3) # Constants # SetConfigSuccess = 0 SetConfigInvalidConfigTime = 1 SetConfigInvalidTime = 2 SetConfigFailed = 3 # used in the rotation field; rotation and reflection in 0.1 proto. Rotate_0 = 1 Rotate_90 = 2 Rotate_180 = 4 Rotate_270 = 8 # new in 1.0 protocol, to allow reflection of screen Reflect_X = 16 Reflect_Y = 32 # new in 1.2 protocol HSyncPositive = 0x00000001 HSyncNegative = 0x00000002 VSyncPositive = 0x00000004 VSyncNegative = 0x00000008 Interlace = 0x00000010 DoubleScan = 0x00000020 CSync = 0x00000040 CSyncPositive = 0x00000080 CSyncNegative = 0x00000100 HSkewPresent = 0x00000200 BCast = 0x00000400 PixelMultiplex = 0x00000800 DoubleClock = 0x00001000 ClockDivideBy2 = 0x00002000 # event types? Connected = 0 Disconnected = 1 UnknownConnection = 2 # Conventional RandR output properties PROPERTY_RANDR_EDID = "EDID" PROPERTY_SIGNAL_FORMAT = "SignalFormat" PROPERTY_SIGNAL_PROPERTIES = "SignalProperties" PROPERTY_CONNECTOR_TYPE = "ConnectorType" PROPERTY_CONNECTOR_NUMBER = "ConnectorNumber" PROPERTY_COMPATIBILITY_LIST = "CompatibilityList" PROPERTY_CLONE_LIST = "CloneList" # subpixel order - TODO: These constants are part of the RENDER extension and # should be moved there if/when that extension is added to python-xlib. SubPixelUnknown = 0 SubPixelHorizontalRGB = 1 SubPixelHorizontalBGR = 2 SubPixelVerticalRGB = 3 SubPixelVerticalBGR = 4 SubPixelNone = 5 # Error Codes # BadRROutput = 0 BadRRCrtc = 1 BadRRMode = 2 # Error classes # class BadRROutputError(Exception): pass class BadRRCrtcError(Exception): pass class BadRRModeError(Exception): pass # Data Structures # RandR_ScreenSizes = rq.Struct( rq.Card16('width_in_pixels'), rq.Card16('height_in_pixels'), rq.Card16('width_in_millimeters'), rq.Card16('height_in_millimeters'), ) RandR_ModeInfo = rq.Struct( rq.Card32('id'), rq.Card16('width'), rq.Card16('height'), rq.Card32('dot_clock'), rq.Card16('h_sync_start'), rq.Card16('h_sync_end'), rq.Card16('h_total'), rq.Card16('h_skew'), rq.Card16('v_sync_start'), rq.Card16('v_sync_end'), rq.Card16('v_total'), rq.Card16('name_length'), rq.Card32('flags'), ) RandR_Rates = rq.Struct( rq.LengthOf('rates', 2), rq.List('rates', rq.Card16Obj) ) # TODO: This struct is part of the RENDER extension and should be moved there # if/when that extension is added to python-xlib. Render_Transform = rq.Struct( rq.Card32('matrix11'), #FIXME: All of these are listed as FIXED in the protocol header. rq.Card32('matrix12'), rq.Card32('matrix13'), rq.Card32('matrix21'), rq.Card32('matrix22'), rq.Card32('matrix23'), rq.Card32('matrix31'), rq.Card32('matrix32'), rq.Card32('matrix33'), ) MonitorInfo = rq.Struct( rq.Card32('name'), rq.Bool('primary'), rq.Bool('automatic'), rq.LengthOf('crtcs', 2), rq.Int16('x'), rq.Int16('y'), rq.Card16('width_in_pixels'), rq.Card16('height_in_pixels'), rq.Card32('width_in_millimeters'), rq.Card32('height_in_millimeters'), rq.List('crtcs', rq.Card32Obj) ) # Requests # class QueryVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card32('major_version'), rq.Card32('minor_version'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('major_version'), rq.Card32('minor_version'), rq.Pad(16), ) def query_version(self): """Get the current version of the RandR extension. """ return QueryVersion( display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=5, ) class _1_0SetScreenConfig(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Drawable('drawable'), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.Card16('size_id'), rq.Card16('rotation'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('new_timestamp'), rq.Card32('new_config_timestamp'), rq.Window('root'), rq.Card16('subpixel_order'), rq.Pad(10), ) def _1_0set_screen_config(self, size_id, rotation, config_timestamp, timestamp=X.CurrentTime): """Sets the screen to the specified size and rotation. """ return _1_0SetScreenConfig( display=self.display, opcode=self.display.get_extension_major(extname), drawable=self, timestamp=timestamp, config_timestamp=config_timestamp, size_id=size_id, rotation=rotation, ) class SetScreenConfig(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Drawable('drawable'), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.Card16('size_id'), rq.Card16('rotation'), rq.Card16('rate'), # added in version 1.1 rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('new_timestamp'), rq.Card32('new_config_timestamp'), rq.Window('root'), rq.Card16('subpixel_order'), rq.Pad(10), ) def set_screen_config(self, size_id, rotation, config_timestamp, rate=0, timestamp=X.CurrentTime): """Sets the screen to the specified size, rate, rotation and reflection. rate can be 0 to have the server select an appropriate rate. """ return SetScreenConfig( display=self.display, opcode=self.display.get_extension_major(extname), drawable=self, timestamp=timestamp, config_timestamp=config_timestamp, size_id=size_id, rotation=rotation, rate=rate, ) class SelectInput(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), rq.Window('window'), rq.Card16('mask'), rq.Pad(2), ) def select_input(self, mask): return SelectInput( display=self.display, opcode=self.display.get_extension_major(extname), window=self, mask=mask, ) class GetScreenInfo(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(5), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('set_of_rotations'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('root'), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.LengthOf('sizes', 2), rq.Card16('size_id'), rq.Card16('rotation'), rq.Card16('rate'), # added in version 1.1 rq.Card16('n_rate_ents'), # XCB's protocol description disagrees with the X headers on this; ignoring. rq.Pad(2), rq.List('sizes', RandR_ScreenSizes), #rq.List('rates', RandR_Rates) #FIXME: Why does uncommenting this cause an error? ) def get_screen_info(self): """Retrieve information about the current and available configurations for the screen associated with this window. """ return GetScreenInfo( display=self.display, opcode=self.display.get_extension_major(extname), window=self, ) # version 1.2 class GetScreenSizeRange(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(6), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('min_width'), rq.Card16('min_height'), rq.Card16('max_width'), rq.Card16('max_height'), rq.Pad(16), ) def get_screen_size_range(self): """Retrieve the range of possible screen sizes. The screen may be set to any size within this range. """ return GetScreenSizeRange( display=self.display, opcode=self.display.get_extension_major(extname), window=self, ) class SetScreenSize(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(7), rq.RequestLength(), rq.Window('window'), rq.Card16('width'), rq.Card16('height'), rq.Card32('width_in_millimeters'), rq.Card32('height_in_millimeters'), ) def set_screen_size(self, width, height, width_in_millimeters=None, height_in_millimeters=None): return SetScreenSize( display=self.display, opcode=self.display.get_extension_major(extname), window=self, width=width, height=height, width_in_millimeters=width_in_millimeters, height_in_millimeters=height_in_millimeters, ) class GetScreenResources(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(8), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.LengthOf('crtcs', 2), rq.LengthOf('outputs', 2), rq.LengthOf('modes', 2), rq.LengthOf('mode_names', 2), rq.Pad(8), rq.List('crtcs', rq.Card32Obj), rq.List('outputs', rq.Card32Obj), rq.List('modes', RandR_ModeInfo), rq.String8('mode_names'), ) def get_screen_resources(self): return GetScreenResources( display=self.display, opcode=self.display.get_extension_major(extname), window=self, ) class GetOutputInfo(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(9), rq.RequestLength(), rq.Card32('output'), rq.Card32('config_timestamp'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('timestamp'), rq.Card32('crtc'), rq.Card32('mm_width'), rq.Card32('mm_height'), rq.Card8('connection'), rq.Card8('subpixel_order'), rq.LengthOf('crtcs', 2), rq.LengthOf('modes', 2), rq.Card16('num_preferred'), rq.LengthOf('clones', 2), rq.LengthOf('name', 2), rq.List('crtcs', rq.Card32Obj), rq.List('modes', rq.Card32Obj), rq.List('clones', rq.Card32Obj), rq.String8('name'), ) def get_output_info(self, output, config_timestamp): return GetOutputInfo( display=self.display, opcode=self.display.get_extension_major(extname), output=output, config_timestamp=config_timestamp, ) class ListOutputProperties(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(10), rq.RequestLength(), rq.Card32('output'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('atoms', 2), rq.Pad(22), rq.List('atoms', rq.Card32Obj), ) def list_output_properties(self, output): return ListOutputProperties ( display=self.display, opcode=self.display.get_extension_major(extname), output=output, ) class QueryOutputProperty(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(11), rq.RequestLength(), rq.Card32('output'), rq.Card32('property'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Bool('pending'), rq.Bool('range'), rq.Bool('immutable'), rq.Pad(21), rq.List('valid_values', rq.Card32Obj), ) def query_output_property(self, output, property): return QueryOutputProperty ( display=self.display, opcode=self.display.get_extension_major(extname), output=output, property=property, ) class ConfigureOutputProperty (rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(12), rq.RequestLength(), rq.Card32('output'), rq.Card32('property'), rq.Bool('pending'), rq.Bool('range'), rq.Pad(2), rq.List('valid_values', rq.Card32Obj), ) def configure_output_property (self, output, property): return ConfigureOutputProperty ( display=self.display, opcode=self.display.get_extension_major(extname), output=output, property=property, ) class ChangeOutputProperty(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(13), rq.RequestLength(), rq.Card32('output'), rq.Card32('property'), rq.Card32('type'), rq.Format('value', 1), rq.Card8('mode'), rq.Pad(2), rq.LengthOf('value', 4), rq.PropertyData('value'), ) def change_output_property(self, output, property, type, mode, value): return ChangeOutputProperty( display=self.display, opcode=self.display.get_extension_major(extname), output=output, property=property, type=type, mode=mode, value=value, ) class DeleteOutputProperty(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(14), rq.RequestLength(), rq.Card32('output'), rq.Card32('property'), ) def delete_output_property(self, output, property): return DeleteOutputProperty( display=self.display, opcode=self.display.get_extension_major(extname), output=output, property=property, ) class GetOutputProperty(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(15), rq.RequestLength(), rq.Card32('output'), rq.Card32('property'), rq.Card32('type'), rq.Card32('long_offset'), rq.Card32('long_length'), rq.Bool('delete'), rq.Bool('pending'), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Format('value', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('property_type'), rq.Card32('bytes_after'), rq.LengthOf('value', 4), rq.Pad(12), rq.List('value', rq.Card8Obj), ) def get_output_property(self, output, property, type, long_offset, long_length, delete=False, pending=False): return GetOutputProperty( display=self.display, opcode=self.display.get_extension_major(extname), output=output, property=property, type=type, long_offset=long_offset, long_length=long_length, delete=delete, pending=pending, ) class CreateMode(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(16), rq.RequestLength(), rq.Window('window'), rq.Object('mode', RandR_ModeInfo), rq.String8('name'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('mode'), rq.Pad(20), ) def create_mode(self, mode, name): return CreateMode ( display=self.display, opcode=self.display.get_extension_major(extname), window=self, mode=mode, name=name, ) class DestroyMode(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(17), rq.RequestLength(), rq.Card32('mode'), ) def destroy_mode(self, mode): return DestroyMode( display=self.display, opcode=self.display.get_extension_major(extname), mode=mode, ) class AddOutputMode(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(18), rq.RequestLength(), rq.Card32('output'), rq.Card32('mode'), ) def add_output_mode(self, output, mode): return AddOutputMode( display=self.display, opcode=self.display.get_extension_major(extname), output=output, mode=mode, ) class DeleteOutputMode(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(19), rq.RequestLength(), rq.Card32('output'), rq.Card32('mode'), ) def delete_output_mode(self, output, mode): return DeleteOutputMode( display=self.display, opcode=self.display.get_extension_major(extname), output=output, mode=mode, ) class GetCrtcInfo(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(20), rq.RequestLength(), rq.Card32('crtc'), rq.Card32('config_timestamp'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('timestamp'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card32('mode'), rq.Card16('rotation'), rq.Card16('possible_rotations'), rq.LengthOf('outputs', 2), rq.LengthOf('possible_outputs', 2), rq.List('outputs', rq.Card32Obj), rq.List('possible_outputs', rq.Card32Obj), ) def get_crtc_info(self, crtc, config_timestamp): return GetCrtcInfo ( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, config_timestamp=config_timestamp, ) class SetCrtcConfig(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(21), rq.RequestLength(), rq.Card32('crtc'), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.Int16('x'), rq.Int16('y'), rq.Card32('mode'), rq.Card16('rotation'), rq.Pad(2), rq.List('outputs', rq.Card32Obj), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('new_timestamp'), rq.Pad(20), ) def set_crtc_config(self, crtc, config_timestamp, x, y, mode, rotation, outputs, timestamp=X.CurrentTime): return SetCrtcConfig ( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, config_timestamp=config_timestamp, x=x, y=y, mode=mode, rotation=rotation, outputs=outputs, timestamp=timestamp, ) class GetCrtcGammaSize(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(22), rq.RequestLength(), rq.Card32('crtc'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('size'), rq.Pad(22), ) def get_crtc_gamma_size(self, crtc): return GetCrtcGammaSize ( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, ) class GetCrtcGamma(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(23), rq.RequestLength(), rq.Card32('crtc'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf(('red', 'green', 'blue'), 2), rq.Pad(22), rq.List('red', rq.Card16Obj), rq.List('green', rq.Card16Obj), rq.List('blue', rq.Card16Obj), ) def get_crtc_gamma(self, crtc): return GetCrtcGamma ( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, ) class SetCrtcGamma(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(24), rq.RequestLength(), rq.Card32('crtc'), rq.Card16('size'), rq.Pad(2), rq.List('red', rq.Card16Obj), rq.List('green', rq.Card16Obj), rq.List('blue', rq.Card16Obj), ) def set_crtc_gamma(self, crtc, size, red, green, blue): return SetCrtcGamma( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, size=size, red=red, green=green, blue=blue, ) # version 1.3 class GetScreenResourcesCurrent(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(25), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.LengthOf('crtcs', 2), rq.LengthOf('outputs', 2), rq.LengthOf('modes', 2), rq.LengthOf('names', 2), rq.Pad(8), rq.List('crtcs', rq.Card32Obj), rq.List('outputs', rq.Card32Obj), rq.List('modes', RandR_ModeInfo), rq.String8('names'), ) def get_screen_resources_current(self): return GetScreenResourcesCurrent( display=self.display, opcode=self.display.get_extension_major(extname), window=self, ) class SetCrtcTransform(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(26), rq.RequestLength(), rq.Card32('crtc'), rq.Object('transform', Render_Transform), rq.LengthOf('filter_name', 2), rq.Pad(2), rq.String8('filter_name'), rq.List('filter_params', rq.Card32Obj), #FIXME: The protocol says FIXED? http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt#n2161 ) def set_crtc_transform(self, crtc, n_bytes_filter): return SetCrtcTransform( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, n_bytes_filter=n_bytes_filter, ) class GetCrtcTransform(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(27), rq.RequestLength(), rq.Card32('crtc'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Object('pending_transform', Render_Transform), rq.Bool('has_transforms'), rq.Pad(3), rq.Object('current_transform', Render_Transform), rq.Pad(4), rq.LengthOf('pending_filter_name', 2), rq.LengthOf('pending_filter_params', 2), rq.LengthOf('current_filter_name', 2), rq.LengthOf('current_filter_params', 2), rq.String8('pending_filter_name'), rq.List('pending_filter_params', rq.Card32Obj), #FIXME: The protocol says FIXED? http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt#n2161 rq.String8('current_filter_name'), rq.List('current_filter_params', rq.Card32Obj), #FIXME: The protocol says FIXED? http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt#n2161 ) def get_crtc_transform(self, crtc): return GetCrtcTransform( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, ) class GetPanning(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(28), rq.RequestLength(), rq.Card32('crtc'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('timestamp'), rq.Card16('left'), rq.Card16('top'), rq.Card16('width'), rq.Card16('height'), rq.Card16('track_left'), rq.Card16('track_top'), rq.Card16('track_width'), rq.Card16('track_height'), rq.Int16('border_left'), rq.Int16('border_top'), rq.Int16('border_right'), rq.Int16('border_bottom'), ) def get_panning(self, crtc): return GetPanning ( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, ) class SetPanning(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(29), rq.RequestLength(), rq.Card32('crtc'), rq.Card32('timestamp'), rq.Card16('left'), rq.Card16('top'), rq.Card16('width'), rq.Card16('height'), rq.Card16('track_left'), rq.Card16('track_top'), rq.Card16('track_width'), rq.Card16('track_height'), rq.Int16('border_left'), rq.Int16('border_top'), rq.Int16('border_right'), rq.Int16('border_bottom'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('new_timestamp'), rq.Pad(20), ) def set_panning(self, crtc, left, top, width, height, track_left, track_top, track_width, track_height, border_left, border_top, border_width, border_height, timestamp=X.CurrentTime): return SetPanning ( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, left=left, top=top, width=width, height=height, track_left=track_left, track_top=track_top, track_width=track_width, track_height=track_height, border_left=border_left, border_top=border_top, border_width=border_width, border_height=border_height, timestamp=timestamp, ) class SetOutputPrimary(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(30), rq.RequestLength(), rq.Window('window'), rq.Card32('output'), ) def set_output_primary(self, output): return SetOutputPrimary( display=self.display, opcode=self.display.get_extension_major(extname), window=self, output=output, ) class GetOutputPrimary(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(31), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('output'), rq.Pad(20), ) def get_output_primary(self): return GetOutputPrimary( display=self.display, opcode=self.display.get_extension_major(extname), window=self, ) # Version 1.5 methods class GetMonitors(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(42), rq.RequestLength(), rq.Window('window'), rq.Bool('is_active'), rq.Pad(3) ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('timestamp'), rq.LengthOf('monitors', 4), rq.Card32('outputs'), rq.Pad(12), rq.List('monitors', MonitorInfo) ) def get_monitors(self, is_active=True): return GetMonitors( display=self.display, opcode=self.display.get_extension_major(extname), window=self, is_active=is_active ) class SetMonitor(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(43), rq.RequestLength(), rq.Window('window'), rq.Object('monitor_info', MonitorInfo) ) def set_monitor(self, monitor_info): return SetMonitor( display=self.display, opcode=self.display.get_extension_major(extname), window=self, monitor_info=monitor_info ) class DeleteMonitor(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(44), rq.RequestLength(), rq.Window('window'), rq.Card32('name') ) def delete_monitor(self, name): return DeleteMonitor( display=self.display, opcode=self.display.get_extension_major(extname), window=self, name=name ) # Events # class ScreenChangeNotify(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('rotation'), rq.Card16('sequence_number'), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.Window('root'), rq.Window('window'), rq.Card16('size_id'), rq.Card16('subpixel_order'), rq.Card16('width_in_pixels'), rq.Card16('height_in_pixels'), rq.Card16('width_in_millimeters'), rq.Card16('height_in_millimeters'), ) class CrtcChangeNotify(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('sub_code'), rq.Card16('sequence_number'), rq.Card32('timestamp'), rq.Window('window'), rq.Card32('crtc'), rq.Card32('mode'), rq.Card16('rotation'), rq.Pad(2), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), ) class OutputChangeNotify(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('sub_code'), rq.Card16('sequence_number'), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.Window('window'), rq.Card32('output'), rq.Card32('crtc'), rq.Card32('mode'), rq.Card16('rotation'), rq.Card8('connection'), rq.Card8('subpixel_order'), ) class OutputPropertyNotify(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('sub_code'), rq.Card16('sequence_number'), rq.Window('window'), rq.Card32('output'), rq.Card32('atom'), rq.Card32('timestamp'), rq.Card8('state'), rq.Pad(11), ) # Initialization # def init(disp, info): disp.extension_add_method('display', 'xrandr_query_version', query_version) disp.extension_add_method('window', 'xrandr_select_input', select_input) disp.extension_add_method('window', 'xrandr_get_screen_info', get_screen_info) disp.extension_add_method('drawable', 'xrandr_1_0set_screen_config', _1_0set_screen_config) disp.extension_add_method('drawable', 'xrandr_set_screen_config', set_screen_config) disp.extension_add_method('window', 'xrandr_get_screen_size_range', get_screen_size_range) disp.extension_add_method('window', 'xrandr_set_screen_size', set_screen_size) disp.extension_add_method('window', 'xrandr_get_screen_resources', get_screen_resources) disp.extension_add_method('display', 'xrandr_get_output_info', get_output_info) disp.extension_add_method('display', 'xrandr_list_output_properties', list_output_properties) disp.extension_add_method('display', 'xrandr_query_output_property', query_output_property) disp.extension_add_method('display', 'xrandr_configure_output_property ', configure_output_property ) disp.extension_add_method('display', 'xrandr_change_output_property', change_output_property) disp.extension_add_method('display', 'xrandr_delete_output_property', delete_output_property) disp.extension_add_method('display', 'xrandr_get_output_property', get_output_property) disp.extension_add_method('window', 'xrandr_create_mode', create_mode) disp.extension_add_method('display', 'xrandr_destroy_mode', destroy_mode) disp.extension_add_method('display', 'xrandr_add_output_mode', add_output_mode) disp.extension_add_method('display', 'xrandr_delete_output_mode', delete_output_mode) disp.extension_add_method('display', 'xrandr_get_crtc_info', get_crtc_info) disp.extension_add_method('display', 'xrandr_set_crtc_config', set_crtc_config) disp.extension_add_method('display', 'xrandr_get_crtc_gamma_size', get_crtc_gamma_size) disp.extension_add_method('display', 'xrandr_get_crtc_gamma', get_crtc_gamma) disp.extension_add_method('display', 'xrandr_set_crtc_gamma', set_crtc_gamma) disp.extension_add_method('window', 'xrandr_get_screen_resources_current', get_screen_resources_current) disp.extension_add_method('display', 'xrandr_set_crtc_transform', set_crtc_transform) disp.extension_add_method('display', 'xrandr_get_crtc_transform', get_crtc_transform) disp.extension_add_method('window', 'xrandr_set_output_primary', set_output_primary) disp.extension_add_method('window', 'xrandr_get_output_primary', get_output_primary) disp.extension_add_method('display', 'xrandr_get_panning', get_panning) disp.extension_add_method('display', 'xrandr_set_panning', set_panning) # If the server is running RANDR 1.5+, enable 1.5 compatible methods and events version = query_version(disp) if version.major_version == 1 and version.minor_version >= 5: # version 1.5 compatible disp.extension_add_method('window', 'xrandr_get_monitors', get_monitors) disp.extension_add_method('window', 'xrandr_set_monitor', set_monitor) disp.extension_add_method('window', 'xrandr_delete_monitor', delete_monitor) disp.extension_add_event(info.first_event + RRScreenChangeNotify, ScreenChangeNotify) # add RRNotify events (1 event code with 3 subcodes) disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_CrtcChange, CrtcChangeNotify) disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputChange, OutputChangeNotify) disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputProperty, OutputPropertyNotify) disp.extension_add_error(BadRROutput, BadRROutputError) disp.extension_add_error(BadRRCrtc, BadRRCrtcError) disp.extension_add_error(BadRRMode, BadRRModeError) python-xlib-0.33/Xlib/ext/record.py000066400000000000000000000222461435211557500172600ustar00rootroot00000000000000# Xlib.ext.record -- RECORD extension module # # Copyright (C) 2006 Alex Badea # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA from Xlib.protocol import rq extname = 'RECORD' FromServerTime = 0x01 FromClientTime = 0x02 FromClientSequence = 0x04 CurrentClients = 1 FutureClients = 2 AllClients = 3 FromServer = 0 FromClient = 1 ClientStarted = 2 ClientDied = 3 StartOfData = 4 EndOfData = 5 Record_Range8 = rq.Struct( rq.Card8('first'), rq.Card8('last')) Record_Range16 = rq.Struct( rq.Card16('first'), rq.Card16('last')) Record_ExtRange = rq.Struct( rq.Card8('major_range_first'), rq.Card8('major_range_last'), rq.Card16('minor_range_first'), rq.Card16('minor_range_last')) Record_Range = rq.Struct( rq.Object('core_requests', Record_Range8), rq.Object('core_replies', Record_Range8), rq.Object('ext_requests', Record_ExtRange), rq.Object('ext_replies', Record_ExtRange), rq.Object('delivered_events', Record_Range8), rq.Object('device_events', Record_Range8), rq.Object('errors', Record_Range8), rq.Bool('client_started'), rq.Bool('client_died')) Record_ClientInfo = rq.Struct( rq.Card32('client_resource'), rq.LengthOf('ranges', 4), rq.List('ranges', Record_Range)) class RawField(rq.ValueField): """A field with raw data, stored as a string""" structcode = None def pack_value(self, val): return val, len(val), None def parse_binary_value(self, data, display, length, format): return data, '' class GetVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card16('major_version'), rq.Card16('minor_version')) _reply = rq.Struct( rq.Pad(2), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('major_version'), rq.Card16('minor_version'), rq.Pad(20)) def get_version(self, major, minor): return GetVersion( display = self.display, opcode = self.display.get_extension_major(extname), major_version = major, minor_version = minor) class CreateContext(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), rq.Card32('context'), # Record_RC rq.Card8('element_header'), # Record_Element_Header rq.Pad(3), rq.LengthOf('clients', 4), rq.LengthOf('ranges', 4), rq.List('clients', rq.Card32Obj), rq.List('ranges', Record_Range)) def create_context(self, datum_flags, clients, ranges): context = self.display.allocate_resource_id() CreateContext( display = self.display, opcode = self.display.get_extension_major(extname), context = context, element_header = datum_flags, clients = clients, ranges = ranges) return context class RegisterClients(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Card32('context'), # Record_RC rq.Card8('element_header'), # Record_Element_Header rq.Pad(3), rq.LengthOf('clients', 4), rq.LengthOf('ranges', 4), rq.List('clients', rq.Card32Obj), rq.List('ranges', Record_Range)) def register_clients(self, context, element_header, clients, ranges): RegisterClients( display = self.display, opcode = self.display.get_extension_major(extname), context = context, element_header = element_header, clients = clients, ranges = ranges) class UnregisterClients(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), rq.Card32('context'), # Record_RC rq.LengthOf('clients', 4), rq.List('clients', rq.Card32Obj)) def unregister_clients(self, context, clients): UnregisterClients( display = self.display, opcode = self.display.get_extension_major(extname), context = context, clients = clients) class GetContext(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), rq.Card32('context')) # Record_RC _reply = rq.Struct( rq.Pad(2), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card8('element_header'), # Record_Element_Header rq.Pad(3), rq.LengthOf('client_info', 4), rq.Pad(16), rq.List('client_info', Record_ClientInfo)) def get_context(self, context): return GetContext( display = self.display, opcode = self.display.get_extension_major(extname), context = context) class EnableContext(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(5), rq.RequestLength(), rq.Card32('context')) # Record_RC _reply = rq.Struct( rq.Pad(1), rq.Card8('category'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card8('element_header'), # Record_Element_Header rq.Bool('client_swapped'), rq.Pad(2), rq.Card32('id_base'), # Record_XIDBase rq.Card32('server_time'), rq.Card32('recorded_sequence_number'), rq.Pad(8), RawField('data')) # This request receives multiple responses, so we need to keep # ourselves in the 'sent_requests' list in order to receive them all. # See the discussion on ListFonstsWithInfo in request.py def __init__(self, callback, *args, **keys): self._callback = callback rq.ReplyRequest.__init__(self, *args, **keys) def _parse_response(self, data): r, d = self._reply.parse_binary(data, self._display) self._callback(r) if r.category == StartOfData: # Hack ourselves a sequence number, used by the code in # Xlib.protocol.display.Display.parse_request_response() self.sequence_number = r.sequence_number if r.category == EndOfData: self._response_lock.acquire() self._data = r self._response_lock.release() else: self._display.sent_requests.insert(0, self) def enable_context(self, context, callback): EnableContext( callback = callback, display = self.display, opcode = self.display.get_extension_major(extname), context = context) class DisableContext(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(6), rq.RequestLength(), rq.Card32('context')) # Record_RC def disable_context(self, context): DisableContext( display = self.display, opcode = self.display.get_extension_major(extname), context = context) class FreeContext(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(7), rq.RequestLength(), rq.Card32('context')) # Record_RC def free_context(self, context): FreeContext( display = self.display, opcode = self.display.get_extension_major(extname), context = context) self.display.free_resource_id(context) def init(disp, info): disp.extension_add_method('display', 'record_get_version', get_version) disp.extension_add_method('display', 'record_create_context', create_context) disp.extension_add_method('display', 'record_register_clients', register_clients) disp.extension_add_method('display', 'record_unregister_clients', unregister_clients) disp.extension_add_method('display', 'record_get_context', get_context) disp.extension_add_method('display', 'record_enable_context', enable_context) disp.extension_add_method('display', 'record_disable_context', disable_context) disp.extension_add_method('display', 'record_free_context', free_context) python-xlib-0.33/Xlib/ext/res.py000066400000000000000000000213741435211557500165740ustar00rootroot00000000000000# Xlib.ext.res -- X-Resource extension module # # Copyright (C) 2021 Aleksei Bavshin # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 51 Franklin Street, # Fifth Floor, # Boston, MA 02110-1301 USA """X-Resource extension allows a client to query the X server about its usage of various resources. For detailed description see any of the following documents. Protocol specification: https://www.x.org/releases/current/doc/resourceproto/resproto.txt XCB Protocol specification: https://cgit.freedesktop.org/xcb/proto/tree/src/res.xml """ from Xlib.protocol import rq RES_MAJOR_VERSION = 1 RES_MINOR_VERSION = 2 extname = "X-Resource" # v1.0 ResQueryVersion = 0 ResQueryClients = 1 ResQueryClientResources = 2 ResQueryClientPixmapBytes = 3 # v1.2 ResQueryClientIds = 4 ResQueryResourceBytes = 5 class QueryVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8("opcode"), rq.Opcode(ResQueryVersion), rq.RequestLength(), rq.Card8("client_major"), rq.Card8("client_minor"), rq.Pad(2)) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16("sequence_number"), rq.ReplyLength(), rq.Card16("server_major"), rq.Card16("server_minor"), rq.Pad(20)) def query_version(self, client_major=RES_MAJOR_VERSION, client_minor=RES_MINOR_VERSION): """ Query the protocol version supported by the X server. The client sends the highest supported version to the server and the server sends the highest version it supports, but no higher than the requested version.""" return QueryVersion( display=self.display, opcode=self.display.get_extension_major(extname), client_major=client_major, client_minor=client_minor) Client = rq.Struct( rq.Card32("resource_base"), rq.Card32("resource_mask")) class QueryClients(rq.ReplyRequest): _request = rq.Struct( rq.Card8("opcode"), rq.Opcode(ResQueryClients), rq.RequestLength()) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16("sequence_number"), rq.ReplyLength(), rq.LengthOf("clients", 4), rq.Pad(20), rq.List("clients", Client)) def query_clients(self): """Request the list of all currently connected clients.""" return QueryClients( display=self.display, opcode=self.display.get_extension_major(extname)) Type = rq.Struct( rq.Card32("resource_type"), rq.Card32("count")) class QueryClientResources(rq.ReplyRequest): _request = rq.Struct( rq.Card8("opcode"), rq.Opcode(ResQueryClientResources), rq.RequestLength(), rq.Card32("client")) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16("sequence_number"), rq.ReplyLength(), rq.LengthOf("types", 4), rq.Pad(20), rq.List("types", Type)) def query_client_resources(self, client): """Request the number of resources owned by a client. The server will return the counts of each type of resource. """ return QueryClientResources( display=self.display, opcode=self.display.get_extension_major(extname), client=client) class QueryClientPixmapBytes(rq.ReplyRequest): _request = rq.Struct( rq.Card8("opcode"), rq.Opcode(ResQueryClientPixmapBytes), rq.RequestLength(), rq.Card32("client")) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16("sequence_number"), rq.ReplyLength(), rq.Card32("bytes"), rq.Card32("bytes_overflow"), rq.Pad(16)) def query_client_pixmap_bytes(self, client): """Query the pixmap usage of some client. The returned number is a sum of memory usage of each pixmap that can be attributed to the given client. """ return QueryClientPixmapBytes( display=self.display, opcode=self.display.get_extension_major(extname), client=client) class SizeOf(rq.LengthOf): """A SizeOf stores the size in bytes of some other Field whose size may vary, e.g. List """ def __init__(self, name, size, item_size): rq.LengthOf.__init__(self, name, size) self.item_size = item_size def parse_value(self, length, display): return length // self.item_size ClientXIDMask = 1 << 0 LocalClientPIDMask = 1 << 1 ClientIdSpec = rq.Struct( rq.Card32("client"), rq.Card32("mask")) ClientIdValue = rq.Struct( rq.Object("spec", ClientIdSpec), SizeOf("value", 4, 4), rq.List("value", rq.Card32Obj)) class QueryClientIds(rq.ReplyRequest): _request = rq.Struct( rq.Card8("opcode"), rq.Opcode(ResQueryClientIds), rq.RequestLength(), rq.LengthOf("specs", 4), rq.List("specs", ClientIdSpec)) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16("sequence_number"), rq.ReplyLength(), rq.LengthOf("ids", 4), rq.Pad(20), rq.List("ids", ClientIdValue)) def query_client_ids(self, specs): """Request to identify a given set of clients with some identification method. The request sends a list of specifiers that select clients and identification methods to server. The server then tries to identify the chosen clients using the identification methods specified for each client. The server returns IDs for those clients that were successfully identified. """ return QueryClientIds( display=self.display, opcode=self.display.get_extension_major(extname), specs=specs) ResourceIdSpec = rq.Struct( rq.Card32("resource"), rq.Card32("type")) ResourceSizeSpec = rq.Struct( # inline struct ResourceIdSpec to work around # a parser bug with nested objects rq.Card32("resource"), rq.Card32("type"), rq.Card32("bytes"), rq.Card32("ref_count"), rq.Card32("use_count")) ResourceSizeValue = rq.Struct( rq.Object("size", ResourceSizeSpec), rq.LengthOf("cross_references", 4), rq.List("cross_references", ResourceSizeSpec)) class QueryResourceBytes(rq.ReplyRequest): _request = rq.Struct( rq.Card8("opcode"), rq.Opcode(ResQueryResourceBytes), rq.RequestLength(), rq.Card32("client"), rq.LengthOf("specs", 4), rq.List("specs", ResourceIdSpec)) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16("sequence_number"), rq.ReplyLength(), rq.LengthOf("sizes", 4), rq.Pad(20), rq.List("sizes", ResourceSizeValue)) def query_resource_bytes(self, client, specs): """Query the sizes of resources from X server. The request sends a list of specifiers that selects resources for size calculation. The server tries to calculate the sizes of chosen resources and returns an estimate for a resource only if the size could be determined """ return QueryResourceBytes( display=self.display, opcode=self.display.get_extension_major(extname), client=client, specs=specs) def init(disp, info): disp.extension_add_method("display", "res_query_version", query_version) disp.extension_add_method("display", "res_query_clients", query_clients) disp.extension_add_method("display", "res_query_client_resources", query_client_resources) disp.extension_add_method("display", "res_query_client_pixmap_bytes", query_client_pixmap_bytes) disp.extension_add_method("display", "res_query_client_ids", query_client_ids) disp.extension_add_method("display", "res_query_resource_bytes", query_resource_bytes) python-xlib-0.33/Xlib/ext/screensaver.py000066400000000000000000000141551435211557500203220ustar00rootroot00000000000000# Xlib.ext.screensaver -- X ScreenSaver extension module # # Copyright (C) 2022 Vladimir Panteleev # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 51 Franklin Street, # Fifth Floor, # Boston, MA 02110-1301 USA """This extension allows registering the client as an X screensaver, or query information about the current screensaver. For detailed description see any of the following documents. Protocol specification: https://www.x.org/releases/X11R7.7/doc/scrnsaverproto/saver.html XCB Protocol specification: https://cgit.freedesktop.org/xcb/proto/tree/src/screensaver.xml """ from Xlib import X from Xlib.protocol import rq, structs extname = 'MIT-SCREEN-SAVER' # Event members NotifyMask = 1 CycleMask = 2 # Notify state StateOff = 0 StateOn = 1 StateCycle = 2 # Notify kind KindBlanked = 0 KindInternal = 1 KindExternal = 2 class QueryVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card8('major_version'), rq.Card8('minor_version'), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('major_version'), rq.Card16('minor_version'), rq.Pad(20), ) def query_version(self): return QueryVersion(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=0) class QueryInfo(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), rq.Drawable('drawable'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('state'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('saver_window'), rq.Card32('til_or_since'), rq.Card32('idle'), rq.Card32('event_mask'), # rq.Set('event_mask', 4, (NotifyMask, CycleMask)), rq.Card8('kind'), rq.Pad(7), ) def query_info(self): return QueryInfo(display=self.display, opcode=self.display.get_extension_major(extname), drawable=self, ) class SelectInput(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Drawable('drawable'), rq.Card32('event_mask'), # rq.Set('event_mask', 4, (NotifyMask, CycleMask)), ) def select_input(self, mask): return SelectInput(display=self.display, opcode=self.display.get_extension_major(extname), drawable=self, event_mask=mask, ) class SetAttributes(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), rq.Drawable('drawable'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('border_width'), rq.Set('window_class', 1, (X.CopyFromParent, X.InputOutput, X.InputOnly)), rq.Card8('depth'), rq.Card32('visual'), structs.WindowValues('attrs'), ) def set_attributes(self, x, y, width, height, border_width, window_class = X.CopyFromParent, depth = X.CopyFromParent, visual = X.CopyFromParent, onerror = None, **keys): return SetAttributes(display=self.display, onerror = onerror, opcode=self.display.get_extension_major(extname), drawable=self, x = x, y = y, width = width, height = height, border_width = border_width, window_class = window_class, depth = depth, visual = visual, attrs = keys) class UnsetAttributes(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), rq.Drawable('drawable'), ) def unset_attributes(self, onerror = None): return UnsetAttributes(display=self.display, onerror = onerror, opcode=self.display.get_extension_major(extname), drawable=self) class Notify(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Set('state', 1, (StateOff, StateOn, StateCycle)), rq.Card16('sequence_number'), rq.Card32('timestamp'), rq.Window('root'), rq.Window('window'), rq.Set('kind', 1, (KindBlanked, KindInternal, KindExternal)), rq.Bool('forced'), rq.Pad(14), ) def init(disp, info): disp.extension_add_method('display', 'screensaver_query_version', query_version) disp.extension_add_method('drawable', 'screensaver_query_info', query_info) disp.extension_add_method('drawable', 'screensaver_select_input', select_input) disp.extension_add_method('drawable', 'screensaver_set_attributes', set_attributes) disp.extension_add_method('drawable', 'screensaver_unset_attributes', unset_attributes) disp.extension_add_event(info.first_event + 0, Notify) python-xlib-0.33/Xlib/ext/security.py000066400000000000000000000116611435211557500176500ustar00rootroot00000000000000# Xlib.ext.security -- SECURITY extension module # # Copyright (C) 2010-2013 Outpost Embedded, LLC # Forest Bond # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA ''' A partial implementation of the SECURITY extension. Support for the SecurityAuthorizationRevoked event is not implemented. ''' from Xlib.protocol import rq extname = 'SECURITY' SecurityClientTrusted = 0 SecurityClientUntrusted = 1 SecurityAuthorizationRevokedMask = 1 AUTHID = rq.Card32 class QueryVersion(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card16('major_version'), rq.Card16('minor_version') ) _reply = rq.Struct(rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('major_version'), rq.Card16('minor_version'), rq.Pad(20) ) def query_version(self): return QueryVersion(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=0) class SecurityGenerateAuthorization(rq.ReplyRequest): # The order of fields here does not match the specifications I've seen # online, but it *does* match with the X.org implementation. I guess the # spec is out-of-date. _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), rq.LengthOf('auth_proto', 2), rq.LengthOf('auth_data', 2), rq.Card32('value_mask'), rq.String8('auth_proto'), rq.Binary('auth_data'), rq.List('values', rq.Card32Obj) ) _reply = rq.Struct(rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), AUTHID('authid'), rq.LengthOf('auth_data_return', 2), rq.Pad(18), rq.Binary('auth_data_return') ) def generate_authorization(self, auth_proto, auth_data=b'', timeout=None, trust_level=None, group=None, event_mask=None): value_mask = 0 values = [] if timeout is not None: value_mask |= 1 values.append(timeout) if trust_level is not None: value_mask |= 2 values.append(trust_level) if group is not None: value_mask |= 4 values.append(group) if event_mask is not None: value_mask |= 8 values.append(event_mask) return SecurityGenerateAuthorization(display=self.display, opcode=self.display.get_extension_major(extname), value_mask=value_mask, auth_proto=auth_proto, auth_data=auth_data, values=values) class SecurityRevokeAuthorization(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), AUTHID('authid') ) def revoke_authorization(self, authid): return SecurityRevokeAuthorization(display=self.display, opcode=self.display.get_extension_major(extname), authid=authid) def init(disp, info): disp.extension_add_method('display', 'security_query_version', query_version) disp.extension_add_method('display', 'security_generate_authorization', generate_authorization) disp.extension_add_method('display', 'security_revoke_authorization', revoke_authorization) python-xlib-0.33/Xlib/ext/shape.py000066400000000000000000000172521435211557500171030ustar00rootroot00000000000000# Automatically generated file; DO NOT EDIT. # Generated from: /usr/share/xcb/shape.xml from Xlib.protocol import rq, structs extname = 'SHAPE' OP = rq.Card8 class SO: Set = 0 Union = 1 Intersect = 2 Subtract = 3 Invert = 4 class SK: Bounding = 0 Clip = 1 Input = 2 class KIND(rq.Set): def __init__(self, name): super(KIND, self).__init__(name, 1, values=(SK.Bounding, SK.Clip, SK.Input)) class NotifyEventData(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), KIND('shape_kind'), rq.Card16('sequence_number'), rq.Window('affected_window'), rq.Int16('extents_x'), rq.Int16('extents_y'), rq.Card16('extents_width'), rq.Card16('extents_height'), rq.Card32('server_time'), rq.Card8('shaped'), rq.Pad(11), ) class QueryVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('major_version'), rq.Card16('minor_version'), ) class Rectangles(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), OP('operation'), KIND('destination_kind'), rq.Card8('ordering'), rq.Pad(1), rq.Window('destination_window'), rq.Int16('x_offset'), rq.Int16('y_offset'), rq.List('rectangles', structs.Rectangle, pad=0), ) class Mask(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), OP('operation'), KIND('destination_kind'), rq.Pad(2), rq.Window('destination_window'), rq.Int16('x_offset'), rq.Int16('y_offset'), rq.Pixmap('source_bitmap'), ) class Combine(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), OP('operation'), KIND('destination_kind'), KIND('source_kind'), rq.Pad(1), rq.Window('destination_window'), rq.Int16('x_offset'), rq.Int16('y_offset'), rq.Window('source_window'), ) class Offset(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), KIND('destination_kind'), rq.Pad(3), rq.Window('destination_window'), rq.Int16('x_offset'), rq.Int16('y_offset'), ) class QueryExtents(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(5), rq.RequestLength(), rq.Window('destination_window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card8('bounding_shaped'), rq.Card8('clip_shaped'), rq.Pad(2), rq.Int16('bounding_shape_extents_x'), rq.Int16('bounding_shape_extents_y'), rq.Card16('bounding_shape_extents_width'), rq.Card16('bounding_shape_extents_height'), rq.Int16('clip_shape_extents_x'), rq.Int16('clip_shape_extents_y'), rq.Card16('clip_shape_extents_width'), rq.Card16('clip_shape_extents_height'), ) class SelectInput(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(6), rq.RequestLength(), rq.Window('destination_window'), rq.Card8('enable'), rq.Pad(3), ) class InputSelected(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(7), rq.RequestLength(), rq.Window('destination_window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('enabled'), rq.Card16('sequence_number'), rq.ReplyLength(), ) class GetRectangles(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(8), rq.RequestLength(), rq.Window('window'), KIND('source_kind'), rq.Pad(3), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('ordering'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('rectangles', 4), rq.Pad(20), rq.List('rectangles', structs.Rectangle, pad=0), ) class Event: # Sub events. Notify = 0 def combine(self, operation, destination_kind, source_kind, x_offset, y_offset): Combine( display=self.display, opcode=self.display.get_extension_major(extname), source_window=self, operation=operation, destination_kind=destination_kind, source_kind=source_kind, x_offset=x_offset, y_offset=y_offset, ) def get_rectangles(self, source_kind): return GetRectangles( display=self.display, opcode=self.display.get_extension_major(extname), window=self, source_kind=source_kind, ) def input_selected(self, ): return InputSelected( display=self.display, opcode=self.display.get_extension_major(extname), destination_window=self, ) def mask(self, operation, destination_kind, x_offset, y_offset, source_bitmap): Mask( display=self.display, opcode=self.display.get_extension_major(extname), destination_window=self, operation=operation, destination_kind=destination_kind, x_offset=x_offset, y_offset=y_offset, source_bitmap=source_bitmap, ) def offset(self, destination_kind, x_offset, y_offset): Offset( display=self.display, opcode=self.display.get_extension_major(extname), destination_window=self, destination_kind=destination_kind, x_offset=x_offset, y_offset=y_offset, ) def query_extents(self, ): return QueryExtents( display=self.display, opcode=self.display.get_extension_major(extname), destination_window=self, ) def query_version(self, ): return QueryVersion( display=self.display, opcode=self.display.get_extension_major(extname), ) def rectangles(self, operation, destination_kind, ordering, x_offset, y_offset, rectangles): Rectangles( display=self.display, opcode=self.display.get_extension_major(extname), destination_window=self, operation=operation, destination_kind=destination_kind, ordering=ordering, x_offset=x_offset, y_offset=y_offset, rectangles=rectangles, ) def select_input(self, enable): SelectInput( display=self.display, opcode=self.display.get_extension_major(extname), destination_window=self, enable=enable, ) def init(disp, info): disp.extension_add_method('window', 'shape_combine', combine) disp.extension_add_method('window', 'shape_get_rectangles', get_rectangles) disp.extension_add_method('window', 'shape_input_selected', input_selected) disp.extension_add_method('window', 'shape_mask', mask) disp.extension_add_method('window', 'shape_offset', offset) disp.extension_add_method('window', 'shape_query_extents', query_extents) disp.extension_add_method('display', 'shape_query_version', query_version) disp.extension_add_method('window', 'shape_rectangles', rectangles) disp.extension_add_method('window', 'shape_select_input', select_input) disp.extension_add_event(info.first_event + Event.Notify, NotifyEventData, 'ShapeNotify') python-xlib-0.33/Xlib/ext/xfixes.py000066400000000000000000000164611435211557500173120ustar00rootroot00000000000000# Xlib.ext.xfixes -- XFIXES extension module # # Copyright (C) 2010-2011 Outpost Embedded, LLC # Forest Bond # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA ''' A partial implementation of the XFIXES extension. Only the HideCursor and ShowCursor requests and SelectionNotify events are provided. ''' from Xlib.protocol import rq extname = 'XFIXES' XFixesSelectionNotify = 0 XFixesCursorNotify = 1 XFixesSetSelectionOwnerNotifyMask = (1 << 0) XFixesSelectionWindowDestroyNotifyMask = (1 << 1) XFixesSelectionClientCloseNotifyMask = (1 << 2) XFixesDisplayCursorNotifyMask = (1 << 0) XFixesSetSelectionOwnerNotify = 0 XFixesSelectionWindowDestroyNotify = 1 XFixesSelectionClientCloseNotify = 2 XFixesDisplayCursorNotify = 0 class QueryVersion(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card32('major_version'), rq.Card32('minor_version') ) _reply = rq.Struct(rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('major_version'), rq.Card32('minor_version'), rq.Pad(16) ) def query_version(self): return QueryVersion(display=self.display, opcode=self.display.get_extension_major(extname), major_version=4, minor_version=0) class HideCursor(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(29), rq.RequestLength(), rq.Window('window') ) def hide_cursor(self): HideCursor(display=self.display, opcode=self.display.get_extension_major(extname), window=self) class ShowCursor(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(30), rq.RequestLength(), rq.Window('window') ) def show_cursor(self): ShowCursor(display=self.display, opcode=self.display.get_extension_major(extname), window=self) class SelectSelectionInput(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Window('window'), rq.Card32('selection'), rq.Card32('mask') ) def select_selection_input(self, window, selection, mask): return SelectSelectionInput(opcode=self.display.get_extension_major(extname), display=self.display, window=window, selection=selection, mask=mask) class SelectionNotify(rq.Event): _code = None _fields = rq.Struct(rq.Card8('type'), rq.Card8('sub_code'), rq.Card16('sequence_number'), rq.Window('window'), rq.Window('owner'), rq.Card32('selection'), rq.Card32('timestamp'), rq.Card32('selection_timestamp'), rq.Pad(8)) class SetSelectionOwnerNotify(SelectionNotify): pass class SelectionWindowDestroyNotify(SelectionNotify): pass class SelectionClientCloseNotify(SelectionNotify): pass class SelectCursorInput(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), rq.Window('window'), rq.Card32('mask') ) def select_cursor_input(self, window, mask): return SelectCursorInput(opcode=self.display.get_extension_major(extname), display=self.display, window=window, cursor_serial=0, mask=mask) class GetCursorImage(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength() ) _reply = rq.Struct(rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('xhot'), rq.Card16('yhot'), rq.Card32('cursor_serial'), rq.Pad(8), rq.List('cursor_image', rq.Card32) ) def get_cursor_image(self, window): return GetCursorImage(opcode=self.display.get_extension_major(extname), display=self.display, ) class DisplayCursorNotify(rq.Event): _code = None _fields = rq.Struct(rq.Card8('type'), rq.Card8('sub_code'), rq.Card16('sequence_number'), rq.Window('window'), rq.Card32('cursor_serial'), rq.Card32('timestamp')) def init(disp, info): disp.extension_add_method('display', 'xfixes_select_selection_input', select_selection_input) disp.extension_add_method('display', 'xfixes_query_version', query_version) disp.extension_add_method('window', 'xfixes_hide_cursor', hide_cursor) disp.extension_add_method('window', 'xfixes_show_cursor', show_cursor) disp.extension_add_method('display', 'xfixes_select_cursor_input', select_cursor_input) disp.extension_add_method('display', 'xfixes_get_cursor_image', get_cursor_image) disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSetSelectionOwnerNotify, SetSelectionOwnerNotify) disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionWindowDestroyNotify, SelectionWindowDestroyNotify) disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionClientCloseNotify, SelectionClientCloseNotify) disp.extension_add_subevent(info.first_event + XFixesCursorNotify, XFixesDisplayCursorNotify, DisplayCursorNotify) python-xlib-0.33/Xlib/ext/xinerama.py000066400000000000000000000154001435211557500176000ustar00rootroot00000000000000# Xlib.ext.xinerama -- Xinerama extension module # # Copyright (C) 2006 Mike Meyer # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA """Xinerama - provide access to the Xinerama extension information. There are at least there different - and mutually incomparable - Xinerama extensions available. This uses the one bundled with XFree86 4.6 and/or Xorg 6.9 in the ati/radeon driver. It uses the include files from that X distribution, so should work with it as well. I provide code for the lone Sun 1.0 request that isn't part of 1.1, but this is untested because I don't have a server that implements it. The functions loosely follow the libXineram functions. Mostly, they return an rq.Struct in lieu of passing in pointers that get data from the rq.Struct crammed into them. The exception is isActive, which returns the state information - because that's what libXinerama does.""" from Xlib.protocol import rq, structs extname = 'XINERAMA' class QueryVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card8('major_version'), rq.Card8('minor_version'), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('major_version'), rq.Card16('minor_version'), rq.Pad(20), ) def query_version(self): return QueryVersion(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=1) class GetState(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Bool('state'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('window'), rq.Pad(20), ) def get_state(self): return GetState(display=self.display, opcode=self.display.get_extension_major(extname), window=self.id, ) class GetScreenCount(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('screen_count'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('window'), rq.Pad(20), ) def get_screen_count(self): return GetScreenCount(display=self.display, opcode=self.display.get_extension_major(extname), window=self.id, ) class GetScreenSize(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), rq.Window('window'), rq.Card32('screen'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.Card32('length'), rq.Card32('width'), rq.Card32('height'), rq.Window('window'), rq.Card32('screen'), rq.Pad(8), ) def get_screen_size(self, screen_no): """Returns the size of the given screen number""" return GetScreenSize(display=self.display, opcode=self.display.get_extension_major(extname), window=self.id, screen=screen_no, ) # IsActive is only available from Xinerama 1.1 and later. # It should be used in preference to GetState. class IsActive(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('state'), rq.Pad(20), ) def is_active(self): r = IsActive(display=self.display, opcode=self.display.get_extension_major(extname), ) return r.state # QueryScreens is only available from Xinerama 1.1 and later class QueryScreens(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(5), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('number'), rq.Pad(20), rq.List('screens', structs.Rectangle), ) def query_screens(self): # Hmm. This one needs to read the screen data from the socket. Ooops... return QueryScreens(display=self.display, opcode=self.display.get_extension_major(extname), ) # GetInfo is only available from some Xinerama 1.0, and *NOT* later! Untested class GetInfo(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), rq.Card32('visual'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('window'), # An array of subwindow slots goes here. Bah. ) def get_info(self, visual): r = GetInfo(display=self.display, opcode=self.display.get_extension_major(extname), visual=visual) def init(disp, info): disp.extension_add_method('display', 'xinerama_query_version', query_version) disp.extension_add_method('window', 'xinerama_get_state', get_state) disp.extension_add_method('window', 'xinerama_get_screen_count', get_screen_count) disp.extension_add_method('window', 'xinerama_get_screen_size', get_screen_size) disp.extension_add_method('display', 'xinerama_is_active', is_active) disp.extension_add_method('display', 'xinerama_query_screens', query_screens) disp.extension_add_method('display', 'xinerama_get_info', get_info) python-xlib-0.33/Xlib/ext/xinput.py000066400000000000000000000501601435211557500173250ustar00rootroot00000000000000# Xlib.ext.xinput -- XInput extension module # # Copyright (C) 2012 Outpost Embedded, LLC # Forest Bond # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA ''' A very incomplete implementation of the XInput extension. ''' import sys import array import struct # Python 2/3 compatibility. from six import integer_types from Xlib.protocol import rq from Xlib import X extname = 'XInputExtension' PropertyDeleted = 0 PropertyCreated = 1 PropertyModified = 2 NotifyNormal = 0 NotifyGrab = 1 NotifyUngrab = 2 NotifyWhileGrabbed = 3 NotifyPassiveGrab = 4 NotifyPassiveUngrab = 5 NotifyAncestor = 0 NotifyVirtual = 1 NotifyInferior = 2 NotifyNonlinear = 3 NotifyNonlinearVirtual = 4 NotifyPointer = 5 NotifyPointerRoot = 6 NotifyDetailNone = 7 GrabtypeButton = 0 GrabtypeKeycode = 1 GrabtypeEnter = 2 GrabtypeFocusIn = 3 GrabtypeTouchBegin = 4 AnyModifier = (1 << 31) AnyButton = 0 AnyKeycode = 0 AsyncDevice = 0 SyncDevice = 1 ReplayDevice = 2 AsyncPairedDevice = 3 AsyncPair = 4 SyncPair = 5 SlaveSwitch = 1 DeviceChange = 2 MasterAdded = (1 << 0) MasterRemoved = (1 << 1) SlaveAdded = (1 << 2) SlaveRemoved = (1 << 3) SlaveAttached = (1 << 4) SlaveDetached = (1 << 5) DeviceEnabled = (1 << 6) DeviceDisabled = (1 << 7) AddMaster = 1 RemoveMaster = 2 AttachSlave = 3 DetachSlave = 4 AttachToMaster = 1 Floating = 2 ModeRelative = 0 ModeAbsolute = 1 MasterPointer = 1 MasterKeyboard = 2 SlavePointer = 3 SlaveKeyboard = 4 FloatingSlave = 5 KeyClass = 0 ButtonClass = 1 ValuatorClass = 2 ScrollClass = 3 TouchClass = 8 KeyRepeat = (1 << 16) AllDevices = 0 AllMasterDevices = 1 DeviceChanged = 1 KeyPress = 2 KeyRelease = 3 ButtonPress = 4 ButtonRelease = 5 Motion = 6 Enter = 7 Leave = 8 FocusIn = 9 FocusOut = 10 HierarchyChanged = 11 PropertyEvent = 12 RawKeyPress = 13 RawKeyRelease = 14 RawButtonPress = 15 RawButtonRelease = 16 RawMotion = 17 DeviceChangedMask = (1 << DeviceChanged) KeyPressMask = (1 << KeyPress) KeyReleaseMask = (1 << KeyRelease) ButtonPressMask = (1 << ButtonPress) ButtonReleaseMask = (1 << ButtonRelease) MotionMask = (1 << Motion) EnterMask = (1 << Enter) LeaveMask = (1 << Leave) FocusInMask = (1 << FocusIn) FocusOutMask = (1 << FocusOut) HierarchyChangedMask = (1 << HierarchyChanged) PropertyEventMask = (1 << PropertyEvent) RawKeyPressMask = (1 << RawKeyPress) RawKeyReleaseMask = (1 << RawKeyRelease) RawButtonPressMask = (1 << RawButtonPress) RawButtonReleaseMask = (1 << RawButtonRelease) RawMotionMask = (1 << RawMotion) GrabModeSync = 0 GrabModeAsync = 1 GrabModeTouch = 2 DEVICEID = rq.Card16 DEVICE = rq.Card16 DEVICEUSE = rq.Card8 PROPERTY_TYPE_FLOAT = 'FLOAT' class FP1616(rq.Int32): def check_value(self, value): return int(value * 65536.0) def parse_value(self, value, display): return float(value) / float(1 << 16) class FP3232(rq.ValueField): structcode = 'lL' structvalues = 2 def check_value(self, value): return value def parse_value(self, value, display): integral, frac = value ret = float(integral) # optimised math.ldexp(float(frac), -32) ret += float(frac) * (1.0 / (1 << 32)) return ret class XIQueryVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(47), rq.RequestLength(), rq.Card16('major_version'), rq.Card16('minor_version'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('major_version'), rq.Card16('minor_version'), rq.Pad(20), ) def query_version(self): return XIQueryVersion( display=self.display, opcode=self.display.get_extension_major(extname), major_version=2, minor_version=0, ) class Mask(rq.List): def __init__(self, name): rq.List.__init__(self, name, rq.Card32, pad=0) def pack_value(self, val): mask_seq = array.array(rq.struct_to_array_codes['L']) if isinstance(val, integer_types): # We need to build a "binary mask" that (as far as I can tell) is # encoded in native byte order from end to end. The simple case is # with a single unsigned 32-bit value, for which we construct an # array with just one item. For values too big to fit inside 4 # bytes we build a longer array, being careful to maintain native # byte order across the entire set of values. if sys.byteorder == 'little': def fun(val): mask_seq.insert(0, val) elif sys.byteorder == 'big': fun = mask_seq.append else: raise AssertionError(sys.byteorder) while val: fun(val & 0xFFFFFFFF) val = val >> 32 else: mask_seq.extend(val) return rq.encode_array(mask_seq), len(mask_seq), None EventMask = rq.Struct( DEVICE('deviceid'), rq.LengthOf('mask', 2), Mask('mask'), ) class XISelectEvents(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(46), rq.RequestLength(), rq.Window('window'), rq.LengthOf('masks', 2), rq.Pad(2), rq.List('masks', EventMask), ) def select_events(self, event_masks): ''' select_events(event_masks) event_masks: Sequence of (deviceid, mask) pairs, where deviceid is a numerical device ID, or AllDevices or AllMasterDevices, and mask is either an unsigned integer or sequence of 32 bits unsigned values ''' return XISelectEvents( display=self.display, opcode=self.display.get_extension_major(extname), window=self, masks=event_masks, ) AnyInfo = rq.Struct( rq.Card16('type'), rq.Card16('length'), rq.Card16('sourceid'), rq.Pad(2), ) class ButtonMask(object): def __init__(self, value, length): self._value = value self._length = length def __len__(self): return self._length def __getitem__(self, key): return self._value & (1 << key) def __str__(self): return repr(self) def __repr__(self): return '0b{value:0{width}b}'.format(value=self._value, width=self._length) class ButtonState(rq.ValueField): structcode = None def __init__(self, name): rq.ValueField.__init__(self, name) def parse_binary_value(self, data, display, length, fmt): # Mask: bitfield of button states. mask_len = 4 * ((((length + 7) >> 3) + 3) >> 2) mask_data = data[:mask_len] mask_value = 0 for byte in reversed(struct.unpack('={0:d}B'.format(mask_len), mask_data)): mask_value <<= 8 mask_value |= byte data = data[mask_len:] assert (mask_value & 1) == 0 return ButtonMask(mask_value >> 1, length), data ButtonInfo = rq.Struct( rq.Card16('type'), rq.Card16('length'), rq.Card16('sourceid'), rq.LengthOf(('state', 'labels'), 2), ButtonState('state'), rq.List('labels', rq.Card32), ) KeyInfo = rq.Struct( rq.Card16('type'), rq.Card16('length'), rq.Card16('sourceid'), rq.LengthOf('keycodes', 2), rq.List('keycodes', rq.Card32), ) ValuatorInfo = rq.Struct( rq.Card16('type'), rq.Card16('length'), rq.Card16('sourceid'), rq.Card16('number'), rq.Card32('label'), FP3232('min'), FP3232('max'), FP3232('value'), rq.Card32('resolution'), rq.Card8('mode'), rq.Pad(3), ) ScrollInfo = rq.Struct( rq.Card16('type'), rq.Card16('length'), rq.Card16('sourceid'), rq.Card16('number'), rq.Card16('scroll_type'), rq.Pad(2), rq.Card32('flags'), FP3232('increment'), ) TouchInfo = rq.Struct( rq.Card16('type'), rq.Card16('length'), rq.Card16('sourceid'), rq.Card8('mode'), rq.Card8('num_touches'), ) INFO_CLASSES = { KeyClass: KeyInfo, ButtonClass: ButtonInfo, ValuatorClass: ValuatorInfo, ScrollClass: ScrollInfo, TouchClass: TouchInfo, } class ClassInfoClass(object): structcode = None def parse_binary(self, data, display): class_type, length = struct.unpack('=HH', data[:4]) class_struct = INFO_CLASSES.get(class_type, AnyInfo) class_data, _ = class_struct.parse_binary(data, display) data = data[length * 4:] return class_data, data ClassInfo = ClassInfoClass() DeviceInfo = rq.Struct( DEVICEID('deviceid'), rq.Card16('use'), rq.Card16('attachment'), rq.LengthOf('classes', 2), rq.LengthOf('name', 2), rq.Bool('enabled'), rq.Pad(1), rq.String8('name', 4), rq.List('classes', ClassInfo), ) class XIQueryDevice(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(48), rq.RequestLength(), DEVICEID('deviceid'), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('devices', 2), rq.Pad(22), rq.List('devices', DeviceInfo), ) def query_device(self, deviceid): return XIQueryDevice( display=self.display, opcode=self.display.get_extension_major(extname), deviceid=deviceid, ) class XIListProperties(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(56), rq.RequestLength(), DEVICEID('deviceid'), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('atoms', 2), rq.Pad(22), rq.List('atoms', rq.Card32Obj), ) def list_device_properties(self, deviceid): return XIListProperties( display=self.display, opcode=self.display.get_extension_major(extname), deviceid=deviceid, ) class XIGetProperty(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(59), rq.RequestLength(), DEVICEID('deviceid'), rq.Card8('delete'), rq.Pad(1), rq.Card32('property'), rq.Card32('type'), rq.Card32('offset'), rq.Card32('length'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('type'), rq.Card32('bytes_after'), rq.LengthOf('value', 4), rq.Format('value', 1), rq.Pad(11), rq.PropertyData('value') ) def get_device_property(self, deviceid, property, type, offset, length, delete=False): return XIGetProperty( display=self.display, opcode=self.display.get_extension_major(extname), deviceid=deviceid, property=property, type=type, offset=offset, length=length, delete=delete, ) class XIChangeProperty(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(57), rq.RequestLength(), DEVICEID('deviceid'), rq.Card8('mode'), rq.Format('value', 1), rq.Card32('property'), rq.Card32('type'), rq.LengthOf('value', 4), rq.PropertyData('value'), ) def change_device_property(self, deviceid, property, type, mode, value): return XIChangeProperty( display=self.display, opcode=self.display.get_extension_major(extname), deviceid=deviceid, property=property, type=type, mode=mode, value=value, ) class XIDeleteProperty(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(58), rq.RequestLength(), DEVICEID('deviceid'), rq.Pad(2), rq.Card32('property'), ) def delete_device_property(self, deviceid, property): return XIDeleteProperty( display=self.display, opcode=self.display.get_extension_major(extname), deviceid=deviceid, property=property, ) class XIGrabDevice(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(51), rq.RequestLength(), rq.Window('grab_window'), rq.Card32('time'), rq.Cursor('cursor', (X.NONE, )), DEVICEID('deviceid'), rq.Set('grab_mode', 1, (GrabModeSync, GrabModeAsync)), rq.Set('paired_device_mode', 1, (GrabModeSync, GrabModeAsync)), rq.Bool('owner_events'), rq.Pad(1), rq.LengthOf('mask', 2), Mask('mask'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card8('status'), rq.Pad(23), ) def grab_device(self, deviceid, time, grab_mode, paired_device_mode, owner_events, event_mask): return XIGrabDevice( display=self.display, opcode=self.display.get_extension_major(extname), deviceid=deviceid, grab_window=self, time=time, cursor=X.NONE, grab_mode=grab_mode, paired_device_mode=paired_device_mode, owner_events=owner_events, mask=event_mask, ) class XIUngrabDevice(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(52), rq.RequestLength(), rq.Card32('time'), DEVICEID('deviceid'), rq.Pad(2), ) def ungrab_device(self, deviceid, time): return XIUngrabDevice( display=self.display, opcode=self.display.get_extension_major(extname), time=time, deviceid=deviceid, ) class XIPassiveGrabDevice(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(54), rq.RequestLength(), rq.Card32('time'), rq.Window('grab_window'), rq.Cursor('cursor', (X.NONE, )), rq.Card32('detail'), DEVICEID('deviceid'), rq.LengthOf('modifiers', 2), rq.LengthOf('mask', 2), rq.Set('grab_type', 1, (GrabtypeButton, GrabtypeKeycode, GrabtypeEnter, GrabtypeFocusIn, GrabtypeTouchBegin)), rq.Set('grab_mode', 1, (GrabModeSync, GrabModeAsync)), rq.Set('paired_device_mode', 1, (GrabModeSync, GrabModeAsync)), rq.Bool('owner_events'), rq.Pad(2), Mask('mask'), rq.List('modifiers', rq.Card32), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('modifiers', 2), rq.Pad(22), rq.List('modifiers', rq.Card32), ) def passive_grab_device(self, deviceid, time, detail, grab_type, grab_mode, paired_device_mode, owner_events, event_mask, modifiers): return XIPassiveGrabDevice( display=self.display, opcode=self.display.get_extension_major(extname), deviceid=deviceid, grab_window=self, time=time, cursor=X.NONE, detail=detail, grab_type=grab_type, grab_mode=grab_mode, paired_device_mode=paired_device_mode, owner_events=owner_events, mask=event_mask, modifiers=modifiers, ) def grab_keycode(self, deviceid, time, keycode, grab_mode, paired_device_mode, owner_events, event_mask, modifiers): return passive_grab_device(self, deviceid, time, keycode, GrabtypeKeycode, grab_mode, paired_device_mode, owner_events, event_mask, modifiers) class XIPassiveUngrabDevice(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(55), rq.RequestLength(), rq.Window('grab_window'), rq.Card32('detail'), DEVICEID('deviceid'), rq.LengthOf('modifiers', 2), rq.Set('grab_type', 1, (GrabtypeButton, GrabtypeKeycode, GrabtypeEnter, GrabtypeFocusIn, GrabtypeTouchBegin)), rq.Pad(3), rq.List('modifiers', rq.Card32), ) def passive_ungrab_device(self, deviceid, detail, grab_type, modifiers): return XIPassiveUngrabDevice( display=self.display, opcode=self.display.get_extension_major(extname), deviceid=deviceid, grab_window=self, detail=detail, grab_type=grab_type, modifiers=modifiers, ) def ungrab_keycode(self, deviceid, keycode, modifiers): return passive_ungrab_device(self, deviceid, keycode, GrabtypeKeycode, modifiers) HierarchyInfo = rq.Struct( DEVICEID('deviceid'), DEVICEID('attachment'), DEVICEUSE('type'), rq.Bool('enabled'), rq.Pad(2), rq.Card32('flags'), ) HierarchyEventData = rq.Struct( DEVICEID('deviceid'), rq.Card32('time'), rq.Card32('flags'), rq.LengthOf('info', 2), rq.Pad(10), rq.List('info', HierarchyInfo), ) ModifierInfo = rq.Struct( rq.Card32('base_mods'), rq.Card32('latched_mods'), rq.Card32('locked_mods'), rq.Card32('effective_mods'), ) GroupInfo = rq.Struct( rq.Card8('base_group'), rq.Card8('latched_group'), rq.Card8('locked_group'), rq.Card8('effective_group'), ) DeviceEventData = rq.Struct( DEVICEID('deviceid'), rq.Card32('time'), rq.Card32('detail'), rq.Window('root'), rq.Window('event'), rq.Window('child'), FP1616('root_x'), FP1616('root_y'), FP1616('event_x'), FP1616('event_y'), rq.LengthOf('buttons', 2), rq.Card16('valulators_len'), DEVICEID('sourceid'), rq.Pad(2), rq.Card32('flags'), rq.Object('mods', ModifierInfo), rq.Object('groups', GroupInfo), ButtonState('buttons'), ) DeviceChangedEventData = rq.Struct( DEVICEID('deviceid'), rq.Card32('time'), rq.LengthOf('classes', 2), DEVICEID('sourceid'), rq.Card8('reason'), rq.Pad(11), rq.List('classes', ClassInfo), ) PropertyEventData = rq.Struct( DEVICEID('deviceid'), rq.Card32('time'), rq.Card32('property'), rq.Card8('what'), rq.Pad(11), ) def init(disp, info): disp.extension_add_method('display', 'xinput_query_version', query_version) disp.extension_add_method('window', 'xinput_select_events', select_events) disp.extension_add_method('display', 'xinput_query_device', query_device) disp.extension_add_method('window', 'xinput_grab_device', grab_device) disp.extension_add_method('display', 'xinput_ungrab_device', ungrab_device) disp.extension_add_method('window', 'xinput_grab_keycode', grab_keycode) disp.extension_add_method('window', 'xinput_ungrab_keycode', ungrab_keycode) disp.extension_add_method('display', 'xinput_get_device_property', get_device_property) disp.extension_add_method('display', 'xinput_list_device_properties', list_device_properties) disp.extension_add_method('display', 'xinput_change_device_property', change_device_property) disp.extension_add_method('display', 'xinput_delete_device_property', delete_device_property) if hasattr(disp,"ge_add_event_data"): for device_event in (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion): disp.ge_add_event_data(info.major_opcode, device_event, DeviceEventData) disp.ge_add_event_data(info.major_opcode, DeviceChanged, DeviceEventData) disp.ge_add_event_data(info.major_opcode, HierarchyChanged, HierarchyEventData) disp.ge_add_event_data(info.major_opcode, PropertyEvent, PropertyEventData) python-xlib-0.33/Xlib/ext/xtest.py000066400000000000000000000107241435211557500171470ustar00rootroot00000000000000# Xlib.ext.xtest -- XTEST extension module # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA from Xlib import X from Xlib.protocol import rq extname = 'XTEST' CurrentCursor = 1 class GetVersion(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card8('major_version'), rq.Pad(1), rq.Card16('minor_version') ) _reply = rq.Struct(rq.Pad(1), rq.Card8('major_version'), rq.Card16('sequence_number'), rq.Pad(4), rq.Card16('minor_version'), rq.Pad(22) ) def get_version(self, major, minor): return GetVersion(display = self.display, opcode = self.display.get_extension_major(extname), major_version = major, minor_version = minor) class CompareCursor(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), rq.Window('window'), rq.Cursor('cursor', (X.NONE, CurrentCursor)), ) _reply = rq.Struct(rq.Pad(1), rq.Card8('same'), rq.Card16('sequence_number'), rq.Pad(28), ) def compare_cursor(self, cursor): r = CompareCursor(display = self.display, opcode = self.display.get_extension_major(extname), window = self.id, cursor = cursor) return r.same class FakeInput(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Set('event_type', 1, (X.KeyPress, X.KeyRelease, X.ButtonPress, X.ButtonRelease, X.MotionNotify)), rq.Card8('detail'), rq.Pad(2), rq.Card32('time'), rq.Window('root', (X.NONE, )), rq.Pad(8), rq.Int16('x'), rq.Int16('y'), rq.Pad(8) ) def fake_input(self, event_type, detail = 0, time = X.CurrentTime, root = X.NONE, x = 0, y = 0): FakeInput(display = self.display, opcode = self.display.get_extension_major(extname), event_type = event_type, detail = detail, time = time, root = root, x = x, y = y) class GrabControl(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), rq.Bool('impervious'), rq.Pad(3) ) def grab_control(self, impervious): GrabControl(display = self.display, opcode = self.display.get_extension_major(extname), impervious = impervious) def init(disp, info): disp.extension_add_method('display', 'xtest_get_version', get_version) disp.extension_add_method('window', 'xtest_compare_cursor', compare_cursor) disp.extension_add_method('display', 'xtest_fake_input', fake_input) disp.extension_add_method('display', 'xtest_grab_control', grab_control) python-xlib-0.33/Xlib/keysymdef/000077500000000000000000000000001435211557500166225ustar00rootroot00000000000000python-xlib-0.33/Xlib/keysymdef/__init__.py000066400000000000000000000021511435211557500207320ustar00rootroot00000000000000# Xlib.keysymdef -- X keysym defs # # Copyright (C) 2001 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA __all__ = [ 'apl', 'arabic', 'cyrillic', 'greek', 'hebrew', 'katakana', 'korean', 'latin1', 'latin2', 'latin3', 'latin4', 'miscellany', 'publishing', 'special', 'technical', 'thai', 'xf86', 'xk3270', 'xkb', ] python-xlib-0.33/Xlib/keysymdef/apl.py000066400000000000000000000005611435211557500177520ustar00rootroot00000000000000XK_leftcaret = 0xba3 XK_rightcaret = 0xba6 XK_downcaret = 0xba8 XK_upcaret = 0xba9 XK_overbar = 0xbc0 XK_downtack = 0xbc2 XK_upshoe = 0xbc3 XK_downstile = 0xbc4 XK_underbar = 0xbc6 XK_jot = 0xbca XK_quad = 0xbcc XK_uptack = 0xbce XK_circle = 0xbcf XK_upstile = 0xbd3 XK_downshoe = 0xbd6 XK_rightshoe = 0xbd8 XK_leftshoe = 0xbda XK_lefttack = 0xbdc XK_righttack = 0xbfc python-xlib-0.33/Xlib/keysymdef/arabic.py000066400000000000000000000023051435211557500204150ustar00rootroot00000000000000XK_Arabic_comma = 0x5ac XK_Arabic_semicolon = 0x5bb XK_Arabic_question_mark = 0x5bf XK_Arabic_hamza = 0x5c1 XK_Arabic_maddaonalef = 0x5c2 XK_Arabic_hamzaonalef = 0x5c3 XK_Arabic_hamzaonwaw = 0x5c4 XK_Arabic_hamzaunderalef = 0x5c5 XK_Arabic_hamzaonyeh = 0x5c6 XK_Arabic_alef = 0x5c7 XK_Arabic_beh = 0x5c8 XK_Arabic_tehmarbuta = 0x5c9 XK_Arabic_teh = 0x5ca XK_Arabic_theh = 0x5cb XK_Arabic_jeem = 0x5cc XK_Arabic_hah = 0x5cd XK_Arabic_khah = 0x5ce XK_Arabic_dal = 0x5cf XK_Arabic_thal = 0x5d0 XK_Arabic_ra = 0x5d1 XK_Arabic_zain = 0x5d2 XK_Arabic_seen = 0x5d3 XK_Arabic_sheen = 0x5d4 XK_Arabic_sad = 0x5d5 XK_Arabic_dad = 0x5d6 XK_Arabic_tah = 0x5d7 XK_Arabic_zah = 0x5d8 XK_Arabic_ain = 0x5d9 XK_Arabic_ghain = 0x5da XK_Arabic_tatweel = 0x5e0 XK_Arabic_feh = 0x5e1 XK_Arabic_qaf = 0x5e2 XK_Arabic_kaf = 0x5e3 XK_Arabic_lam = 0x5e4 XK_Arabic_meem = 0x5e5 XK_Arabic_noon = 0x5e6 XK_Arabic_ha = 0x5e7 XK_Arabic_heh = 0x5e7 XK_Arabic_waw = 0x5e8 XK_Arabic_alefmaksura = 0x5e9 XK_Arabic_yeh = 0x5ea XK_Arabic_fathatan = 0x5eb XK_Arabic_dammatan = 0x5ec XK_Arabic_kasratan = 0x5ed XK_Arabic_fatha = 0x5ee XK_Arabic_damma = 0x5ef XK_Arabic_kasra = 0x5f0 XK_Arabic_shadda = 0x5f1 XK_Arabic_sukun = 0x5f2 XK_Arabic_switch = 0xFF7E python-xlib-0.33/Xlib/keysymdef/cyrillic.py000066400000000000000000000047541435211557500210200ustar00rootroot00000000000000XK_Serbian_dje = 0x6a1 XK_Macedonia_gje = 0x6a2 XK_Cyrillic_io = 0x6a3 XK_Ukrainian_ie = 0x6a4 XK_Ukranian_je = 0x6a4 XK_Macedonia_dse = 0x6a5 XK_Ukrainian_i = 0x6a6 XK_Ukranian_i = 0x6a6 XK_Ukrainian_yi = 0x6a7 XK_Ukranian_yi = 0x6a7 XK_Cyrillic_je = 0x6a8 XK_Serbian_je = 0x6a8 XK_Cyrillic_lje = 0x6a9 XK_Serbian_lje = 0x6a9 XK_Cyrillic_nje = 0x6aa XK_Serbian_nje = 0x6aa XK_Serbian_tshe = 0x6ab XK_Macedonia_kje = 0x6ac XK_Byelorussian_shortu = 0x6ae XK_Cyrillic_dzhe = 0x6af XK_Serbian_dze = 0x6af XK_numerosign = 0x6b0 XK_Serbian_DJE = 0x6b1 XK_Macedonia_GJE = 0x6b2 XK_Cyrillic_IO = 0x6b3 XK_Ukrainian_IE = 0x6b4 XK_Ukranian_JE = 0x6b4 XK_Macedonia_DSE = 0x6b5 XK_Ukrainian_I = 0x6b6 XK_Ukranian_I = 0x6b6 XK_Ukrainian_YI = 0x6b7 XK_Ukranian_YI = 0x6b7 XK_Cyrillic_JE = 0x6b8 XK_Serbian_JE = 0x6b8 XK_Cyrillic_LJE = 0x6b9 XK_Serbian_LJE = 0x6b9 XK_Cyrillic_NJE = 0x6ba XK_Serbian_NJE = 0x6ba XK_Serbian_TSHE = 0x6bb XK_Macedonia_KJE = 0x6bc XK_Byelorussian_SHORTU = 0x6be XK_Cyrillic_DZHE = 0x6bf XK_Serbian_DZE = 0x6bf XK_Cyrillic_yu = 0x6c0 XK_Cyrillic_a = 0x6c1 XK_Cyrillic_be = 0x6c2 XK_Cyrillic_tse = 0x6c3 XK_Cyrillic_de = 0x6c4 XK_Cyrillic_ie = 0x6c5 XK_Cyrillic_ef = 0x6c6 XK_Cyrillic_ghe = 0x6c7 XK_Cyrillic_ha = 0x6c8 XK_Cyrillic_i = 0x6c9 XK_Cyrillic_shorti = 0x6ca XK_Cyrillic_ka = 0x6cb XK_Cyrillic_el = 0x6cc XK_Cyrillic_em = 0x6cd XK_Cyrillic_en = 0x6ce XK_Cyrillic_o = 0x6cf XK_Cyrillic_pe = 0x6d0 XK_Cyrillic_ya = 0x6d1 XK_Cyrillic_er = 0x6d2 XK_Cyrillic_es = 0x6d3 XK_Cyrillic_te = 0x6d4 XK_Cyrillic_u = 0x6d5 XK_Cyrillic_zhe = 0x6d6 XK_Cyrillic_ve = 0x6d7 XK_Cyrillic_softsign = 0x6d8 XK_Cyrillic_yeru = 0x6d9 XK_Cyrillic_ze = 0x6da XK_Cyrillic_sha = 0x6db XK_Cyrillic_e = 0x6dc XK_Cyrillic_shcha = 0x6dd XK_Cyrillic_che = 0x6de XK_Cyrillic_hardsign = 0x6df XK_Cyrillic_YU = 0x6e0 XK_Cyrillic_A = 0x6e1 XK_Cyrillic_BE = 0x6e2 XK_Cyrillic_TSE = 0x6e3 XK_Cyrillic_DE = 0x6e4 XK_Cyrillic_IE = 0x6e5 XK_Cyrillic_EF = 0x6e6 XK_Cyrillic_GHE = 0x6e7 XK_Cyrillic_HA = 0x6e8 XK_Cyrillic_I = 0x6e9 XK_Cyrillic_SHORTI = 0x6ea XK_Cyrillic_KA = 0x6eb XK_Cyrillic_EL = 0x6ec XK_Cyrillic_EM = 0x6ed XK_Cyrillic_EN = 0x6ee XK_Cyrillic_O = 0x6ef XK_Cyrillic_PE = 0x6f0 XK_Cyrillic_YA = 0x6f1 XK_Cyrillic_ER = 0x6f2 XK_Cyrillic_ES = 0x6f3 XK_Cyrillic_TE = 0x6f4 XK_Cyrillic_U = 0x6f5 XK_Cyrillic_ZHE = 0x6f6 XK_Cyrillic_VE = 0x6f7 XK_Cyrillic_SOFTSIGN = 0x6f8 XK_Cyrillic_YERU = 0x6f9 XK_Cyrillic_ZE = 0x6fa XK_Cyrillic_SHA = 0x6fb XK_Cyrillic_E = 0x6fc XK_Cyrillic_SHCHA = 0x6fd XK_Cyrillic_CHE = 0x6fe XK_Cyrillic_HARDSIGN = 0x6ff python-xlib-0.33/Xlib/keysymdef/greek.py000066400000000000000000000034601435211557500202740ustar00rootroot00000000000000XK_Greek_ALPHAaccent = 0x7a1 XK_Greek_EPSILONaccent = 0x7a2 XK_Greek_ETAaccent = 0x7a3 XK_Greek_IOTAaccent = 0x7a4 XK_Greek_IOTAdiaeresis = 0x7a5 XK_Greek_OMICRONaccent = 0x7a7 XK_Greek_UPSILONaccent = 0x7a8 XK_Greek_UPSILONdieresis = 0x7a9 XK_Greek_OMEGAaccent = 0x7ab XK_Greek_accentdieresis = 0x7ae XK_Greek_horizbar = 0x7af XK_Greek_alphaaccent = 0x7b1 XK_Greek_epsilonaccent = 0x7b2 XK_Greek_etaaccent = 0x7b3 XK_Greek_iotaaccent = 0x7b4 XK_Greek_iotadieresis = 0x7b5 XK_Greek_iotaaccentdieresis = 0x7b6 XK_Greek_omicronaccent = 0x7b7 XK_Greek_upsilonaccent = 0x7b8 XK_Greek_upsilondieresis = 0x7b9 XK_Greek_upsilonaccentdieresis = 0x7ba XK_Greek_omegaaccent = 0x7bb XK_Greek_ALPHA = 0x7c1 XK_Greek_BETA = 0x7c2 XK_Greek_GAMMA = 0x7c3 XK_Greek_DELTA = 0x7c4 XK_Greek_EPSILON = 0x7c5 XK_Greek_ZETA = 0x7c6 XK_Greek_ETA = 0x7c7 XK_Greek_THETA = 0x7c8 XK_Greek_IOTA = 0x7c9 XK_Greek_KAPPA = 0x7ca XK_Greek_LAMDA = 0x7cb XK_Greek_LAMBDA = 0x7cb XK_Greek_MU = 0x7cc XK_Greek_NU = 0x7cd XK_Greek_XI = 0x7ce XK_Greek_OMICRON = 0x7cf XK_Greek_PI = 0x7d0 XK_Greek_RHO = 0x7d1 XK_Greek_SIGMA = 0x7d2 XK_Greek_TAU = 0x7d4 XK_Greek_UPSILON = 0x7d5 XK_Greek_PHI = 0x7d6 XK_Greek_CHI = 0x7d7 XK_Greek_PSI = 0x7d8 XK_Greek_OMEGA = 0x7d9 XK_Greek_alpha = 0x7e1 XK_Greek_beta = 0x7e2 XK_Greek_gamma = 0x7e3 XK_Greek_delta = 0x7e4 XK_Greek_epsilon = 0x7e5 XK_Greek_zeta = 0x7e6 XK_Greek_eta = 0x7e7 XK_Greek_theta = 0x7e8 XK_Greek_iota = 0x7e9 XK_Greek_kappa = 0x7ea XK_Greek_lamda = 0x7eb XK_Greek_lambda = 0x7eb XK_Greek_mu = 0x7ec XK_Greek_nu = 0x7ed XK_Greek_xi = 0x7ee XK_Greek_omicron = 0x7ef XK_Greek_pi = 0x7f0 XK_Greek_rho = 0x7f1 XK_Greek_sigma = 0x7f2 XK_Greek_finalsmallsigma = 0x7f3 XK_Greek_tau = 0x7f4 XK_Greek_upsilon = 0x7f5 XK_Greek_phi = 0x7f6 XK_Greek_chi = 0x7f7 XK_Greek_psi = 0x7f8 XK_Greek_omega = 0x7f9 XK_Greek_switch = 0xFF7E python-xlib-0.33/Xlib/keysymdef/hebrew.py000066400000000000000000000016751435211557500204610ustar00rootroot00000000000000XK_hebrew_doublelowline = 0xcdf XK_hebrew_aleph = 0xce0 XK_hebrew_bet = 0xce1 XK_hebrew_beth = 0xce1 XK_hebrew_gimel = 0xce2 XK_hebrew_gimmel = 0xce2 XK_hebrew_dalet = 0xce3 XK_hebrew_daleth = 0xce3 XK_hebrew_he = 0xce4 XK_hebrew_waw = 0xce5 XK_hebrew_zain = 0xce6 XK_hebrew_zayin = 0xce6 XK_hebrew_chet = 0xce7 XK_hebrew_het = 0xce7 XK_hebrew_tet = 0xce8 XK_hebrew_teth = 0xce8 XK_hebrew_yod = 0xce9 XK_hebrew_finalkaph = 0xcea XK_hebrew_kaph = 0xceb XK_hebrew_lamed = 0xcec XK_hebrew_finalmem = 0xced XK_hebrew_mem = 0xcee XK_hebrew_finalnun = 0xcef XK_hebrew_nun = 0xcf0 XK_hebrew_samech = 0xcf1 XK_hebrew_samekh = 0xcf1 XK_hebrew_ayin = 0xcf2 XK_hebrew_finalpe = 0xcf3 XK_hebrew_pe = 0xcf4 XK_hebrew_finalzade = 0xcf5 XK_hebrew_finalzadi = 0xcf5 XK_hebrew_zade = 0xcf6 XK_hebrew_zadi = 0xcf6 XK_hebrew_qoph = 0xcf7 XK_hebrew_kuf = 0xcf7 XK_hebrew_resh = 0xcf8 XK_hebrew_shin = 0xcf9 XK_hebrew_taw = 0xcfa XK_hebrew_taf = 0xcfa XK_Hebrew_switch = 0xFF7E python-xlib-0.33/Xlib/keysymdef/katakana.py000066400000000000000000000025651435211557500207570ustar00rootroot00000000000000XK_overline = 0x47e XK_kana_fullstop = 0x4a1 XK_kana_openingbracket = 0x4a2 XK_kana_closingbracket = 0x4a3 XK_kana_comma = 0x4a4 XK_kana_conjunctive = 0x4a5 XK_kana_middledot = 0x4a5 XK_kana_WO = 0x4a6 XK_kana_a = 0x4a7 XK_kana_i = 0x4a8 XK_kana_u = 0x4a9 XK_kana_e = 0x4aa XK_kana_o = 0x4ab XK_kana_ya = 0x4ac XK_kana_yu = 0x4ad XK_kana_yo = 0x4ae XK_kana_tsu = 0x4af XK_kana_tu = 0x4af XK_prolongedsound = 0x4b0 XK_kana_A = 0x4b1 XK_kana_I = 0x4b2 XK_kana_U = 0x4b3 XK_kana_E = 0x4b4 XK_kana_O = 0x4b5 XK_kana_KA = 0x4b6 XK_kana_KI = 0x4b7 XK_kana_KU = 0x4b8 XK_kana_KE = 0x4b9 XK_kana_KO = 0x4ba XK_kana_SA = 0x4bb XK_kana_SHI = 0x4bc XK_kana_SU = 0x4bd XK_kana_SE = 0x4be XK_kana_SO = 0x4bf XK_kana_TA = 0x4c0 XK_kana_CHI = 0x4c1 XK_kana_TI = 0x4c1 XK_kana_TSU = 0x4c2 XK_kana_TU = 0x4c2 XK_kana_TE = 0x4c3 XK_kana_TO = 0x4c4 XK_kana_NA = 0x4c5 XK_kana_NI = 0x4c6 XK_kana_NU = 0x4c7 XK_kana_NE = 0x4c8 XK_kana_NO = 0x4c9 XK_kana_HA = 0x4ca XK_kana_HI = 0x4cb XK_kana_FU = 0x4cc XK_kana_HU = 0x4cc XK_kana_HE = 0x4cd XK_kana_HO = 0x4ce XK_kana_MA = 0x4cf XK_kana_MI = 0x4d0 XK_kana_MU = 0x4d1 XK_kana_ME = 0x4d2 XK_kana_MO = 0x4d3 XK_kana_YA = 0x4d4 XK_kana_YU = 0x4d5 XK_kana_YO = 0x4d6 XK_kana_RA = 0x4d7 XK_kana_RI = 0x4d8 XK_kana_RU = 0x4d9 XK_kana_RE = 0x4da XK_kana_RO = 0x4db XK_kana_WA = 0x4dc XK_kana_N = 0x4dd XK_voicedsound = 0x4de XK_semivoicedsound = 0x4df XK_kana_switch = 0xFF7E python-xlib-0.33/Xlib/keysymdef/korean.py000066400000000000000000000054541435211557500204630ustar00rootroot00000000000000XK_Hangul = 0xff31 XK_Hangul_Start = 0xff32 XK_Hangul_End = 0xff33 XK_Hangul_Hanja = 0xff34 XK_Hangul_Jamo = 0xff35 XK_Hangul_Romaja = 0xff36 XK_Hangul_Codeinput = 0xff37 XK_Hangul_Jeonja = 0xff38 XK_Hangul_Banja = 0xff39 XK_Hangul_PreHanja = 0xff3a XK_Hangul_PostHanja = 0xff3b XK_Hangul_SingleCandidate = 0xff3c XK_Hangul_MultipleCandidate = 0xff3d XK_Hangul_PreviousCandidate = 0xff3e XK_Hangul_Special = 0xff3f XK_Hangul_switch = 0xFF7E XK_Hangul_Kiyeog = 0xea1 XK_Hangul_SsangKiyeog = 0xea2 XK_Hangul_KiyeogSios = 0xea3 XK_Hangul_Nieun = 0xea4 XK_Hangul_NieunJieuj = 0xea5 XK_Hangul_NieunHieuh = 0xea6 XK_Hangul_Dikeud = 0xea7 XK_Hangul_SsangDikeud = 0xea8 XK_Hangul_Rieul = 0xea9 XK_Hangul_RieulKiyeog = 0xeaa XK_Hangul_RieulMieum = 0xeab XK_Hangul_RieulPieub = 0xeac XK_Hangul_RieulSios = 0xead XK_Hangul_RieulTieut = 0xeae XK_Hangul_RieulPhieuf = 0xeaf XK_Hangul_RieulHieuh = 0xeb0 XK_Hangul_Mieum = 0xeb1 XK_Hangul_Pieub = 0xeb2 XK_Hangul_SsangPieub = 0xeb3 XK_Hangul_PieubSios = 0xeb4 XK_Hangul_Sios = 0xeb5 XK_Hangul_SsangSios = 0xeb6 XK_Hangul_Ieung = 0xeb7 XK_Hangul_Jieuj = 0xeb8 XK_Hangul_SsangJieuj = 0xeb9 XK_Hangul_Cieuc = 0xeba XK_Hangul_Khieuq = 0xebb XK_Hangul_Tieut = 0xebc XK_Hangul_Phieuf = 0xebd XK_Hangul_Hieuh = 0xebe XK_Hangul_A = 0xebf XK_Hangul_AE = 0xec0 XK_Hangul_YA = 0xec1 XK_Hangul_YAE = 0xec2 XK_Hangul_EO = 0xec3 XK_Hangul_E = 0xec4 XK_Hangul_YEO = 0xec5 XK_Hangul_YE = 0xec6 XK_Hangul_O = 0xec7 XK_Hangul_WA = 0xec8 XK_Hangul_WAE = 0xec9 XK_Hangul_OE = 0xeca XK_Hangul_YO = 0xecb XK_Hangul_U = 0xecc XK_Hangul_WEO = 0xecd XK_Hangul_WE = 0xece XK_Hangul_WI = 0xecf XK_Hangul_YU = 0xed0 XK_Hangul_EU = 0xed1 XK_Hangul_YI = 0xed2 XK_Hangul_I = 0xed3 XK_Hangul_J_Kiyeog = 0xed4 XK_Hangul_J_SsangKiyeog = 0xed5 XK_Hangul_J_KiyeogSios = 0xed6 XK_Hangul_J_Nieun = 0xed7 XK_Hangul_J_NieunJieuj = 0xed8 XK_Hangul_J_NieunHieuh = 0xed9 XK_Hangul_J_Dikeud = 0xeda XK_Hangul_J_Rieul = 0xedb XK_Hangul_J_RieulKiyeog = 0xedc XK_Hangul_J_RieulMieum = 0xedd XK_Hangul_J_RieulPieub = 0xede XK_Hangul_J_RieulSios = 0xedf XK_Hangul_J_RieulTieut = 0xee0 XK_Hangul_J_RieulPhieuf = 0xee1 XK_Hangul_J_RieulHieuh = 0xee2 XK_Hangul_J_Mieum = 0xee3 XK_Hangul_J_Pieub = 0xee4 XK_Hangul_J_PieubSios = 0xee5 XK_Hangul_J_Sios = 0xee6 XK_Hangul_J_SsangSios = 0xee7 XK_Hangul_J_Ieung = 0xee8 XK_Hangul_J_Jieuj = 0xee9 XK_Hangul_J_Cieuc = 0xeea XK_Hangul_J_Khieuq = 0xeeb XK_Hangul_J_Tieut = 0xeec XK_Hangul_J_Phieuf = 0xeed XK_Hangul_J_Hieuh = 0xeee XK_Hangul_RieulYeorinHieuh = 0xeef XK_Hangul_SunkyeongeumMieum = 0xef0 XK_Hangul_SunkyeongeumPieub = 0xef1 XK_Hangul_PanSios = 0xef2 XK_Hangul_KkogjiDalrinIeung = 0xef3 XK_Hangul_SunkyeongeumPhieuf = 0xef4 XK_Hangul_YeorinHieuh = 0xef5 XK_Hangul_AraeA = 0xef6 XK_Hangul_AraeAE = 0xef7 XK_Hangul_J_PanSios = 0xef8 XK_Hangul_J_KkogjiDalrinIeung = 0xef9 XK_Hangul_J_YeorinHieuh = 0xefa XK_Korean_Won = 0xeff python-xlib-0.33/Xlib/keysymdef/latin1.py000066400000000000000000000065421435211557500203730ustar00rootroot00000000000000XK_space = 0x020 XK_exclam = 0x021 XK_quotedbl = 0x022 XK_numbersign = 0x023 XK_dollar = 0x024 XK_percent = 0x025 XK_ampersand = 0x026 XK_apostrophe = 0x027 XK_quoteright = 0x027 XK_parenleft = 0x028 XK_parenright = 0x029 XK_asterisk = 0x02a XK_plus = 0x02b XK_comma = 0x02c XK_minus = 0x02d XK_period = 0x02e XK_slash = 0x02f XK_0 = 0x030 XK_1 = 0x031 XK_2 = 0x032 XK_3 = 0x033 XK_4 = 0x034 XK_5 = 0x035 XK_6 = 0x036 XK_7 = 0x037 XK_8 = 0x038 XK_9 = 0x039 XK_colon = 0x03a XK_semicolon = 0x03b XK_less = 0x03c XK_equal = 0x03d XK_greater = 0x03e XK_question = 0x03f XK_at = 0x040 XK_A = 0x041 XK_B = 0x042 XK_C = 0x043 XK_D = 0x044 XK_E = 0x045 XK_F = 0x046 XK_G = 0x047 XK_H = 0x048 XK_I = 0x049 XK_J = 0x04a XK_K = 0x04b XK_L = 0x04c XK_M = 0x04d XK_N = 0x04e XK_O = 0x04f XK_P = 0x050 XK_Q = 0x051 XK_R = 0x052 XK_S = 0x053 XK_T = 0x054 XK_U = 0x055 XK_V = 0x056 XK_W = 0x057 XK_X = 0x058 XK_Y = 0x059 XK_Z = 0x05a XK_bracketleft = 0x05b XK_backslash = 0x05c XK_bracketright = 0x05d XK_asciicircum = 0x05e XK_underscore = 0x05f XK_grave = 0x060 XK_quoteleft = 0x060 XK_a = 0x061 XK_b = 0x062 XK_c = 0x063 XK_d = 0x064 XK_e = 0x065 XK_f = 0x066 XK_g = 0x067 XK_h = 0x068 XK_i = 0x069 XK_j = 0x06a XK_k = 0x06b XK_l = 0x06c XK_m = 0x06d XK_n = 0x06e XK_o = 0x06f XK_p = 0x070 XK_q = 0x071 XK_r = 0x072 XK_s = 0x073 XK_t = 0x074 XK_u = 0x075 XK_v = 0x076 XK_w = 0x077 XK_x = 0x078 XK_y = 0x079 XK_z = 0x07a XK_braceleft = 0x07b XK_bar = 0x07c XK_braceright = 0x07d XK_asciitilde = 0x07e XK_nobreakspace = 0x0a0 XK_exclamdown = 0x0a1 XK_cent = 0x0a2 XK_sterling = 0x0a3 XK_currency = 0x0a4 XK_yen = 0x0a5 XK_brokenbar = 0x0a6 XK_section = 0x0a7 XK_diaeresis = 0x0a8 XK_copyright = 0x0a9 XK_ordfeminine = 0x0aa XK_guillemotleft = 0x0ab XK_notsign = 0x0ac XK_hyphen = 0x0ad XK_registered = 0x0ae XK_macron = 0x0af XK_degree = 0x0b0 XK_plusminus = 0x0b1 XK_twosuperior = 0x0b2 XK_threesuperior = 0x0b3 XK_acute = 0x0b4 XK_mu = 0x0b5 XK_paragraph = 0x0b6 XK_periodcentered = 0x0b7 XK_cedilla = 0x0b8 XK_onesuperior = 0x0b9 XK_masculine = 0x0ba XK_guillemotright = 0x0bb XK_onequarter = 0x0bc XK_onehalf = 0x0bd XK_threequarters = 0x0be XK_questiondown = 0x0bf XK_Agrave = 0x0c0 XK_Aacute = 0x0c1 XK_Acircumflex = 0x0c2 XK_Atilde = 0x0c3 XK_Adiaeresis = 0x0c4 XK_Aring = 0x0c5 XK_AE = 0x0c6 XK_Ccedilla = 0x0c7 XK_Egrave = 0x0c8 XK_Eacute = 0x0c9 XK_Ecircumflex = 0x0ca XK_Ediaeresis = 0x0cb XK_Igrave = 0x0cc XK_Iacute = 0x0cd XK_Icircumflex = 0x0ce XK_Idiaeresis = 0x0cf XK_ETH = 0x0d0 XK_Eth = 0x0d0 XK_Ntilde = 0x0d1 XK_Ograve = 0x0d2 XK_Oacute = 0x0d3 XK_Ocircumflex = 0x0d4 XK_Otilde = 0x0d5 XK_Odiaeresis = 0x0d6 XK_multiply = 0x0d7 XK_Ooblique = 0x0d8 XK_Ugrave = 0x0d9 XK_Uacute = 0x0da XK_Ucircumflex = 0x0db XK_Udiaeresis = 0x0dc XK_Yacute = 0x0dd XK_THORN = 0x0de XK_Thorn = 0x0de XK_ssharp = 0x0df XK_agrave = 0x0e0 XK_aacute = 0x0e1 XK_acircumflex = 0x0e2 XK_atilde = 0x0e3 XK_adiaeresis = 0x0e4 XK_aring = 0x0e5 XK_ae = 0x0e6 XK_ccedilla = 0x0e7 XK_egrave = 0x0e8 XK_eacute = 0x0e9 XK_ecircumflex = 0x0ea XK_ediaeresis = 0x0eb XK_igrave = 0x0ec XK_iacute = 0x0ed XK_icircumflex = 0x0ee XK_idiaeresis = 0x0ef XK_eth = 0x0f0 XK_ntilde = 0x0f1 XK_ograve = 0x0f2 XK_oacute = 0x0f3 XK_ocircumflex = 0x0f4 XK_otilde = 0x0f5 XK_odiaeresis = 0x0f6 XK_division = 0x0f7 XK_oslash = 0x0f8 XK_ugrave = 0x0f9 XK_uacute = 0x0fa XK_ucircumflex = 0x0fb XK_udiaeresis = 0x0fc XK_yacute = 0x0fd XK_thorn = 0x0fe XK_ydiaeresis = 0x0ff python-xlib-0.33/Xlib/keysymdef/latin2.py000066400000000000000000000020631435211557500203660ustar00rootroot00000000000000XK_Aogonek = 0x1a1 XK_breve = 0x1a2 XK_Lstroke = 0x1a3 XK_Lcaron = 0x1a5 XK_Sacute = 0x1a6 XK_Scaron = 0x1a9 XK_Scedilla = 0x1aa XK_Tcaron = 0x1ab XK_Zacute = 0x1ac XK_Zcaron = 0x1ae XK_Zabovedot = 0x1af XK_aogonek = 0x1b1 XK_ogonek = 0x1b2 XK_lstroke = 0x1b3 XK_lcaron = 0x1b5 XK_sacute = 0x1b6 XK_caron = 0x1b7 XK_scaron = 0x1b9 XK_scedilla = 0x1ba XK_tcaron = 0x1bb XK_zacute = 0x1bc XK_doubleacute = 0x1bd XK_zcaron = 0x1be XK_zabovedot = 0x1bf XK_Racute = 0x1c0 XK_Abreve = 0x1c3 XK_Lacute = 0x1c5 XK_Cacute = 0x1c6 XK_Ccaron = 0x1c8 XK_Eogonek = 0x1ca XK_Ecaron = 0x1cc XK_Dcaron = 0x1cf XK_Dstroke = 0x1d0 XK_Nacute = 0x1d1 XK_Ncaron = 0x1d2 XK_Odoubleacute = 0x1d5 XK_Rcaron = 0x1d8 XK_Uring = 0x1d9 XK_Udoubleacute = 0x1db XK_Tcedilla = 0x1de XK_racute = 0x1e0 XK_abreve = 0x1e3 XK_lacute = 0x1e5 XK_cacute = 0x1e6 XK_ccaron = 0x1e8 XK_eogonek = 0x1ea XK_ecaron = 0x1ec XK_dcaron = 0x1ef XK_dstroke = 0x1f0 XK_nacute = 0x1f1 XK_ncaron = 0x1f2 XK_odoubleacute = 0x1f5 XK_udoubleacute = 0x1fb XK_rcaron = 0x1f8 XK_uring = 0x1f9 XK_tcedilla = 0x1fe XK_abovedot = 0x1ff python-xlib-0.33/Xlib/keysymdef/latin3.py000066400000000000000000000007211435211557500203660ustar00rootroot00000000000000XK_Hstroke = 0x2a1 XK_Hcircumflex = 0x2a6 XK_Iabovedot = 0x2a9 XK_Gbreve = 0x2ab XK_Jcircumflex = 0x2ac XK_hstroke = 0x2b1 XK_hcircumflex = 0x2b6 XK_idotless = 0x2b9 XK_gbreve = 0x2bb XK_jcircumflex = 0x2bc XK_Cabovedot = 0x2c5 XK_Ccircumflex = 0x2c6 XK_Gabovedot = 0x2d5 XK_Gcircumflex = 0x2d8 XK_Ubreve = 0x2dd XK_Scircumflex = 0x2de XK_cabovedot = 0x2e5 XK_ccircumflex = 0x2e6 XK_gabovedot = 0x2f5 XK_gcircumflex = 0x2f8 XK_ubreve = 0x2fd XK_scircumflex = 0x2fe python-xlib-0.33/Xlib/keysymdef/latin4.py000066400000000000000000000012461435211557500203720ustar00rootroot00000000000000XK_kra = 0x3a2 XK_kappa = 0x3a2 XK_Rcedilla = 0x3a3 XK_Itilde = 0x3a5 XK_Lcedilla = 0x3a6 XK_Emacron = 0x3aa XK_Gcedilla = 0x3ab XK_Tslash = 0x3ac XK_rcedilla = 0x3b3 XK_itilde = 0x3b5 XK_lcedilla = 0x3b6 XK_emacron = 0x3ba XK_gcedilla = 0x3bb XK_tslash = 0x3bc XK_ENG = 0x3bd XK_eng = 0x3bf XK_Amacron = 0x3c0 XK_Iogonek = 0x3c7 XK_Eabovedot = 0x3cc XK_Imacron = 0x3cf XK_Ncedilla = 0x3d1 XK_Omacron = 0x3d2 XK_Kcedilla = 0x3d3 XK_Uogonek = 0x3d9 XK_Utilde = 0x3dd XK_Umacron = 0x3de XK_amacron = 0x3e0 XK_iogonek = 0x3e7 XK_eabovedot = 0x3ec XK_imacron = 0x3ef XK_ncedilla = 0x3f1 XK_omacron = 0x3f2 XK_kcedilla = 0x3f3 XK_uogonek = 0x3f9 XK_utilde = 0x3fd XK_umacron = 0x3fe python-xlib-0.33/Xlib/keysymdef/miscellany.py000066400000000000000000000060751435211557500213440ustar00rootroot00000000000000XK_BackSpace = 0xFF08 XK_Tab = 0xFF09 XK_Linefeed = 0xFF0A XK_Clear = 0xFF0B XK_Return = 0xFF0D XK_Pause = 0xFF13 XK_Scroll_Lock = 0xFF14 XK_Sys_Req = 0xFF15 XK_Escape = 0xFF1B XK_Delete = 0xFFFF XK_Multi_key = 0xFF20 XK_SingleCandidate = 0xFF3C XK_MultipleCandidate = 0xFF3D XK_PreviousCandidate = 0xFF3E XK_Kanji = 0xFF21 XK_Muhenkan = 0xFF22 XK_Henkan_Mode = 0xFF23 XK_Henkan = 0xFF23 XK_Romaji = 0xFF24 XK_Hiragana = 0xFF25 XK_Katakana = 0xFF26 XK_Hiragana_Katakana = 0xFF27 XK_Zenkaku = 0xFF28 XK_Hankaku = 0xFF29 XK_Zenkaku_Hankaku = 0xFF2A XK_Touroku = 0xFF2B XK_Massyo = 0xFF2C XK_Kana_Lock = 0xFF2D XK_Kana_Shift = 0xFF2E XK_Eisu_Shift = 0xFF2F XK_Eisu_toggle = 0xFF30 XK_Zen_Koho = 0xFF3D XK_Mae_Koho = 0xFF3E XK_Home = 0xFF50 XK_Left = 0xFF51 XK_Up = 0xFF52 XK_Right = 0xFF53 XK_Down = 0xFF54 XK_Prior = 0xFF55 XK_Page_Up = 0xFF55 XK_Next = 0xFF56 XK_Page_Down = 0xFF56 XK_End = 0xFF57 XK_Begin = 0xFF58 XK_Select = 0xFF60 XK_Print = 0xFF61 XK_Execute = 0xFF62 XK_Insert = 0xFF63 XK_Undo = 0xFF65 XK_Redo = 0xFF66 XK_Menu = 0xFF67 XK_Find = 0xFF68 XK_Cancel = 0xFF69 XK_Help = 0xFF6A XK_Break = 0xFF6B XK_Mode_switch = 0xFF7E XK_script_switch = 0xFF7E XK_Num_Lock = 0xFF7F XK_KP_Space = 0xFF80 XK_KP_Tab = 0xFF89 XK_KP_Enter = 0xFF8D XK_KP_F1 = 0xFF91 XK_KP_F2 = 0xFF92 XK_KP_F3 = 0xFF93 XK_KP_F4 = 0xFF94 XK_KP_Home = 0xFF95 XK_KP_Left = 0xFF96 XK_KP_Up = 0xFF97 XK_KP_Right = 0xFF98 XK_KP_Down = 0xFF99 XK_KP_Prior = 0xFF9A XK_KP_Page_Up = 0xFF9A XK_KP_Next = 0xFF9B XK_KP_Page_Down = 0xFF9B XK_KP_End = 0xFF9C XK_KP_Begin = 0xFF9D XK_KP_Insert = 0xFF9E XK_KP_Delete = 0xFF9F XK_KP_Equal = 0xFFBD XK_KP_Multiply = 0xFFAA XK_KP_Add = 0xFFAB XK_KP_Separator = 0xFFAC XK_KP_Subtract = 0xFFAD XK_KP_Decimal = 0xFFAE XK_KP_Divide = 0xFFAF XK_KP_0 = 0xFFB0 XK_KP_1 = 0xFFB1 XK_KP_2 = 0xFFB2 XK_KP_3 = 0xFFB3 XK_KP_4 = 0xFFB4 XK_KP_5 = 0xFFB5 XK_KP_6 = 0xFFB6 XK_KP_7 = 0xFFB7 XK_KP_8 = 0xFFB8 XK_KP_9 = 0xFFB9 XK_F1 = 0xFFBE XK_F2 = 0xFFBF XK_F3 = 0xFFC0 XK_F4 = 0xFFC1 XK_F5 = 0xFFC2 XK_F6 = 0xFFC3 XK_F7 = 0xFFC4 XK_F8 = 0xFFC5 XK_F9 = 0xFFC6 XK_F10 = 0xFFC7 XK_F11 = 0xFFC8 XK_L1 = 0xFFC8 XK_F12 = 0xFFC9 XK_L2 = 0xFFC9 XK_F13 = 0xFFCA XK_L3 = 0xFFCA XK_F14 = 0xFFCB XK_L4 = 0xFFCB XK_F15 = 0xFFCC XK_L5 = 0xFFCC XK_F16 = 0xFFCD XK_L6 = 0xFFCD XK_F17 = 0xFFCE XK_L7 = 0xFFCE XK_F18 = 0xFFCF XK_L8 = 0xFFCF XK_F19 = 0xFFD0 XK_L9 = 0xFFD0 XK_F20 = 0xFFD1 XK_L10 = 0xFFD1 XK_F21 = 0xFFD2 XK_R1 = 0xFFD2 XK_F22 = 0xFFD3 XK_R2 = 0xFFD3 XK_F23 = 0xFFD4 XK_R3 = 0xFFD4 XK_F24 = 0xFFD5 XK_R4 = 0xFFD5 XK_F25 = 0xFFD6 XK_R5 = 0xFFD6 XK_F26 = 0xFFD7 XK_R6 = 0xFFD7 XK_F27 = 0xFFD8 XK_R7 = 0xFFD8 XK_F28 = 0xFFD9 XK_R8 = 0xFFD9 XK_F29 = 0xFFDA XK_R9 = 0xFFDA XK_F30 = 0xFFDB XK_R10 = 0xFFDB XK_F31 = 0xFFDC XK_R11 = 0xFFDC XK_F32 = 0xFFDD XK_R12 = 0xFFDD XK_F33 = 0xFFDE XK_R13 = 0xFFDE XK_F34 = 0xFFDF XK_R14 = 0xFFDF XK_F35 = 0xFFE0 XK_R15 = 0xFFE0 XK_Shift_L = 0xFFE1 XK_Shift_R = 0xFFE2 XK_Control_L = 0xFFE3 XK_Control_R = 0xFFE4 XK_Caps_Lock = 0xFFE5 XK_Shift_Lock = 0xFFE6 XK_Meta_L = 0xFFE7 XK_Meta_R = 0xFFE8 XK_Alt_L = 0xFFE9 XK_Alt_R = 0xFFEA XK_Super_L = 0xFFEB XK_Super_R = 0xFFEC XK_Hyper_L = 0xFFED XK_Hyper_R = 0xFFEE python-xlib-0.33/Xlib/keysymdef/publishing.py000066400000000000000000000036711435211557500213470ustar00rootroot00000000000000XK_emspace = 0xaa1 XK_enspace = 0xaa2 XK_em3space = 0xaa3 XK_em4space = 0xaa4 XK_digitspace = 0xaa5 XK_punctspace = 0xaa6 XK_thinspace = 0xaa7 XK_hairspace = 0xaa8 XK_emdash = 0xaa9 XK_endash = 0xaaa XK_signifblank = 0xaac XK_ellipsis = 0xaae XK_doubbaselinedot = 0xaaf XK_onethird = 0xab0 XK_twothirds = 0xab1 XK_onefifth = 0xab2 XK_twofifths = 0xab3 XK_threefifths = 0xab4 XK_fourfifths = 0xab5 XK_onesixth = 0xab6 XK_fivesixths = 0xab7 XK_careof = 0xab8 XK_figdash = 0xabb XK_leftanglebracket = 0xabc XK_decimalpoint = 0xabd XK_rightanglebracket = 0xabe XK_marker = 0xabf XK_oneeighth = 0xac3 XK_threeeighths = 0xac4 XK_fiveeighths = 0xac5 XK_seveneighths = 0xac6 XK_trademark = 0xac9 XK_signaturemark = 0xaca XK_trademarkincircle = 0xacb XK_leftopentriangle = 0xacc XK_rightopentriangle = 0xacd XK_emopencircle = 0xace XK_emopenrectangle = 0xacf XK_leftsinglequotemark = 0xad0 XK_rightsinglequotemark = 0xad1 XK_leftdoublequotemark = 0xad2 XK_rightdoublequotemark = 0xad3 XK_prescription = 0xad4 XK_minutes = 0xad6 XK_seconds = 0xad7 XK_latincross = 0xad9 XK_hexagram = 0xada XK_filledrectbullet = 0xadb XK_filledlefttribullet = 0xadc XK_filledrighttribullet = 0xadd XK_emfilledcircle = 0xade XK_emfilledrect = 0xadf XK_enopencircbullet = 0xae0 XK_enopensquarebullet = 0xae1 XK_openrectbullet = 0xae2 XK_opentribulletup = 0xae3 XK_opentribulletdown = 0xae4 XK_openstar = 0xae5 XK_enfilledcircbullet = 0xae6 XK_enfilledsqbullet = 0xae7 XK_filledtribulletup = 0xae8 XK_filledtribulletdown = 0xae9 XK_leftpointer = 0xaea XK_rightpointer = 0xaeb XK_club = 0xaec XK_diamond = 0xaed XK_heart = 0xaee XK_maltesecross = 0xaf0 XK_dagger = 0xaf1 XK_doubledagger = 0xaf2 XK_checkmark = 0xaf3 XK_ballotcross = 0xaf4 XK_musicalsharp = 0xaf5 XK_musicalflat = 0xaf6 XK_malesymbol = 0xaf7 XK_femalesymbol = 0xaf8 XK_telephone = 0xaf9 XK_telephonerecorder = 0xafa XK_phonographcopyright = 0xafb XK_caret = 0xafc XK_singlelowquotemark = 0xafd XK_doublelowquotemark = 0xafe XK_cursor = 0xaff python-xlib-0.33/Xlib/keysymdef/special.py000066400000000000000000000007521435211557500206200ustar00rootroot00000000000000XK_blank = 0x9df XK_soliddiamond = 0x9e0 XK_checkerboard = 0x9e1 XK_ht = 0x9e2 XK_ff = 0x9e3 XK_cr = 0x9e4 XK_lf = 0x9e5 XK_nl = 0x9e8 XK_vt = 0x9e9 XK_lowrightcorner = 0x9ea XK_uprightcorner = 0x9eb XK_upleftcorner = 0x9ec XK_lowleftcorner = 0x9ed XK_crossinglines = 0x9ee XK_horizlinescan1 = 0x9ef XK_horizlinescan3 = 0x9f0 XK_horizlinescan5 = 0x9f1 XK_horizlinescan7 = 0x9f2 XK_horizlinescan9 = 0x9f3 XK_leftt = 0x9f4 XK_rightt = 0x9f5 XK_bott = 0x9f6 XK_topt = 0x9f7 XK_vertbar = 0x9f8 python-xlib-0.33/Xlib/keysymdef/technical.py000066400000000000000000000022631435211557500211310ustar00rootroot00000000000000XK_leftradical = 0x8a1 XK_topleftradical = 0x8a2 XK_horizconnector = 0x8a3 XK_topintegral = 0x8a4 XK_botintegral = 0x8a5 XK_vertconnector = 0x8a6 XK_topleftsqbracket = 0x8a7 XK_botleftsqbracket = 0x8a8 XK_toprightsqbracket = 0x8a9 XK_botrightsqbracket = 0x8aa XK_topleftparens = 0x8ab XK_botleftparens = 0x8ac XK_toprightparens = 0x8ad XK_botrightparens = 0x8ae XK_leftmiddlecurlybrace = 0x8af XK_rightmiddlecurlybrace = 0x8b0 XK_topleftsummation = 0x8b1 XK_botleftsummation = 0x8b2 XK_topvertsummationconnector = 0x8b3 XK_botvertsummationconnector = 0x8b4 XK_toprightsummation = 0x8b5 XK_botrightsummation = 0x8b6 XK_rightmiddlesummation = 0x8b7 XK_lessthanequal = 0x8bc XK_notequal = 0x8bd XK_greaterthanequal = 0x8be XK_integral = 0x8bf XK_therefore = 0x8c0 XK_variation = 0x8c1 XK_infinity = 0x8c2 XK_nabla = 0x8c5 XK_approximate = 0x8c8 XK_similarequal = 0x8c9 XK_ifonlyif = 0x8cd XK_implies = 0x8ce XK_identical = 0x8cf XK_radical = 0x8d6 XK_includedin = 0x8da XK_includes = 0x8db XK_intersection = 0x8dc XK_union = 0x8dd XK_logicaland = 0x8de XK_logicalor = 0x8df XK_partialderivative = 0x8ef XK_function = 0x8f6 XK_leftarrow = 0x8fb XK_uparrow = 0x8fc XK_rightarrow = 0x8fd XK_downarrow = 0x8fe python-xlib-0.33/Xlib/keysymdef/thai.py000066400000000000000000000037241435211557500201270ustar00rootroot00000000000000XK_Thai_kokai = 0xda1 XK_Thai_khokhai = 0xda2 XK_Thai_khokhuat = 0xda3 XK_Thai_khokhwai = 0xda4 XK_Thai_khokhon = 0xda5 XK_Thai_khorakhang = 0xda6 XK_Thai_ngongu = 0xda7 XK_Thai_chochan = 0xda8 XK_Thai_choching = 0xda9 XK_Thai_chochang = 0xdaa XK_Thai_soso = 0xdab XK_Thai_chochoe = 0xdac XK_Thai_yoying = 0xdad XK_Thai_dochada = 0xdae XK_Thai_topatak = 0xdaf XK_Thai_thothan = 0xdb0 XK_Thai_thonangmontho = 0xdb1 XK_Thai_thophuthao = 0xdb2 XK_Thai_nonen = 0xdb3 XK_Thai_dodek = 0xdb4 XK_Thai_totao = 0xdb5 XK_Thai_thothung = 0xdb6 XK_Thai_thothahan = 0xdb7 XK_Thai_thothong = 0xdb8 XK_Thai_nonu = 0xdb9 XK_Thai_bobaimai = 0xdba XK_Thai_popla = 0xdbb XK_Thai_phophung = 0xdbc XK_Thai_fofa = 0xdbd XK_Thai_phophan = 0xdbe XK_Thai_fofan = 0xdbf XK_Thai_phosamphao = 0xdc0 XK_Thai_moma = 0xdc1 XK_Thai_yoyak = 0xdc2 XK_Thai_rorua = 0xdc3 XK_Thai_ru = 0xdc4 XK_Thai_loling = 0xdc5 XK_Thai_lu = 0xdc6 XK_Thai_wowaen = 0xdc7 XK_Thai_sosala = 0xdc8 XK_Thai_sorusi = 0xdc9 XK_Thai_sosua = 0xdca XK_Thai_hohip = 0xdcb XK_Thai_lochula = 0xdcc XK_Thai_oang = 0xdcd XK_Thai_honokhuk = 0xdce XK_Thai_paiyannoi = 0xdcf XK_Thai_saraa = 0xdd0 XK_Thai_maihanakat = 0xdd1 XK_Thai_saraaa = 0xdd2 XK_Thai_saraam = 0xdd3 XK_Thai_sarai = 0xdd4 XK_Thai_saraii = 0xdd5 XK_Thai_saraue = 0xdd6 XK_Thai_sarauee = 0xdd7 XK_Thai_sarau = 0xdd8 XK_Thai_sarauu = 0xdd9 XK_Thai_phinthu = 0xdda XK_Thai_maihanakat_maitho = 0xdde XK_Thai_baht = 0xddf XK_Thai_sarae = 0xde0 XK_Thai_saraae = 0xde1 XK_Thai_sarao = 0xde2 XK_Thai_saraaimaimuan = 0xde3 XK_Thai_saraaimaimalai = 0xde4 XK_Thai_lakkhangyao = 0xde5 XK_Thai_maiyamok = 0xde6 XK_Thai_maitaikhu = 0xde7 XK_Thai_maiek = 0xde8 XK_Thai_maitho = 0xde9 XK_Thai_maitri = 0xdea XK_Thai_maichattawa = 0xdeb XK_Thai_thanthakhat = 0xdec XK_Thai_nikhahit = 0xded XK_Thai_leksun = 0xdf0 XK_Thai_leknung = 0xdf1 XK_Thai_leksong = 0xdf2 XK_Thai_leksam = 0xdf3 XK_Thai_leksi = 0xdf4 XK_Thai_lekha = 0xdf5 XK_Thai_lekhok = 0xdf6 XK_Thai_lekchet = 0xdf7 XK_Thai_lekpaet = 0xdf8 XK_Thai_lekkao = 0xdf9 python-xlib-0.33/Xlib/keysymdef/xf86.py000066400000000000000000000153011435211557500177670ustar00rootroot00000000000000XK_XF86_ModeLock = 0x1008FF01 XK_XF86_MonBrightnessUp = 0x1008FF02 XK_XF86_MonBrightnessDown = 0x1008FF03 XK_XF86_KbdLightOnOff = 0x1008FF04 XK_XF86_KbdBrightnessUp = 0x1008FF05 XK_XF86_KbdBrightnessDown = 0x1008FF06 XK_XF86_MonBrightnessCycle = 0x1008FF07 XK_XF86_Standby = 0x1008FF10 XK_XF86_AudioLowerVolume = 0x1008FF11 XK_XF86_AudioMute = 0x1008FF12 XK_XF86_AudioRaiseVolume = 0x1008FF13 XK_XF86_AudioPlay = 0x1008FF14 XK_XF86_AudioStop = 0x1008FF15 XK_XF86_AudioPrev = 0x1008FF16 XK_XF86_AudioNext = 0x1008FF17 XK_XF86_HomePage = 0x1008FF18 XK_XF86_Mail = 0x1008FF19 XK_XF86_Start = 0x1008FF1A XK_XF86_Search = 0x1008FF1B XK_XF86_AudioRecord = 0x1008FF1C XK_XF86_Calculator = 0x1008FF1D XK_XF86_Memo = 0x1008FF1E XK_XF86_ToDoList = 0x1008FF1F XK_XF86_Calendar = 0x1008FF20 XK_XF86_PowerDown = 0x1008FF21 XK_XF86_ContrastAdjust = 0x1008FF22 XK_XF86_RockerUp = 0x1008FF23 XK_XF86_RockerDown = 0x1008FF24 XK_XF86_RockerEnter = 0x1008FF25 XK_XF86_Back = 0x1008FF26 XK_XF86_Forward = 0x1008FF27 XK_XF86_Stop = 0x1008FF28 XK_XF86_Refresh = 0x1008FF29 XK_XF86_PowerOff = 0x1008FF2A XK_XF86_WakeUp = 0x1008FF2B XK_XF86_Eject = 0x1008FF2C XK_XF86_ScreenSaver = 0x1008FF2D XK_XF86_WWW = 0x1008FF2E XK_XF86_Sleep = 0x1008FF2F XK_XF86_Favorites = 0x1008FF30 XK_XF86_AudioPause = 0x1008FF31 XK_XF86_AudioMedia = 0x1008FF32 XK_XF86_MyComputer = 0x1008FF33 XK_XF86_VendorHome = 0x1008FF34 XK_XF86_LightBulb = 0x1008FF35 XK_XF86_Shop = 0x1008FF36 XK_XF86_History = 0x1008FF37 XK_XF86_OpenURL = 0x1008FF38 XK_XF86_AddFavorite = 0x1008FF39 XK_XF86_HotLinks = 0x1008FF3A XK_XF86_BrightnessAdjust = 0x1008FF3B XK_XF86_Finance = 0x1008FF3C XK_XF86_Community = 0x1008FF3D XK_XF86_AudioRewind = 0x1008FF3E XK_XF86_XF86BackForward = 0x1008FF3F XK_XF86_Launch0 = 0x1008FF40 XK_XF86_Launch1 = 0x1008FF41 XK_XF86_Launch2 = 0x1008FF42 XK_XF86_Launch3 = 0x1008FF43 XK_XF86_Launch4 = 0x1008FF44 XK_XF86_Launch5 = 0x1008FF45 XK_XF86_Launch6 = 0x1008FF46 XK_XF86_Launch7 = 0x1008FF47 XK_XF86_Launch8 = 0x1008FF48 XK_XF86_Launch9 = 0x1008FF49 XK_XF86_LaunchA = 0x1008FF4A XK_XF86_LaunchB = 0x1008FF4B XK_XF86_LaunchC = 0x1008FF4C XK_XF86_LaunchD = 0x1008FF4D XK_XF86_LaunchE = 0x1008FF4E XK_XF86_LaunchF = 0x1008FF4F XK_XF86_ApplicationLeft = 0x1008FF50 XK_XF86_ApplicationRight = 0x1008FF51 XK_XF86_Book = 0x1008FF52 XK_XF86_CD = 0x1008FF53 XK_XF86_Calculater = 0x1008FF54 XK_XF86_Clear = 0x1008FF55 XK_XF86_Close = 0x1008FF56 XK_XF86_Copy = 0x1008FF57 XK_XF86_Cut = 0x1008FF58 XK_XF86_Display = 0x1008FF59 XK_XF86_DOS = 0x1008FF5A XK_XF86_Documents = 0x1008FF5B XK_XF86_Excel = 0x1008FF5C XK_XF86_Explorer = 0x1008FF5D XK_XF86_Game = 0x1008FF5E XK_XF86_Go = 0x1008FF5F XK_XF86_iTouch = 0x1008FF60 XK_XF86_LogOff = 0x1008FF61 XK_XF86_Market = 0x1008FF62 XK_XF86_Meeting = 0x1008FF63 XK_XF86_MenuKB = 0x1008FF65 XK_XF86_MenuPB = 0x1008FF66 XK_XF86_MySites = 0x1008FF67 XK_XF86_New = 0x1008FF68 XK_XF86_News = 0x1008FF69 XK_XF86_OfficeHome = 0x1008FF6A XK_XF86_Open = 0x1008FF6B XK_XF86_Option = 0x1008FF6C XK_XF86_Paste = 0x1008FF6D XK_XF86_Phone = 0x1008FF6E XK_XF86_Q = 0x1008FF70 XK_XF86_Reply = 0x1008FF72 XK_XF86_Reload = 0x1008FF73 XK_XF86_RotateWindows = 0x1008FF74 XK_XF86_RotationPB = 0x1008FF75 XK_XF86_RotationKB = 0x1008FF76 XK_XF86_Save = 0x1008FF77 XK_XF86_ScrollUp = 0x1008FF78 XK_XF86_ScrollDown = 0x1008FF79 XK_XF86_ScrollClick = 0x1008FF7A XK_XF86_Send = 0x1008FF7B XK_XF86_Spell = 0x1008FF7C XK_XF86_SplitScreen = 0x1008FF7D XK_XF86_Support = 0x1008FF7E XK_XF86_TaskPane = 0x1008FF7F XK_XF86_Terminal = 0x1008FF80 XK_XF86_Tools = 0x1008FF81 XK_XF86_Travel = 0x1008FF82 XK_XF86_UserPB = 0x1008FF84 XK_XF86_User1KB = 0x1008FF85 XK_XF86_User2KB = 0x1008FF86 XK_XF86_Video = 0x1008FF87 XK_XF86_WheelButton = 0x1008FF88 XK_XF86_Word = 0x1008FF89 XK_XF86_Xfer = 0x1008FF8A XK_XF86_ZoomIn = 0x1008FF8B XK_XF86_ZoomOut = 0x1008FF8C XK_XF86_Away = 0x1008FF8D XK_XF86_Messenger = 0x1008FF8E XK_XF86_WebCam = 0x1008FF8F XK_XF86_MailForward = 0x1008FF90 XK_XF86_Pictures = 0x1008FF91 XK_XF86_Music = 0x1008FF92 XK_XF86_Battery = 0x1008FF93 XK_XF86_Bluetooth = 0x1008FF94 XK_XF86_WLAN = 0x1008FF95 XK_XF86_UWB = 0x1008FF96 XK_XF86_AudioForward = 0x1008FF97 XK_XF86_AudioRepeat = 0x1008FF98 XK_XF86_AudioRandomPlay = 0x1008FF99 XK_XF86_Subtitle = 0x1008FF9A XK_XF86_AudioCycleTrack = 0x1008FF9B XK_XF86_CycleAngle = 0x1008FF9C XK_XF86_FrameBack = 0x1008FF9D XK_XF86_FrameForward = 0x1008FF9E XK_XF86_Time = 0x1008FF9F XK_XF86_Select = 0x1008FFA0 XK_XF86_View = 0x1008FFA1 XK_XF86_TopMenu = 0x1008FFA2 XK_XF86_Red = 0x1008FFA3 XK_XF86_Green = 0x1008FFA4 XK_XF86_Yellow = 0x1008FFA5 XK_XF86_Blue = 0x1008FFA6 XK_XF86_Suspend = 0x1008FFA7 XK_XF86_Hibernate = 0x1008FFA8 XK_XF86_TouchpadToggle = 0x1008FFA9 XK_XF86_TouchpadOn = 0x1008FFB0 XK_XF86_TouchpadOff = 0x1008FFB1 XK_XF86_AudioMicMute = 0x1008FFB2 XK_XF86_Keyboard = 0x1008FFB3 XK_XF86_WWAN = 0x1008FFB4 XK_XF86_RFKill = 0x1008FFB5 XK_XF86_AudioPreset = 0x1008FFB6 XK_XF86_RotationLockToggle = 0x1008FFB7 XK_XF86_FullScreen = 0x1008FFB8 XK_XF86_Switch_VT_1 = 0x1008FE01 XK_XF86_Switch_VT_2 = 0x1008FE02 XK_XF86_Switch_VT_3 = 0x1008FE03 XK_XF86_Switch_VT_4 = 0x1008FE04 XK_XF86_Switch_VT_5 = 0x1008FE05 XK_XF86_Switch_VT_6 = 0x1008FE06 XK_XF86_Switch_VT_7 = 0x1008FE07 XK_XF86_Switch_VT_8 = 0x1008FE08 XK_XF86_Switch_VT_9 = 0x1008FE09 XK_XF86_Switch_VT_10 = 0x1008FE0A XK_XF86_Switch_VT_11 = 0x1008FE0B XK_XF86_Switch_VT_12 = 0x1008FE0C XK_XF86_Ungrab = 0x1008FE20 XK_XF86_ClearGrab = 0x1008FE21 XK_XF86_Next_VMode = 0x1008FE22 XK_XF86_Prev_VMode = 0x1008FE23 XK_XF86_LogWindowTree = 0x1008FE24 XK_XF86_LogGrabInfo = 0x1008FE25 python-xlib-0.33/Xlib/keysymdef/xk3270.py000066400000000000000000000013421435211557500201320ustar00rootroot00000000000000XK_3270_Duplicate = 0xFD01 XK_3270_FieldMark = 0xFD02 XK_3270_Right2 = 0xFD03 XK_3270_Left2 = 0xFD04 XK_3270_BackTab = 0xFD05 XK_3270_EraseEOF = 0xFD06 XK_3270_EraseInput = 0xFD07 XK_3270_Reset = 0xFD08 XK_3270_Quit = 0xFD09 XK_3270_PA1 = 0xFD0A XK_3270_PA2 = 0xFD0B XK_3270_PA3 = 0xFD0C XK_3270_Test = 0xFD0D XK_3270_Attn = 0xFD0E XK_3270_CursorBlink = 0xFD0F XK_3270_AltCursor = 0xFD10 XK_3270_KeyClick = 0xFD11 XK_3270_Jump = 0xFD12 XK_3270_Ident = 0xFD13 XK_3270_Rule = 0xFD14 XK_3270_Copy = 0xFD15 XK_3270_Play = 0xFD16 XK_3270_Setup = 0xFD17 XK_3270_Record = 0xFD18 XK_3270_ChangeScreen = 0xFD19 XK_3270_DeleteWord = 0xFD1A XK_3270_ExSelect = 0xFD1B XK_3270_CursorSelect = 0xFD1C XK_3270_PrintScreen = 0xFD1D XK_3270_Enter = 0xFD1E python-xlib-0.33/Xlib/keysymdef/xkb.py000066400000000000000000000055521435211557500177670ustar00rootroot00000000000000XK_ISO_Lock = 0xFE01 XK_ISO_Level2_Latch = 0xFE02 XK_ISO_Level3_Shift = 0xFE03 XK_ISO_Level3_Latch = 0xFE04 XK_ISO_Level3_Lock = 0xFE05 XK_ISO_Group_Shift = 0xFF7E XK_ISO_Group_Latch = 0xFE06 XK_ISO_Group_Lock = 0xFE07 XK_ISO_Next_Group = 0xFE08 XK_ISO_Next_Group_Lock = 0xFE09 XK_ISO_Prev_Group = 0xFE0A XK_ISO_Prev_Group_Lock = 0xFE0B XK_ISO_First_Group = 0xFE0C XK_ISO_First_Group_Lock = 0xFE0D XK_ISO_Last_Group = 0xFE0E XK_ISO_Last_Group_Lock = 0xFE0F XK_ISO_Left_Tab = 0xFE20 XK_ISO_Move_Line_Up = 0xFE21 XK_ISO_Move_Line_Down = 0xFE22 XK_ISO_Partial_Line_Up = 0xFE23 XK_ISO_Partial_Line_Down = 0xFE24 XK_ISO_Partial_Space_Left = 0xFE25 XK_ISO_Partial_Space_Right = 0xFE26 XK_ISO_Set_Margin_Left = 0xFE27 XK_ISO_Set_Margin_Right = 0xFE28 XK_ISO_Release_Margin_Left = 0xFE29 XK_ISO_Release_Margin_Right = 0xFE2A XK_ISO_Release_Both_Margins = 0xFE2B XK_ISO_Fast_Cursor_Left = 0xFE2C XK_ISO_Fast_Cursor_Right = 0xFE2D XK_ISO_Fast_Cursor_Up = 0xFE2E XK_ISO_Fast_Cursor_Down = 0xFE2F XK_ISO_Continuous_Underline = 0xFE30 XK_ISO_Discontinuous_Underline = 0xFE31 XK_ISO_Emphasize = 0xFE32 XK_ISO_Center_Object = 0xFE33 XK_ISO_Enter = 0xFE34 XK_dead_grave = 0xFE50 XK_dead_acute = 0xFE51 XK_dead_circumflex = 0xFE52 XK_dead_tilde = 0xFE53 XK_dead_macron = 0xFE54 XK_dead_breve = 0xFE55 XK_dead_abovedot = 0xFE56 XK_dead_diaeresis = 0xFE57 XK_dead_abovering = 0xFE58 XK_dead_doubleacute = 0xFE59 XK_dead_caron = 0xFE5A XK_dead_cedilla = 0xFE5B XK_dead_ogonek = 0xFE5C XK_dead_iota = 0xFE5D XK_dead_voiced_sound = 0xFE5E XK_dead_semivoiced_sound = 0xFE5F XK_dead_belowdot = 0xFE60 XK_First_Virtual_Screen = 0xFED0 XK_Prev_Virtual_Screen = 0xFED1 XK_Next_Virtual_Screen = 0xFED2 XK_Last_Virtual_Screen = 0xFED4 XK_Terminate_Server = 0xFED5 XK_AccessX_Enable = 0xFE70 XK_AccessX_Feedback_Enable = 0xFE71 XK_RepeatKeys_Enable = 0xFE72 XK_SlowKeys_Enable = 0xFE73 XK_BounceKeys_Enable = 0xFE74 XK_StickyKeys_Enable = 0xFE75 XK_MouseKeys_Enable = 0xFE76 XK_MouseKeys_Accel_Enable = 0xFE77 XK_Overlay1_Enable = 0xFE78 XK_Overlay2_Enable = 0xFE79 XK_AudibleBell_Enable = 0xFE7A XK_Pointer_Left = 0xFEE0 XK_Pointer_Right = 0xFEE1 XK_Pointer_Up = 0xFEE2 XK_Pointer_Down = 0xFEE3 XK_Pointer_UpLeft = 0xFEE4 XK_Pointer_UpRight = 0xFEE5 XK_Pointer_DownLeft = 0xFEE6 XK_Pointer_DownRight = 0xFEE7 XK_Pointer_Button_Dflt = 0xFEE8 XK_Pointer_Button1 = 0xFEE9 XK_Pointer_Button2 = 0xFEEA XK_Pointer_Button3 = 0xFEEB XK_Pointer_Button4 = 0xFEEC XK_Pointer_Button5 = 0xFEED XK_Pointer_DblClick_Dflt = 0xFEEE XK_Pointer_DblClick1 = 0xFEEF XK_Pointer_DblClick2 = 0xFEF0 XK_Pointer_DblClick3 = 0xFEF1 XK_Pointer_DblClick4 = 0xFEF2 XK_Pointer_DblClick5 = 0xFEF3 XK_Pointer_Drag_Dflt = 0xFEF4 XK_Pointer_Drag1 = 0xFEF5 XK_Pointer_Drag2 = 0xFEF6 XK_Pointer_Drag3 = 0xFEF7 XK_Pointer_Drag4 = 0xFEF8 XK_Pointer_Drag5 = 0xFEFD XK_Pointer_EnableKeys = 0xFEF9 XK_Pointer_Accelerate = 0xFEFA XK_Pointer_DfltBtnNext = 0xFEFB XK_Pointer_DfltBtnPrev = 0xFEFC python-xlib-0.33/Xlib/protocol/000077500000000000000000000000001435211557500164635ustar00rootroot00000000000000python-xlib-0.33/Xlib/protocol/ChangeLog000066400000000000000000000103771435211557500202450ustar00rootroot000000000000002006-07-22 Mike Grant * Xlib/protocol/display.py: (mggrant) Fix for 1219457 - flushing was blocking and waiting for a read operation. Added missing "import socket" per bug report #681511. Fix for bug:1098695 & 1098738. The "recv" variable was being used for more than one thing - renamed one. Changelog hasn't been maintained since 2002, but some of the more significant comments from cvs logs follow: * Xlib/protocol/request.py: (petli) Fix bugs in definition and method of GrabButton/Pointer 2002-02-22 Peter Liljenberg * event.py(CirculateNotify, CirculateRequest): These are identical, so subclass the common Circulate. 2002-02-13 Peter Liljenberg * rq.py (ValueList.parse_binary_value): Use = both for calcsize and unpacking. Caused problems on Alpha. 2002-02-11 Peter Liljenberg * request.py (GetWindowAttributes): Rename class to win_class. (AllocColorPlanes): Fix Pad(4) to Pad(8) in reply. * rq.py (ReplyLength): Add a reply length field, for completeness and easier unit test generation. 2002-02-10 Peter Liljenberg * rq.py (DictWrapper.__cmp__): Let DictWrapper compare with plain dictionaries. (Event.__init__): Set send_event to 0 when creating new events objects, and allow events to be compared. (Struct.parse_binary): Allow LengthFields to have a parse_value method. (OddLength.parse_value): Decode field. (String16.parse_binary_value): Handle OddLength fields. (TextElements8.parse_binary_value): Bugfix: return values instead of v. (String8.parse_binary_value): Parse String8 with no LengthOf field. 2002-02-09 Peter Liljenberg * rq.py (TextElements16): Bugfix: inherit TextElements8 instead of TextElements16. Found while preparing unit tests, whee. 2002-01-14 Peter Liljenberg * display.py (Display.parse_event_response): Fix bug reported by Ilpo Nyyssönen, whereby ReplyRequests which generates events (e.g. get_property with delete = 1) will get dropped when the event is received. 2001-12-14 Peter Liljenberg * display.py (Display.parse_event_response): * rq.py (Event.__init__): Fixed bug in event type decoding: bit 0-6 is the event type, and bit 7 is set if the event was sent by SendEvent. 2001-01-16 * event.py: Changed some class names so that they correspond exactly to the event type constants. Tue Jan 9 10:03:25 2001 Peter Liljenberg * display.py (Display.send_request): Fixed a call to append() with multiple arguments, something that modern Pythons don't allow. 2001-01-04 * rq.py: The fix for 64-bit platforms didn't work, and close scrutiny of structmodule.c shows why: it turns out that '=' translates into '<' or '>', the one the platform would use. This means B is one byte, H is two and L is four, and no extra alignment, always. '@', which is the default, selects native number of bytes, which on Alpha means that 'L' is eight bytes. Now the code goes to pains to ensure that '=' encoding is always used, so _now_ it should work on all platforms. Ahem. 2000-12-29 * rq.py: Optimizations: + replace calls to Field.get_name() with access to attribute name. (Struct.build_from_args): Fri Dec 29 17:05:02 2000 Peter Liljenberg * rq.py: Alpha forces us to probe how many bytes each struct code in 'bhil' represents, instead of being able to assume that b is 1, h is 2 and l is 4. 2000-12-21 * request.py (SetClipRectangles): Fixed typo (attribute was "rectangels"). 2000-12-20 * rq.py (DictWrapper.__setitem__), (DictWrapper.__delitem__), (DictWrapper.__setattr__), (DictWrapper.__delattr__): Add a few methods to the DictWrapper, to make sure that even if attributes are changed, all attributes can be found in the _data mapping. (ValueField.__init__): (Object.__init__): (ValueField.pack_value): (Set.__init__): Added a default parameter, so that structure elements with a default value can be omitted when calling build_from_args. python-xlib-0.33/Xlib/protocol/__init__.py000066400000000000000000000016671435211557500206060ustar00rootroot00000000000000# Xlib.protocol.__init__ -- glue for Xlib.protocol package # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA __all__ = [ 'display', 'event', 'request', 'rq', 'structs', ] python-xlib-0.33/Xlib/protocol/display.py000066400000000000000000001067641435211557500205200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # Xlib.protocol.display -- core display communication # # Copyright (C) 2000-2002 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Standard modules import errno import math import select import socket import struct import sys # Python 2/3 compatibility. from six import PY3, byte2int, indexbytes # Xlib modules from .. import error from ..ext import ge from ..support import lock, connect # Xlib.protocol modules from . import rq from . import event if PY3: class bytesview(object): def __init__(self, data, offset=0, size=None): if size is None: size = len(data)-offset if isinstance(data, bytes): view = memoryview(data) elif isinstance(data, bytesview): view = data.view else: raise TypeError('unsupported type: {}'.format(type(data))) self.view = view[offset:offset+size] def __len__(self): return len(self.view) def __getitem__(self, key): if isinstance(key, slice): return bytes(self.view[key]) return self.view[key] else: def bytesview(data, offset=0, size=None): if not isinstance(data, (bytes, buffer)): raise TypeError('unsupported type: {}'.format(type(data))) if size is None: size = len(data)-offset return buffer(data, offset, size) class Display(object): extension_major_opcodes = {} error_classes = error.xerror_class.copy() event_classes = event.event_class.copy() def __init__(self, display = None): name, protocol, host, displayno, screenno = connect.get_display(display) self.display_name = name self.default_screen = screenno self.socket = connect.get_socket(name, protocol, host, displayno) auth_name, auth_data = connect.get_auth(self.socket, name, protocol, host, displayno) # Internal structures for communication, grouped # by their function and locks # Socket error indicator, set when the socket is closed # in one way or another self.socket_error_lock = lock.allocate_lock() self.socket_error = None # Event queue self.event_queue_read_lock = lock.allocate_lock() self.event_queue_write_lock = lock.allocate_lock() self.event_queue = [] # Unsent request queue and sequence number counter self.request_queue_lock = lock.allocate_lock() self.request_serial = 1 self.request_queue = [] # Send-and-receive loop, see function send_and_receive # for a detailed explanation self.send_recv_lock = lock.allocate_lock() self.send_active = 0 self.recv_active = 0 self.event_waiting = 0 self.event_wait_lock = lock.allocate_lock() self.request_waiting = 0 self.request_wait_lock = lock.allocate_lock() # Calculate optimal default buffer size for recv. buffer_size = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF) buffer_size = math.pow(2, math.floor(math.log(buffer_size, 2))) self.recv_buffer_size = int(buffer_size) # Data used by the send-and-receive loop self.sent_requests = [] self.recv_packet_len = 0 self.data_send = b'' self.data_recv = b'' self.data_sent_bytes = 0 # Resource ID structures self.resource_id_lock = lock.allocate_lock() self.resource_ids = {} self.last_resource_id = 0 # Use an default error handler, one which just prints the error self.error_handler = None # Right, now we're all set up for the connection setup # request with the server. # Figure out which endianness the hardware uses self.big_endian = struct.unpack('BB', struct.pack('H', 0x0100))[0] if self.big_endian: order = 0x42 else: order = 0x6c # Send connection setup r = ConnectionSetupRequest(self, byte_order = order, protocol_major = 11, protocol_minor = 0, auth_prot_name = auth_name, auth_prot_data = auth_data) # Did connection fail? if r.status != 1: raise error.DisplayConnectionError(self.display_name, r.reason) # Set up remaining info self.info = r self.default_screen = min(self.default_screen, len(self.info.roots) - 1) # # Public interface # def get_display_name(self): return self.display_name def get_default_screen(self): return self.default_screen def fileno(self): self.check_for_error() return self.socket.fileno() def next_event(self): self.check_for_error() # Main lock, so that only one thread at a time performs the # event waiting code. This at least guarantees that the first # thread calling next_event() will get the next event, although # no order is guaranteed among other threads calling next_event() # while the first is blocking. self.event_queue_read_lock.acquire() # Lock event queue, so we can check if it is empty self.event_queue_write_lock.acquire() # We have too loop until we get an event, as # we might be woken up when there is no event. while not self.event_queue: # Lock send_recv so no send_and_receive # can start or stop while we're checking # whether there are one active. self.send_recv_lock.acquire() # Release event queue to allow an send_and_recv to # insert any now. self.event_queue_write_lock.release() # Call send_and_recv, which will return when # something has occured self.send_and_recv(event = True) # Before looping around, lock the event queue against # modifications. self.event_queue_write_lock.acquire() # Whiew, we have an event! Remove it from # the event queue and relaese its write lock. event = self.event_queue[0] del self.event_queue[0] self.event_queue_write_lock.release() # Finally, allow any other threads which have called next_event() # while we were waiting to proceed. self.event_queue_read_lock.release() # And return the event! return event def pending_events(self): self.check_for_error() # Make a send_and_recv pass, receiving any events self.send_recv_lock.acquire() self.send_and_recv(recv = True) # Lock the queue, get the event count, and unlock again. self.event_queue_write_lock.acquire() count = len(self.event_queue) self.event_queue_write_lock.release() return count def flush(self): self.check_for_error() self.send_recv_lock.acquire() self.send_and_recv(flush = True) def close(self): self.flush() self.close_internal('client') def set_error_handler(self, handler): self.error_handler = handler def allocate_resource_id(self): """id = d.allocate_resource_id() Allocate a new X resource id number ID. Raises ResourceIDError if there are no free resource ids. """ self.resource_id_lock.acquire() try: i = self.last_resource_id while i in self.resource_ids: i = i + 1 if i > self.info.resource_id_mask: i = 0 if i == self.last_resource_id: raise error.ResourceIDError('out of resource ids') self.resource_ids[i] = None self.last_resource_id = i return self.info.resource_id_base | i finally: self.resource_id_lock.release() def free_resource_id(self, rid): """d.free_resource_id(rid) Free resource id RID. Attempts to free a resource id which isn't allocated by us are ignored. """ self.resource_id_lock.acquire() try: i = rid & self.info.resource_id_mask # Attempting to free a resource id outside our range if rid - i != self.info.resource_id_base: return None try: del self.resource_ids[i] except KeyError: pass finally: self.resource_id_lock.release() def get_resource_class(self, class_name, default = None): """class = d.get_resource_class(class_name, default = None) Return the class to be used for X resource objects of type CLASS_NAME, or DEFAULT if no such class is set. """ return self.resource_classes.get(class_name, default) def set_extension_major(self, extname, major): self.extension_major_opcodes[extname] = major def get_extension_major(self, extname): return self.extension_major_opcodes[extname] def add_extension_event(self, code, evt, subcode=None): if subcode == None: self.event_classes[code] = evt else: if not code in self.event_classes: self.event_classes[code] = {subcode: evt} else: self.event_classes[code][subcode] = evt def add_extension_error(self, code, err): self.error_classes[code] = err # # Private functions # def check_for_error(self): self.socket_error_lock.acquire() err = self.socket_error self.socket_error_lock.release() if err: raise err def send_request(self, request, wait_for_response): if self.socket_error: raise self.socket_error self.request_queue_lock.acquire() request._serial = self.request_serial self.request_serial = (self.request_serial + 1) % 65536 self.request_queue.append((request, wait_for_response)) qlen = len(self.request_queue) self.request_queue_lock.release() # if qlen > 10: # self.flush() def close_internal(self, whom): # Clear out data structures self.request_queue = None self.sent_requests = None self.event_queue = None self.data_send = None self.data_recv = None # Close the connection self.socket.close() # Set a connection closed indicator self.socket_error_lock.acquire() self.socket_error = error.ConnectionClosedError(whom) self.socket_error_lock.release() def send_and_recv(self, flush = False, event = False, request = None, recv = False): """send_and_recv(flush = None, event = None, request = None, recv = None) Perform I/O, or wait for some other thread to do it for us. send_recv_lock MUST be LOCKED when send_and_recv is called. It will be UNLOCKED at return. Exactly or one of the parameters flush, event, request and recv must be set to control the return condition. To attempt to send all requests in the queue, flush should be true. Will return immediately if another thread is already doing send_and_recv. To wait for an event to be received, event should be true. To wait for a response to a certain request (either an error or a response), request should be set to that request's serial number. To just read any pending data from the server, recv should be true. It is not guaranteed that the return condition has been fulfilled when the function returns, so the caller has to loop until it is finished. """ # We go to sleep if there is already a thread doing what we # want to do: # If flushing, we want to send # If waiting for a response to a request, we want to send # (to ensure that the request was sent - we alway recv # when we get to the main loop, but sending is the important # thing here) # If waiting for an event, we want to recv # If just trying to receive anything we can, we want to recv # FIXME: It would be good if we could also sleep when we're waiting on # a response to a request that has already been sent. if (((flush or request is not None) and self.send_active) or ((event or recv) and self.recv_active)): # Signal that we are waiting for something. These locks # together with the *_waiting variables are used as # semaphores. When an event or a request response arrives, # it will zero the *_waiting and unlock the lock. The # locks will also be unlocked when an active send_and_recv # finishes to signal the other waiting threads that one of # them has to take over the send_and_recv function. # All this makes these locks and variables a part of the # send_and_recv control logic, and hence must be modified # only when we have the send_recv_lock locked. if event: wait_lock = self.event_wait_lock if not self.event_waiting: self.event_waiting = 1 wait_lock.acquire() elif request is not None: wait_lock = self.request_wait_lock if not self.request_waiting: self.request_waiting = 1 wait_lock.acquire() # Release send_recv, allowing a send_and_recive # to terminate or other threads to queue up self.send_recv_lock.release() # Return immediately if flushing, even if that # might mean that not necessarily all requests # have been sent. if flush or recv: return # Wait for something to happen, as the wait locks are # unlocked either when what we wait for has arrived (not # necessarily the exact object we're waiting for, though), # or when an active send_and_recv exits. # Release it immediately afterwards as we're only using # the lock for synchonization. Since we're not modifying # event_waiting or request_waiting here we don't have # to lock send_and_recv_lock. In fact, we can't do that # or we trigger a dead-lock. wait_lock.acquire() wait_lock.release() # Return to caller to let it check whether it has # got the data it was waiting for return # There's no thread doing what we need to do. Find out exactly # what to do # There must always be some thread receiving data, but it must not # necessarily be us if not self.recv_active: receiving = 1 self.recv_active = 1 else: receiving = 0 flush_bytes = None sending = 0 # Loop, receiving and sending data. while 1: # We might want to start sending data if sending or not self.send_active: # Turn all requests on request queue into binary form # and append them to self.data_send self.request_queue_lock.acquire() for req, wait in self.request_queue: self.data_send = self.data_send + req._binary if wait: self.sent_requests.append(req) del self.request_queue[:] self.request_queue_lock.release() # If there now is data to send, mark us as senders if self.data_send: self.send_active = 1 sending = 1 else: self.send_active = 0 sending = 0 # We've done all setup, so release the lock and start waiting # for the network to fire up self.send_recv_lock.release() # There's no longer anything useful we can do here. if not (sending or receiving): break # If we're flushing, figure out how many bytes we # have to send so that we're not caught in an interminable # loop if other threads continuously append requests. if flush and flush_bytes is None: flush_bytes = self.data_sent_bytes + len(self.data_send) try: # We're only checking for the socket to be writable # if we're the sending thread. We always check for it # to become readable: either we are the receiving thread # and should take care of the data, or the receiving thread # might finish receiving after having read the data if sending: writeset = [self.socket] else: writeset = [] # Timeout immediately if we're only checking for # something to read or if we're flushing, otherwise block if recv or flush: timeout = 0 else: timeout = None rs, ws, es = select.select([self.socket], writeset, [], timeout) # Ignore errors caused by a signal received while blocking. # All other errors are re-raised. except select.error as err: if isinstance(err, OSError): code = err.errno else: code = err[0] if code != errno.EINTR: raise # We must lock send_and_recv before we can loop to # the start of the loop self.send_recv_lock.acquire() continue # Socket is ready for sending data, send as much as possible. if ws: try: i = self.socket.send(self.data_send) except socket.error as err: self.close_internal('server: %s' % err) raise self.socket_error self.data_send = self.data_send[i:] self.data_sent_bytes = self.data_sent_bytes + i # There is data to read gotreq = 0 if rs: # We're the receiving thread, parse the data if receiving: try: count = self.recv_packet_len - len(self.data_recv) count = max(self.recv_buffer_size, count) bytes_recv = self.socket.recv(count) except socket.error as err: self.close_internal('server: %s' % err) raise self.socket_error if not bytes_recv: # Clear up, set a connection closed indicator and raise it self.close_internal('server') raise self.socket_error self.data_recv = bytes(self.data_recv) + bytes_recv gotreq = self.parse_response(request) # Otherwise return, allowing the calling thread to figure # out if it has got the data it needs else: # We must be a sending thread if we're here, so reset # that indicator. self.send_recv_lock.acquire() self.send_active = 0 self.send_recv_lock.release() # And return to the caller return # There are three different end of send-recv-loop conditions. # However, we don't leave the loop immediately, instead we # try to send and receive any data that might be left. We # do this by giving a timeout of 0 to select to poll # the socket. # When flushing: all requests have been sent if flush and flush_bytes >= self.data_sent_bytes: break # When waiting for an event: an event has been read if event and self.event_queue: break # When processing a certain request: got its reply if request is not None and gotreq: break # Always break if we just want to receive as much as possible if recv: break # Else there's may still data which must be sent, or # we haven't got the data we waited for. Lock and loop self.send_recv_lock.acquire() # We have accomplished the callers request. # Record that there are now no active send_and_recv, # and wake up all waiting thread self.send_recv_lock.acquire() if sending: self.send_active = 0 if receiving: self.recv_active = 0 if self.event_waiting: self.event_waiting = 0 self.event_wait_lock.release() if self.request_waiting: self.request_waiting = 0 self.request_wait_lock.release() self.send_recv_lock.release() def parse_response(self, request): """Internal method. Parse data received from server. If REQUEST is not None true is returned if the request with that serial number was received, otherwise false is returned. If REQUEST is -1, we're parsing the server connection setup response. """ if request == -1: return self.parse_connection_setup() # Parse ordinary server response gotreq = False while True: if self.data_recv: # Check the first byte to find out what kind of response it is rtype = byte2int(self.data_recv) # Are we're waiting for additional data for the current packet? if self.recv_packet_len: if len(self.data_recv) < self.recv_packet_len: return gotreq if rtype == 1: gotreq = self.parse_request_response(request) or gotreq continue elif rtype & 0x7f == ge.GenericEventCode: self.parse_event_response(rtype) continue else: raise AssertionError(rtype) # Every response is at least 32 bytes long, so don't bother # until we have received that much if len(self.data_recv) < 32: return gotreq # Error response if rtype == 0: gotreq = self.parse_error_response(request) or gotreq # Request response or generic event. elif rtype == 1 or rtype & 0x7f == ge.GenericEventCode: # Set reply length, and loop around to see if # we have got the full response rlen = int(struct.unpack('=L', self.data_recv[4:8])[0]) self.recv_packet_len = 32 + rlen * 4 # Else non-generic event else: self.parse_event_response(rtype) def parse_error_response(self, request): # Code is second byte code = indexbytes(self.data_recv, 1) # Fetch error class estruct = self.error_classes.get(code, error.XError) e = estruct(self, self.data_recv[:32]) self.data_recv = bytesview(self.data_recv, 32) # print 'recv Error:', e req = self.get_waiting_request(e.sequence_number) # Error for a request whose response we are waiting for, # or which have an error handler. However, if the error # handler indicates that it hasn't taken care of the # error, pass it on to the default error handler if req and req._set_error(e): # If this was a ReplyRequest, unlock any threads waiting # for a request to finish if isinstance(req, rq.ReplyRequest): self.send_recv_lock.acquire() if self.request_waiting: self.request_waiting = 0 self.request_wait_lock.release() self.send_recv_lock.release() return request == e.sequence_number # Else call the error handler else: if self.error_handler: rq.call_error_handler(self.error_handler, e, None) else: self.default_error_handler(e) return False def default_error_handler(self, err): sys.stderr.write('X protocol error:\n%s\n' % err) def parse_request_response(self, request): req = self.get_waiting_replyrequest() # Sequence number is always data[2:4] # Do sanity check before trying to parse the data sno = struct.unpack('=H', self.data_recv[2:4])[0] if sno != req._serial: raise RuntimeError("Expected reply for request %s, but got %s. Can't happen!" % (req._serial, sno)) req._parse_response(self.data_recv[:self.recv_packet_len]) # print 'recv Request:', req self.data_recv = bytesview(self.data_recv, self.recv_packet_len) self.recv_packet_len = 0 # Unlock any response waiting threads self.send_recv_lock.acquire() if self.request_waiting: self.request_waiting = 0 self.request_wait_lock.release() self.send_recv_lock.release() return req.sequence_number == request def parse_event_response(self, etype): # Skip bit 8, that is set if this event came from an SendEvent etype = etype & 0x7f if etype == ge.GenericEventCode: length = self.recv_packet_len else: length = 32 estruct = self.event_classes.get(etype, event.AnyEvent) if type(estruct) == dict: subcode = self.data_recv[1] # Python2 compatibility if type(subcode) == str: subcode = ord(subcode) # this etype refers to a set of sub-events with individual subcodes estruct = estruct[subcode] e = estruct(display = self, binarydata = self.data_recv[:length]) if etype == ge.GenericEventCode: self.recv_packet_len = 0 self.data_recv = bytesview(self.data_recv, length) # Drop all requests having an error handler, # but which obviously succeded. # Decrement it by one, so that we don't remove the request # that generated these events, if there is such a one. # Bug reported by Ilpo Nyyssönen # Note: not all events have a sequence_number field! # (e.g. KeymapNotify). if hasattr(e, 'sequence_number'): self.get_waiting_request((e.sequence_number - 1) % 65536) # print 'recv Event:', e # Insert the event into the queue self.event_queue_write_lock.acquire() self.event_queue.append(e) self.event_queue_write_lock.release() # Unlock any event waiting threads self.send_recv_lock.acquire() if self.event_waiting: self.event_waiting = 0 self.event_wait_lock.release() self.send_recv_lock.release() def get_waiting_request(self, sno): if not self.sent_requests: return None # Normalize sequence numbers, even if they have wrapped. # This ensures that # sno <= last_serial # and # self.sent_requests[0]._serial <= last_serial if self.sent_requests[0]._serial > self.request_serial: last_serial = self.request_serial + 65536 if sno < self.request_serial: sno = sno + 65536 else: last_serial = self.request_serial if sno > self.request_serial: sno = sno - 65536 # No matching events at all if sno < self.sent_requests[0]._serial: return None # Find last req <= sno req = None reqpos = len(self.sent_requests) adj = 0 last = 0 for i in range(0, len(self.sent_requests)): rno = self.sent_requests[i]._serial + adj # Did serial numbers just wrap around? if rno < last: adj = 65536 rno = rno + adj last = rno if sno == rno: req = self.sent_requests[i] reqpos = i + 1 break elif sno < rno: req = None reqpos = i break # Delete all request such as req <= sno del self.sent_requests[:reqpos] return req def get_waiting_replyrequest(self): for i in range(0, len(self.sent_requests)): if hasattr(self.sent_requests[i], '_reply'): req = self.sent_requests[i] del self.sent_requests[:i + 1] return req # Reply for an unknown request? No, that can't happen. else: raise RuntimeError("Request reply to unknown request. Can't happen!") def parse_connection_setup(self): """Internal function used to parse connection setup response. """ # Only the ConnectionSetupRequest has been sent so far r = self.sent_requests[0] while True: # print 'data_send:', repr(self.data_send) # print 'data_recv:', repr(self.data_recv) if r._data: alen = r._data['additional_length'] * 4 # The full response haven't arrived yet if len(self.data_recv) < alen: return False # Connection failed or further authentication is needed. # Set reason to the reason string if r._data['status'] != 1: r._data['reason'] = self.data_recv[:r._data['reason_length']] # Else connection succeeded, parse the reply else: x, d = r._success_reply.parse_binary(self.data_recv[:alen], self, rawdict = True) r._data.update(x) del self.sent_requests[0] self.data_recv = self.data_recv[alen:] return True else: # The base reply is 8 bytes long if len(self.data_recv) < 8: return False r._data, d = r._reply.parse_binary(self.data_recv[:8], self, rawdict = True) self.data_recv = self.data_recv[8:] # Loop around to see if we have got the additional data # already PixmapFormat = rq.Struct( rq.Card8('depth'), rq.Card8('bits_per_pixel'), rq.Card8('scanline_pad'), rq.Pad(5) ) VisualType = rq.Struct ( rq.Card32('visual_id'), rq.Card8('visual_class'), rq.Card8('bits_per_rgb_value'), rq.Card16('colormap_entries'), rq.Card32('red_mask'), rq.Card32('green_mask'), rq.Card32('blue_mask'), rq.Pad(4) ) Depth = rq.Struct( rq.Card8('depth'), rq.Pad(1), rq.LengthOf('visuals', 2), rq.Pad(4), rq.List('visuals', VisualType) ) Screen = rq.Struct( rq.Window('root'), rq.Colormap('default_colormap'), rq.Card32('white_pixel'), rq.Card32('black_pixel'), rq.Card32('current_input_mask'), rq.Card16('width_in_pixels'), rq.Card16('height_in_pixels'), rq.Card16('width_in_mms'), rq.Card16('height_in_mms'), rq.Card16('min_installed_maps'), rq.Card16('max_installed_maps'), rq.Card32('root_visual'), rq.Card8('backing_store'), rq.Card8('save_unders'), rq.Card8('root_depth'), rq.LengthOf('allowed_depths', 1), rq.List('allowed_depths', Depth) ) class ConnectionSetupRequest(rq.GetAttrData): _request = rq.Struct( rq.Set('byte_order', 1, (0x42, 0x6c)), rq.Pad(1), rq.Card16('protocol_major'), rq.Card16('protocol_minor'), rq.LengthOf('auth_prot_name', 2), rq.LengthOf('auth_prot_data', 2), rq.Pad(2), rq.String8('auth_prot_name'), rq.String8('auth_prot_data') ) _reply = rq.Struct ( rq.Card8('status'), rq.Card8('reason_length'), rq.Card16('protocol_major'), rq.Card16('protocol_minor'), rq.Card16('additional_length') ) _success_reply = rq.Struct( rq.Card32('release_number'), rq.Card32('resource_id_base'), rq.Card32('resource_id_mask'), rq.Card32('motion_buffer_size'), rq.LengthOf('vendor', 2), rq.Card16('max_request_length'), rq.LengthOf('roots', 1), rq.LengthOf('pixmap_formats', 1), rq.Card8('image_byte_order'), rq.Card8('bitmap_format_bit_order'), rq.Card8('bitmap_format_scanline_unit'), rq.Card8('bitmap_format_scanline_pad'), rq.Card8('min_keycode'), rq.Card8('max_keycode'), rq.Pad(4), rq.String8('vendor'), rq.List('pixmap_formats', PixmapFormat), rq.List('roots', Screen), ) def __init__(self, display, *args, **keys): self._binary = self._request.to_binary(*args, **keys) self._data = None # Don't bother about locking, since no other threads have # access to the display yet display.request_queue.append((self, True)) # However, we must lock send_and_recv, but we don't have # to loop. display.send_recv_lock.acquire() display.send_and_recv(request = -1) python-xlib-0.33/Xlib/protocol/event.py000066400000000000000000000360261435211557500201650ustar00rootroot00000000000000# Xlib.protocol.event -- definitions of core events # # Copyright (C) 2000-2002 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Xlib modules from .. import X # Xlib.protocol modules from . import rq class AnyEvent(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('detail'), rq.Card16('sequence_number'), rq.FixedBinary('data', 28), ) class KeyButtonPointer(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('detail'), rq.Card16('sequence_number'), rq.Card32('time'), rq.Window('root'), rq.Window('window'), rq.Window('child', (X.NONE, )), rq.Int16('root_x'), rq.Int16('root_y'), rq.Int16('event_x'), rq.Int16('event_y'), rq.Card16('state'), rq.Card8('same_screen'), rq.Pad(1), ) class KeyPress(KeyButtonPointer): _code = X.KeyPress class KeyRelease(KeyButtonPointer): _code = X.KeyRelease class ButtonPress(KeyButtonPointer): _code = X.ButtonPress class ButtonRelease(KeyButtonPointer): _code = X.ButtonRelease class MotionNotify(KeyButtonPointer): _code = X.MotionNotify class EnterLeave(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('detail'), rq.Card16('sequence_number'), rq.Card32('time'), rq.Window('root'), rq.Window('window'), rq.Window('child', (X.NONE, )), rq.Int16('root_x'), rq.Int16('root_y'), rq.Int16('event_x'), rq.Int16('event_y'), rq.Card16('state'), rq.Card8('mode'), rq.Card8('flags'), ) class EnterNotify(EnterLeave): _code = X.EnterNotify class LeaveNotify(EnterLeave): _code = X.LeaveNotify class Focus(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('detail'), rq.Card16('sequence_number'), rq.Window('window'), rq.Card8('mode'), rq.Pad(23), ) class FocusIn(Focus): _code = X.FocusIn class FocusOut(Focus): _code = X.FocusOut class Expose(rq.Event): _code = X.Expose _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('window'), rq.Card16('x'), rq.Card16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('count'), rq.Pad(14), ) class GraphicsExpose(rq.Event): _code = X.GraphicsExpose _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Drawable('drawable'), rq.Card16('x'), rq.Card16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('minor_event'), rq.Card16('count'), rq.Card8('major_event'), rq.Pad(11), ) class NoExpose(rq.Event): _code = X.NoExpose _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Drawable('window'), rq.Card16('minor_event'), rq.Card8('major_event'), rq.Pad(21), ) class VisibilityNotify(rq.Event): _code = X.VisibilityNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('window'), rq.Card8('state'), rq.Pad(23), ) class CreateNotify(rq.Event): _code = X.CreateNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('parent'), rq.Window('window'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('border_width'), rq.Card8('override'), rq.Pad(9), ) class DestroyNotify(rq.Event): _code = X.DestroyNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Pad(20), ) class UnmapNotify(rq.Event): _code = X.UnmapNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Card8('from_configure'), rq.Pad(19), ) class MapNotify(rq.Event): _code = X.MapNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Card8('override'), rq.Pad(19), ) class MapRequest(rq.Event): _code = X.MapRequest _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('parent'), rq.Window('window'), rq.Pad(20), ) class ReparentNotify(rq.Event): _code = X.ReparentNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Window('parent'), rq.Int16('x'), rq.Int16('y'), rq.Card8('override'), rq.Pad(11), ) class ConfigureNotify(rq.Event): _code = X.ConfigureNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Window('above_sibling', (X.NONE, )), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('border_width'), rq.Card8('override'), rq.Pad(5), ) class ConfigureRequest(rq.Event): _code = X.ConfigureRequest _fields = rq.Struct( rq.Card8('type'), rq.Card8('stack_mode'), rq.Card16('sequence_number'), rq.Window('parent'), rq.Window('window'), rq.Window('sibling', (X.NONE, )), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('border_width'), rq.Card16('value_mask'), rq.Pad(4), ) class GravityNotify(rq.Event): _code = X.GravityNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Int16('x'), rq.Int16('y'), rq.Pad(16), ) class ResizeRequest(rq.Event): _code = X.ResizeRequest _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('window'), rq.Card16('width'), rq.Card16('height'), rq.Pad(20), ) class Circulate(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Pad(4), rq.Card8('place'), rq.Pad(15), ) class CirculateNotify(Circulate): _code = X.CirculateNotify class CirculateRequest(Circulate): _code = X.CirculateRequest class PropertyNotify(rq.Event): _code = X.PropertyNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('window'), rq.Card32('atom'), rq.Card32('time'), rq.Card8('state'), rq.Pad(15), ) class SelectionClear(rq.Event): _code = X.SelectionClear _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Card32('time'), rq.Window('window'), rq.Card32('atom'), rq.Pad(16), ) class SelectionRequest(rq.Event): _code = X.SelectionRequest _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Card32('time'), rq.Window('owner'), rq.Window('requestor'), rq.Card32('selection'), rq.Card32('target'), rq.Card32('property'), rq.Pad(4), ) class SelectionNotify(rq.Event): _code = X.SelectionNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Card32('time'), rq.Window('requestor'), rq.Card32('selection'), rq.Card32('target'), rq.Card32('property'), rq.Pad(8), ) class ColormapNotify(rq.Event): _code = X.ColormapNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('window'), rq.Colormap('colormap', (X.NONE, )), rq.Card8('new'), rq.Card8('state'), rq.Pad(18), ) class MappingNotify(rq.Event): _code = X.MappingNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Card8('request'), rq.Card8('first_keycode'), rq.Card8('count'), rq.Pad(25), ) class ClientMessage(rq.Event): _code = X.ClientMessage _fields = rq.Struct( rq.Card8('type'), rq.Format('data', 1), rq.Card16('sequence_number'), rq.Window('window'), rq.Card32('client_type'), rq.FixedPropertyData('data', 20), ) class KeymapNotify(rq.Event): _code = X.KeymapNotify _fields = rq.Struct( rq.Card8('type'), rq.FixedList('data', 31, rq.Card8Obj, pad = 0) ) event_class = { X.KeyPress: KeyPress, X.KeyRelease: KeyRelease, X.ButtonPress: ButtonPress, X.ButtonRelease: ButtonRelease, X.MotionNotify: MotionNotify, X.EnterNotify: EnterNotify, X.LeaveNotify: LeaveNotify, X.FocusIn: FocusIn, X.FocusOut: FocusOut, X.KeymapNotify: KeymapNotify, X.Expose: Expose, X.GraphicsExpose: GraphicsExpose, X.NoExpose: NoExpose, X.VisibilityNotify: VisibilityNotify, X.CreateNotify: CreateNotify, X.DestroyNotify: DestroyNotify, X.UnmapNotify: UnmapNotify, X.MapNotify: MapNotify, X.MapRequest: MapRequest, X.ReparentNotify: ReparentNotify, X.ConfigureNotify: ConfigureNotify, X.ConfigureRequest: ConfigureRequest, X.GravityNotify: GravityNotify, X.ResizeRequest: ResizeRequest, X.CirculateNotify: CirculateNotify, X.CirculateRequest: CirculateRequest, X.PropertyNotify: PropertyNotify, X.SelectionClear: SelectionClear, X.SelectionRequest: SelectionRequest, X.SelectionNotify: SelectionNotify, X.ColormapNotify: ColormapNotify, X.ClientMessage: ClientMessage, X.MappingNotify: MappingNotify, } python-xlib-0.33/Xlib/protocol/request.py000066400000000000000000001347201435211557500205340ustar00rootroot00000000000000# Xlib.protocol.request -- definitions of core requests # # Copyright (C) 2000-2002 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Xlib modules from .. import X # Xlib.protocol modules from . import rq from . import structs class CreateWindow(rq.Request): _request = rq.Struct( rq.Opcode(1), rq.Card8('depth'), rq.RequestLength(), rq.Window('wid'), rq.Window('parent'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('border_width'), rq.Set('window_class', 2, (X.CopyFromParent, X.InputOutput, X.InputOnly)), rq.Card32('visual'), structs.WindowValues('attrs'), ) class ChangeWindowAttributes(rq.Request): _request = rq.Struct( rq.Opcode(2), rq.Pad(1), rq.RequestLength(), rq.Window('window'), structs.WindowValues('attrs'), ) class GetWindowAttributes(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(3), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('backing_store'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('visual'), rq.Card16('win_class'), rq.Card8('bit_gravity'), rq.Card8('win_gravity'), rq.Card32('backing_bit_planes'), rq.Card32('backing_pixel'), rq.Card8('save_under'), rq.Card8('map_is_installed'), rq.Card8('map_state'), rq.Card8('override_redirect'), rq.Colormap('colormap', (X.NONE, )), rq.Card32('all_event_masks'), rq.Card32('your_event_mask'), rq.Card16('do_not_propagate_mask'), rq.Pad(2), ) class DestroyWindow(rq.Request): _request = rq.Struct( rq.Opcode(4), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) class DestroySubWindows(rq.Request): _request = rq.Struct( rq.Opcode(5), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) class ChangeSaveSet(rq.Request): _request = rq.Struct( rq.Opcode(6), rq.Set('mode', 1, (X.SetModeInsert, X.SetModeDelete)), rq.RequestLength(), rq.Window('window'), ) class ReparentWindow(rq.Request): _request = rq.Struct( rq.Opcode(7), rq.Pad(1), rq.RequestLength(), rq.Window('window'), rq.Window('parent'), rq.Int16('x'), rq.Int16('y'), ) class MapWindow(rq.Request): _request = rq.Struct( rq.Opcode(8), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) class MapSubwindows(rq.Request): _request = rq.Struct( rq.Opcode(9), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) class UnmapWindow(rq.Request): _request = rq.Struct( rq.Opcode(10), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) class UnmapSubwindows(rq.Request): _request = rq.Struct( rq.Opcode(11), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) class ConfigureWindow(rq.Request): _request = rq.Struct( rq.Opcode(12), rq.Pad(1), rq.RequestLength(), rq.Window('window'), rq.ValueList( 'attrs', 2, 2, rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Int16('border_width'), rq.Window('sibling'), rq.Set('stack_mode', 1, (X.Above, X.Below, X.TopIf, X.BottomIf, X.Opposite)) ) ) class CirculateWindow(rq.Request): _request = rq.Struct( rq.Opcode(13), rq.Set('direction', 1, (X.RaiseLowest, X.LowerHighest)), rq.RequestLength(), rq.Window('window'), ) class GetGeometry(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(14), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable') ) _reply = rq.Struct ( rq.ReplyCode(), rq.Card8('depth'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('root'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('border_width'), rq.Pad(10) ) class QueryTree(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(15), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('root'), rq.Window('parent', (X.NONE, )), rq.LengthOf('children', 2), rq.Pad(14), rq.List('children', rq.WindowObj), ) class InternAtom(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(16), rq.Bool('only_if_exists'), rq.RequestLength(), rq.LengthOf('name', 2), rq.Pad(2), rq.String8('name'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('atom'), rq.Pad(20), ) class GetAtomName(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(17), rq.Pad(1), rq.RequestLength(), rq.Card32('atom') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('name', 2), rq.Pad(22), rq.String8('name'), ) class ChangeProperty(rq.Request): _request = rq.Struct( rq.Opcode(18), rq.Set('mode', 1, (X.PropModeReplace, X.PropModePrepend, X.PropModeAppend)), rq.RequestLength(), rq.Window('window'), rq.Card32('property'), rq.Card32('type'), rq.Format('data', 1), rq.Pad(3), rq.LengthOf('data', 4), rq.PropertyData('data'), ) class DeleteProperty(rq.Request): _request = rq.Struct( rq.Opcode(19), rq.Pad(1), rq.RequestLength(), rq.Window('window'), rq.Card32('property'), ) class GetProperty(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(20), rq.Bool('delete'), rq.RequestLength(), rq.Window('window'), rq.Card32('property'), rq.Card32('type'), rq.Card32('long_offset'), rq.Card32('long_length'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Format('value', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('property_type'), rq.Card32('bytes_after'), rq.LengthOf('value', 4), rq.Pad(12), rq.PropertyData('value'), ) class ListProperties(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(21), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('atoms', 2), rq.Pad(22), rq.List('atoms', rq.Card32Obj), ) class SetSelectionOwner(rq.Request): _request = rq.Struct( rq.Opcode(22), rq.Pad(1), rq.RequestLength(), rq.Window('window'), rq.Card32('selection'), rq.Card32('time'), ) class GetSelectionOwner(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(23), rq.Pad(1), rq.RequestLength(), rq.Card32('selection') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('owner', (X.NONE, )), rq.Pad(20), ) class ConvertSelection(rq.Request): _request = rq.Struct( rq.Opcode(24), rq.Pad(1), rq.RequestLength(), rq.Window('requestor'), rq.Card32('selection'), rq.Card32('target'), rq.Card32('property'), rq.Card32('time'), ) class SendEvent(rq.Request): _request = rq.Struct( rq.Opcode(25), rq.Bool('propagate'), rq.RequestLength(), rq.Window('destination'), rq.Card32('event_mask'), rq.EventField('event'), ) class GrabPointer(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(26), rq.Bool('owner_events'), rq.RequestLength(), rq.Window('grab_window'), rq.Card16('event_mask'), rq.Set('pointer_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Set('keyboard_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Window('confine_to', (X.NONE, )), rq.Cursor('cursor', (X.NONE, )), rq.Card32('time'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), ) class UngrabPointer(rq.Request): _request = rq.Struct( rq.Opcode(27), rq.Pad(1), rq.RequestLength(), rq.Card32('time') ) class GrabButton(rq.Request): _request = rq.Struct( rq.Opcode(28), rq.Bool('owner_events'), rq.RequestLength(), rq.Window('grab_window'), rq.Card16('event_mask'), rq.Set('pointer_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Set('keyboard_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Window('confine_to', (X.NONE, )), rq.Cursor('cursor', (X.NONE, )), rq.Card8('button'), rq.Pad(1), rq.Card16('modifiers'), ) class UngrabButton(rq.Request): _request = rq.Struct( rq.Opcode(29), rq.Card8('button'), rq.RequestLength(), rq.Window('grab_window'), rq.Card16('modifiers'), rq.Pad(2), ) class ChangeActivePointerGrab(rq.Request): _request = rq.Struct( rq.Opcode(30), rq.Pad(1), rq.RequestLength(), rq.Cursor('cursor'), rq.Card32('time'), rq.Card16('event_mask'), rq.Pad(2), ) class GrabKeyboard(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(31), rq.Bool('owner_events'), rq.RequestLength(), rq.Window('grab_window'), rq.Card32('time'), rq.Set('pointer_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Set('keyboard_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), ) class UngrabKeyboard(rq.Request): _request = rq.Struct( rq.Opcode(32), rq.Pad(1), rq.RequestLength(), rq.Card32('time') ) class GrabKey(rq.Request): _request = rq.Struct( rq.Opcode(33), rq.Bool('owner_events'), rq.RequestLength(), rq.Window('grab_window'), rq.Card16('modifiers'), rq.Card8('key'), rq.Set('pointer_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Set('keyboard_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Pad(3), ) class UngrabKey(rq.Request): _request = rq.Struct( rq.Opcode(34), rq.Card8('key'), rq.RequestLength(), rq.Window('grab_window'), rq.Card16('modifiers'), rq.Pad(2), ) class AllowEvents(rq.Request): _request = rq.Struct( rq.Opcode(35), rq.Set('mode', 1, (X.AsyncPointer, X.SyncPointer, X.ReplayPointer, X.AsyncKeyboard, X.SyncKeyboard, X.ReplayKeyboard, X.AsyncBoth, X.SyncBoth)), rq.RequestLength(), rq.Card32('time'), ) class GrabServer(rq.Request): _request = rq.Struct( rq.Opcode(36), rq.Pad(1), rq.RequestLength(), ) class UngrabServer(rq.Request): _request = rq.Struct( rq.Opcode(37), rq.Pad(1), rq.RequestLength(), ) class QueryPointer(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(38), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('same_screen'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('root'), rq.Window('child', (X.NONE, )), rq.Int16('root_x'), rq.Int16('root_y'), rq.Int16('win_x'), rq.Int16('win_y'), rq.Card16('mask'), rq.Pad(6), ) class GetMotionEvents(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(39), rq.Pad(1), rq.RequestLength(), rq.Window('window'), rq.Card32('start'), rq.Card32('stop'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('events', 4), rq.Pad(20), rq.List('events', structs.TimeCoord), ) class TranslateCoords(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(40), rq.Pad(1), rq.RequestLength(), rq.Window('src_wid'), rq.Window('dst_wid'), rq.Int16('src_x'), rq.Int16('src_y'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('same_screen'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('child', (X.NONE, )), rq.Int16('x'), rq.Int16('y'), rq.Pad(16), ) class WarpPointer(rq.Request): _request = rq.Struct( rq.Opcode(41), rq.Pad(1), rq.RequestLength(), rq.Window('src_window'), rq.Window('dst_window'), rq.Int16('src_x'), rq.Int16('src_y'), rq.Card16('src_width'), rq.Card16('src_height'), rq.Int16('dst_x'), rq.Int16('dst_y'), ) class SetInputFocus(rq.Request): _request = rq.Struct( rq.Opcode(42), rq.Set('revert_to', 1, (X.RevertToNone, X.RevertToPointerRoot, X.RevertToParent)), rq.RequestLength(), rq.Window('focus'), rq.Card32('time'), ) class GetInputFocus(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(43), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('revert_to'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('focus', (X.NONE, X.PointerRoot)), rq.Pad(20), ) class QueryKeymap(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(44), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.FixedList('map', 32, rq.Card8Obj), ) class OpenFont(rq.Request): _request = rq.Struct( rq.Opcode(45), rq.Pad(1), rq.RequestLength(), rq.Font('fid'), rq.LengthOf('name', 2), rq.Pad(2), rq.String8('name'), ) class CloseFont(rq.Request): _request = rq.Struct( rq.Opcode(46), rq.Pad(1), rq.RequestLength(), rq.Font('font') ) class QueryFont(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(47), rq.Pad(1), rq.RequestLength(), rq.Fontable('font') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Object('min_bounds', structs.CharInfo), rq.Pad(4), rq.Object('max_bounds', structs.CharInfo), rq.Pad(4), rq.Card16('min_char_or_byte2'), rq.Card16('max_char_or_byte2'), rq.Card16('default_char'), rq.LengthOf('properties', 2), rq.Card8('draw_direction'), rq.Card8('min_byte1'), rq.Card8('max_byte1'), rq.Card8('all_chars_exist'), rq.Int16('font_ascent'), rq.Int16('font_descent'), rq.LengthOf('char_infos', 4), rq.List('properties', structs.FontProp), rq.List('char_infos', structs.CharInfo), ) class QueryTextExtents(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(48), rq.OddLength('string'), rq.RequestLength(), rq.Fontable('font'), rq.String16('string'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('draw_direction'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Int16('font_ascent'), rq.Int16('font_descent'), rq.Int16('overall_ascent'), rq.Int16('overall_descent'), rq.Int32('overall_width'), rq.Int32('overall_left'), rq.Int32('overall_right'), rq.Pad(4), ) class ListFonts(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(49), rq.Pad(1), rq.RequestLength(), rq.Card16('max_names'), rq.LengthOf('pattern', 2), rq.String8('pattern'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('fonts', 2), rq.Pad(22), rq.List('fonts', rq.Str), ) class ListFontsWithInfo(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(50), rq.Pad(1), rq.RequestLength(), rq.Card16('max_names'), rq.LengthOf('pattern', 2), rq.String8('pattern'), ) _reply = rq.Struct( rq.ReplyCode(), rq.LengthOf('name', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Object('min_bounds', structs.CharInfo), rq.Pad(4), rq.Object('max_bounds', structs.CharInfo), rq.Pad(4), rq.Card16('min_char_or_byte2'), rq.Card16('max_char_or_byte2'), rq.Card16('default_char'), rq.LengthOf('properties', 2), rq.Card8('draw_direction'), rq.Card8('min_byte1'), rq.Card8('max_byte1'), rq.Card8('all_chars_exist'), rq.Int16('font_ascent'), rq.Int16('font_descent'), rq.Card32('replies_hint'), rq.List('properties', structs.FontProp), rq.String8('name'), ) # Somebody must have smoked some really wicked weed when they # defined the ListFontsWithInfo request: # The server sends a reply for _each_ matching font... # It then sends a special reply (name length == 0) to indicate # that there are no more fonts in the reply. # This means that we have to do some special parsing to see if # we have got the end-of-reply reply. If we haven't, we # have to reinsert the request in the front of the # display.sent_request queue to catch the next response. # Bastards. def __init__(self, *args, **keys): self._fonts = [] rq.ReplyRequest.__init__(self, *args, **keys) def _parse_response(self, data): if ord(data[1]) == 0: self._response_lock.acquire() self._data = self._fonts del self._fonts self._response_lock.release() return r, d = self._reply.parse_binary(data) self._fonts.append(r) self._display.sent_requests.insert(0, self) # Override the default __getattr__, since it isn't usable for # the list reply. Instead provide a __getitem__ and a __len__. def __getattr__(self, attr): raise AttributeError(attr) def __getitem__(self, item): return self._data[item] def __len__(self): return len(self._data) class SetFontPath(rq.Request): _request = rq.Struct( rq.Opcode(51), rq.Pad(1), rq.RequestLength(), rq.LengthOf('path', 2), rq.Pad(2), rq.List('path', rq.Str), ) class GetFontPath(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(52), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('paths', 2), rq.Pad(22), rq.List('paths', rq.Str), ) class CreatePixmap(rq.Request): _request = rq.Struct( rq.Opcode(53), rq.Card8('depth'), rq.RequestLength(), rq.Pixmap('pid'), rq.Drawable('drawable'), rq.Card16('width'), rq.Card16('height'), ) class FreePixmap(rq.Request): _request = rq.Struct( rq.Opcode(54), rq.Pad(1), rq.RequestLength(), rq.Pixmap('pixmap') ) class CreateGC(rq.Request): _request = rq.Struct( rq.Opcode(55), rq.Pad(1), rq.RequestLength(), rq.GC('cid'), rq.Drawable('drawable'), structs.GCValues('attrs'), ) class ChangeGC(rq.Request): _request = rq.Struct( rq.Opcode(56), rq.Pad(1), rq.RequestLength(), rq.GC('gc'), structs.GCValues('attrs'), ) class CopyGC(rq.Request): _request = rq.Struct( rq.Opcode(57), rq.Pad(1), rq.RequestLength(), rq.GC('src_gc'), rq.GC('dst_gc'), rq.Card32('mask'), ) class SetDashes(rq.Request): _request = rq.Struct( rq.Opcode(58), rq.Pad(1), rq.RequestLength(), rq.GC('gc'), rq.Card16('dash_offset'), rq.LengthOf('dashes', 2), rq.List('dashes', rq.Card8Obj), ) class SetClipRectangles(rq.Request): _request = rq.Struct( rq.Opcode(59), rq.Set('ordering', 1, (X.Unsorted, X.YSorted, X.YXSorted, X.YXBanded)), rq.RequestLength(), rq.GC('gc'), rq.Int16('x_origin'), rq.Int16('y_origin'), rq.List('rectangles', structs.Rectangle), ) class FreeGC(rq.Request): _request = rq.Struct( rq.Opcode(60), rq.Pad(1), rq.RequestLength(), rq.GC('gc') ) class ClearArea(rq.Request): _request = rq.Struct( rq.Opcode(61), rq.Bool('exposures'), rq.RequestLength(), rq.Window('window'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), ) class CopyArea(rq.Request): _request = rq.Struct( rq.Opcode(62), rq.Pad(1), rq.RequestLength(), rq.Drawable('src_drawable'), rq.Drawable('dst_drawable'), rq.GC('gc'), rq.Int16('src_x'), rq.Int16('src_y'), rq.Int16('dst_x'), rq.Int16('dst_y'), rq.Card16('width'), rq.Card16('height'), ) class CopyPlane(rq.Request): _request = rq.Struct( rq.Opcode(63), rq.Pad(1), rq.RequestLength(), rq.Drawable('src_drawable'), rq.Drawable('dst_drawable'), rq.GC('gc'), rq.Int16('src_x'), rq.Int16('src_y'), rq.Int16('dst_x'), rq.Int16('dst_y'), rq.Card16('width'), rq.Card16('height'), rq.Card32('bit_plane'), ) class PolyPoint(rq.Request): _request = rq.Struct( rq.Opcode(64), rq.Set('coord_mode', 1, (X.CoordModeOrigin, X.CoordModePrevious)), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('points', structs.Point), ) class PolyLine(rq.Request): _request = rq.Struct( rq.Opcode(65), rq.Set('coord_mode', 1, (X.CoordModeOrigin, X.CoordModePrevious)), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('points', structs.Point), ) class PolySegment(rq.Request): _request = rq.Struct( rq.Opcode(66), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('segments', structs.Segment), ) class PolyRectangle(rq.Request): _request = rq.Struct( rq.Opcode(67), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('rectangles', structs.Rectangle), ) class PolyArc(rq.Request): _request = rq.Struct( rq.Opcode(68), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('arcs', structs.Arc), ) class FillPoly(rq.Request): _request = rq.Struct( rq.Opcode(69), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Set('shape', 1, (X.Complex, X.Nonconvex, X.Convex)), rq.Set('coord_mode', 1, (X.CoordModeOrigin, X.CoordModePrevious)), rq.Pad(2), rq.List('points', structs.Point), ) class PolyFillRectangle(rq.Request): _request = rq.Struct( rq.Opcode(70), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('rectangles', structs.Rectangle), ) class PolyFillArc(rq.Request): _request = rq.Struct( rq.Opcode(71), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('arcs', structs.Arc), ) class PutImage(rq.Request): _request = rq.Struct( rq.Opcode(72), rq.Set('format', 1, (X.XYBitmap, X.XYPixmap, X.ZPixmap)), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Card16('width'), rq.Card16('height'), rq.Int16('dst_x'), rq.Int16('dst_y'), rq.Card8('left_pad'), rq.Card8('depth'), rq.Pad(2), rq.Binary('data'), ) class GetImage(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(73), rq.Set('format', 1, (X.XYPixmap, X.ZPixmap)), rq.RequestLength(), rq.Drawable('drawable'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card32('plane_mask'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('depth'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('visual'), rq.Pad(20), rq.Binary('data'), ) class PolyText8(rq.Request): _request = rq.Struct( rq.Opcode(74), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Int16('x'), rq.Int16('y'), rq.TextElements8('items'), ) class PolyText16(rq.Request): _request = rq.Struct( rq.Opcode(75), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Int16('x'), rq.Int16('y'), rq.TextElements16('items'), ) class ImageText8(rq.Request): _request = rq.Struct( rq.Opcode(76), rq.LengthOf('string', 1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Int16('x'), rq.Int16('y'), rq.String8('string'), ) class ImageText16(rq.Request): _request = rq.Struct( rq.Opcode(77), rq.LengthOf('string', 1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Int16('x'), rq.Int16('y'), rq.String16('string'), ) class CreateColormap(rq.Request): _request = rq.Struct( rq.Opcode(78), rq.Set('alloc', 1, (X.AllocNone, X.AllocAll)), rq.RequestLength(), rq.Colormap('mid'), rq.Window('window'), rq.Card32('visual'), ) class FreeColormap(rq.Request): _request = rq.Struct( rq.Opcode(79), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap') ) class CopyColormapAndFree(rq.Request): _request = rq.Struct( rq.Opcode(80), rq.Pad(1), rq.RequestLength(), rq.Colormap('mid'), rq.Colormap('src_cmap'), ) class InstallColormap(rq.Request): _request = rq.Struct( rq.Opcode(81), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap') ) class UninstallColormap(rq.Request): _request = rq.Struct( rq.Opcode(82), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap') ) class ListInstalledColormaps(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(83), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('cmaps', 2), rq.Pad(22), rq.List('cmaps', rq.ColormapObj), ) class AllocColor(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(84), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap'), rq.Card16('red'), rq.Card16('green'), rq.Card16('blue'), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('red'), rq.Card16('green'), rq.Card16('blue'), rq.Pad(2), rq.Card32('pixel'), rq.Pad(12), ) class AllocNamedColor(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(85), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap'), rq.LengthOf('name', 2), rq.Pad(2), rq.String8('name'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('pixel'), rq.Card16('exact_red'), rq.Card16('exact_green'), rq.Card16('exact_blue'), rq.Card16('screen_red'), rq.Card16('screen_green'), rq.Card16('screen_blue'), rq.Pad(8), ) class AllocColorCells(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(86), rq.Bool('contiguous'), rq.RequestLength(), rq.Colormap('cmap'), rq.Card16('colors'), rq.Card16('planes'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('pixels', 2), rq.LengthOf('masks', 2), rq.Pad(20), rq.List('pixels', rq.Card32Obj), rq.List('masks', rq.Card32Obj), ) class AllocColorPlanes(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(87), rq.Bool('contiguous'), rq.RequestLength(), rq.Colormap('cmap'), rq.Card16('colors'), rq.Card16('red'), rq.Card16('green'), rq.Card16('blue'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('pixels', 2), rq.Pad(2), rq.Card32('red_mask'), rq.Card32('green_mask'), rq.Card32('blue_mask'), rq.Pad(8), rq.List('pixels', rq.Card32Obj), ) class FreeColors(rq.Request): _request = rq.Struct( rq.Opcode(88), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap'), rq.Card32('plane_mask'), rq.List('pixels', rq.Card32Obj), ) class StoreColors(rq.Request): _request = rq.Struct( rq.Opcode(89), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap'), rq.List('items', structs.ColorItem), ) class StoreNamedColor(rq.Request): _request = rq.Struct( rq.Opcode(90), rq.Card8('flags'), rq.RequestLength(), rq.Colormap('cmap'), rq.Card32('pixel'), rq.LengthOf('name', 2), rq.Pad(2), rq.String8('name'), ) class QueryColors(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(91), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap'), rq.List('pixels', rq.Card32Obj), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('colors', 2), rq.Pad(22), rq.List('colors', structs.RGB), ) class LookupColor(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(92), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap'), rq.LengthOf('name', 2), rq.Pad(2), rq.String8('name'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('exact_red'), rq.Card16('exact_green'), rq.Card16('exact_blue'), rq.Card16('screen_red'), rq.Card16('screen_green'), rq.Card16('screen_blue'), rq.Pad(12), ) class CreateCursor(rq.Request): _request = rq.Struct( rq.Opcode(93), rq.Pad(1), rq.RequestLength(), rq.Cursor('cid'), rq.Pixmap('source'), rq.Pixmap('mask'), rq.Card16('fore_red'), rq.Card16('fore_green'), rq.Card16('fore_blue'), rq.Card16('back_red'), rq.Card16('back_green'), rq.Card16('back_blue'), rq.Card16('x'), rq.Card16('y'), ) class CreateGlyphCursor(rq.Request): _request = rq.Struct( rq.Opcode(94), rq.Pad(1), rq.RequestLength(), rq.Cursor('cid'), rq.Font('source'), rq.Font('mask'), rq.Card16('source_char'), rq.Card16('mask_char'), rq.Card16('fore_red'), rq.Card16('fore_green'), rq.Card16('fore_blue'), rq.Card16('back_red'), rq.Card16('back_green'), rq.Card16('back_blue'), ) class FreeCursor(rq.Request): _request = rq.Struct( rq.Opcode(95), rq.Pad(1), rq.RequestLength(), rq.Cursor('cursor') ) class RecolorCursor(rq.Request): _request = rq.Struct( rq.Opcode(96), rq.Pad(1), rq.RequestLength(), rq.Cursor('cursor'), rq.Card16('fore_red'), rq.Card16('fore_green'), rq.Card16('fore_blue'), rq.Card16('back_red'), rq.Card16('back_green'), rq.Card16('back_blue'), ) class QueryBestSize(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(97), rq.Set('item_class', 1, (X.CursorShape, X.TileShape, X.StippleShape)), rq.RequestLength(), rq.Drawable('drawable'), rq.Card16('width'), rq.Card16('height'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('width'), rq.Card16('height'), rq.Pad(20), ) class QueryExtension(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(98), rq.Pad(1), rq.RequestLength(), rq.LengthOf('name', 2), rq.Pad(2), rq.String8('name'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card8('present'), rq.Card8('major_opcode'), rq.Card8('first_event'), rq.Card8('first_error'), rq.Pad(20), ) class ListExtensions(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(99), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.LengthOf('names', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), rq.List('names', rq.Str), ) class ChangeKeyboardMapping(rq.Request): _request = rq.Struct( rq.Opcode(100), rq.LengthOf('keysyms', 1), rq.RequestLength(), rq.Card8('first_keycode'), rq.Format('keysyms', 1), rq.Pad(2), rq.KeyboardMapping('keysyms'), ) class GetKeyboardMapping(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(101), rq.Pad(1), rq.RequestLength(), rq.Card8('first_keycode'), rq.Card8('count'), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Format('keysyms', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), rq.KeyboardMapping('keysyms'), ) class ChangeKeyboardControl(rq.Request): _request = rq.Struct( rq.Opcode(102), rq.Pad(1), rq.RequestLength(), rq.ValueList( 'attrs', 4, 0, rq.Int8('key_click_percent'), rq.Int8('bell_percent'), rq.Int16('bell_pitch'), rq.Int16('bell_duration'), rq.Card8('led'), rq.Set('led_mode', 1, (X.LedModeOff, X.LedModeOn)), rq.Card8('key'), rq.Set('auto_repeat_mode', 1, (X.AutoRepeatModeOff, X.AutoRepeatModeOn, X.AutoRepeatModeDefault)) ) ) class GetKeyboardControl(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(103), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('global_auto_repeat'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('led_mask'), rq.Card8('key_click_percent'), rq.Card8('bell_percent'), rq.Card16('bell_pitch'), rq.Card16('bell_duration'), rq.Pad(2), rq.FixedList('auto_repeats', 32, rq.Card8Obj), ) class Bell(rq.Request): _request = rq.Struct( rq.Opcode(104), rq.Int8('percent'), rq.RequestLength(), ) class ChangePointerControl(rq.Request): _request = rq.Struct( rq.Opcode(105), rq.Pad(1), rq.RequestLength(), rq.Int16('accel_num'), rq.Int16('accel_denum'), rq.Int16('threshold'), rq.Bool('do_accel'), rq.Bool('do_thresh'), ) class GetPointerControl(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(106), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('accel_num'), rq.Card16('accel_denom'), rq.Card16('threshold'), rq.Pad(18), ) class SetScreenSaver(rq.Request): _request = rq.Struct( rq.Opcode(107), rq.Pad(1), rq.RequestLength(), rq.Int16('timeout'), rq.Int16('interval'), rq.Set('prefer_blank', 1, (X.DontPreferBlanking, X.PreferBlanking, X.DefaultBlanking)), rq.Set('allow_exposures', 1, (X.DontAllowExposures, X.AllowExposures, X.DefaultExposures)), rq.Pad(2), ) class GetScreenSaver(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(108), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('timeout'), rq.Card16('interval'), rq.Card8('prefer_blanking'), rq.Card8('allow_exposures'), rq.Pad(18), ) class ChangeHosts(rq.Request): _request = rq.Struct( rq.Opcode(109), rq.Set('mode', 1, (X.HostInsert, X.HostDelete)), rq.RequestLength(), rq.Set('host_family', 1, (X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos, X.FamilyServerInterpreted, X.FamilyInternetV6)), rq.Pad(1), rq.LengthOf('host', 2), rq.List('host', rq.Card8Obj) ) class ListHosts(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(110), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('mode'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('hosts', 2), rq.Pad(22), rq.List('hosts', structs.Host), ) class SetAccessControl(rq.Request): _request = rq.Struct( rq.Opcode(111), rq.Set('mode', 1, (X.DisableAccess, X.EnableAccess)), rq.RequestLength(), ) class SetCloseDownMode(rq.Request): _request = rq.Struct( rq.Opcode(112), rq.Set('mode', 1, (X.DestroyAll, X.RetainPermanent, X.RetainTemporary)), rq.RequestLength(), ) class KillClient(rq.Request): _request = rq.Struct( rq.Opcode(113), rq.Pad(1), rq.RequestLength(), rq.Resource('resource') ) class RotateProperties(rq.Request): _request = rq.Struct( rq.Opcode(114), rq.Pad(1), rq.RequestLength(), rq.Window('window'), rq.LengthOf('properties', 2), rq.Int16('delta'), rq.List('properties', rq.Card32Obj), ) class ForceScreenSaver(rq.Request): _request = rq.Struct( rq.Opcode(115), rq.Set('mode', 1, (X.ScreenSaverReset, X.ScreenSaverActive)), rq.RequestLength(), ) class SetPointerMapping(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(116), rq.LengthOf('map', 1), rq.RequestLength(), rq.List('map', rq.Card8Obj), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), ) class GetPointerMapping(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(117), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.LengthOf('map', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), rq.List('map', rq.Card8Obj), ) class SetModifierMapping(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(118), rq.Format('keycodes', 1), rq.RequestLength(), rq.ModifierMapping('keycodes') ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), ) class GetModifierMapping(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(119), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Format('keycodes', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), rq.ModifierMapping('keycodes') ) class NoOperation(rq.Request): _request = rq.Struct( rq.Opcode(127), rq.Pad(1), rq.RequestLength(), ) major_codes = { 1: CreateWindow, 2: ChangeWindowAttributes, 3: GetWindowAttributes, 4: DestroyWindow, 5: DestroySubWindows, 6: ChangeSaveSet, 7: ReparentWindow, 8: MapWindow, 9: MapSubwindows, 10: UnmapWindow, 11: UnmapSubwindows, 12: ConfigureWindow, 13: CirculateWindow, 14: GetGeometry, 15: QueryTree, 16: InternAtom, 17: GetAtomName, 18: ChangeProperty, 19: DeleteProperty, 20: GetProperty, 21: ListProperties, 22: SetSelectionOwner, 23: GetSelectionOwner, 24: ConvertSelection, 25: SendEvent, 26: GrabPointer, 27: UngrabPointer, 28: GrabButton, 29: UngrabButton, 30: ChangeActivePointerGrab, 31: GrabKeyboard, 32: UngrabKeyboard, 33: GrabKey, 34: UngrabKey, 35: AllowEvents, 36: GrabServer, 37: UngrabServer, 38: QueryPointer, 39: GetMotionEvents, 40: TranslateCoords, 41: WarpPointer, 42: SetInputFocus, 43: GetInputFocus, 44: QueryKeymap, 45: OpenFont, 46: CloseFont, 47: QueryFont, 48: QueryTextExtents, 49: ListFonts, 50: ListFontsWithInfo, 51: SetFontPath, 52: GetFontPath, 53: CreatePixmap, 54: FreePixmap, 55: CreateGC, 56: ChangeGC, 57: CopyGC, 58: SetDashes, 59: SetClipRectangles, 60: FreeGC, 61: ClearArea, 62: CopyArea, 63: CopyPlane, 64: PolyPoint, 65: PolyLine, 66: PolySegment, 67: PolyRectangle, 68: PolyArc, 69: FillPoly, 70: PolyFillRectangle, 71: PolyFillArc, 72: PutImage, 73: GetImage, 74: PolyText8, 75: PolyText16, 76: ImageText8, 77: ImageText16, 78: CreateColormap, 79: FreeColormap, 80: CopyColormapAndFree, 81: InstallColormap, 82: UninstallColormap, 83: ListInstalledColormaps, 84: AllocColor, 85: AllocNamedColor, 86: AllocColorCells, 87: AllocColorPlanes, 88: FreeColors, 89: StoreColors, 90: StoreNamedColor, 91: QueryColors, 92: LookupColor, 93: CreateCursor, 94: CreateGlyphCursor, 95: FreeCursor, 96: RecolorCursor, 97: QueryBestSize, 98: QueryExtension, 99: ListExtensions, 100: ChangeKeyboardMapping, 101: GetKeyboardMapping, 102: ChangeKeyboardControl, 103: GetKeyboardControl, 104: Bell, 105: ChangePointerControl, 106: GetPointerControl, 107: SetScreenSaver, 108: GetScreenSaver, 109: ChangeHosts, 110: ListHosts, 111: SetAccessControl, 112: SetCloseDownMode, 113: KillClient, 114: RotateProperties, 115: ForceScreenSaver, 116: SetPointerMapping, 117: GetPointerMapping, 118: SetModifierMapping, 119: GetModifierMapping, 127: NoOperation, } python-xlib-0.33/Xlib/protocol/rq.py000066400000000000000000001250651435211557500174700ustar00rootroot00000000000000# Xlib.protocol.rq -- structure primitives for request, events and errors # # Copyright (C) 2000-2002 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Standard modules import sys import traceback import struct from array import array # Python 2/3 compatibility. from six import PY3, binary_type, byte2int, indexbytes, iterbytes # Xlib modules from .. import X from ..support import lock def decode_string(bs): return bs.decode('latin1') if PY3: def encode_array(a): return a.tobytes() else: def encode_array(a): return a.tostring() class BadDataError(Exception): pass # These are struct codes, we know their byte sizes signed_codes = { 1: 'b', 2: 'h', 4: 'l' } unsigned_codes = { 1: 'B', 2: 'H', 4: 'L' } # Unfortunately, we don't know the array sizes of B, H and L, since # these use the underlying architecture's size for a char, short and # long. Therefore we probe for their sizes, and additionally create # a mapping that translates from struct codes to array codes. # # Bleah. array_unsigned_codes = { } struct_to_array_codes = { } for c in 'bhil': size = array(c).itemsize array_unsigned_codes[size] = c.upper() try: struct_to_array_codes[signed_codes[size]] = c struct_to_array_codes[unsigned_codes[size]] = c.upper() except KeyError: pass # print array_unsigned_codes, struct_to_array_codes class Field(object): """Field objects represent the data fields of a Struct. Field objects must have the following attributes: name -- the field name, or None structcode -- the struct codes representing this field structvalues -- the number of values encodes by structcode Additionally, these attributes should either be None or real methods: check_value -- check a value before it is converted to binary parse_value -- parse a value after it has been converted from binary If one of these attributes are None, no check or additional parsings will be done one values when converting to or from binary form. Otherwise, the methods should have the following behaviour: newval = check_value(val) Check that VAL is legal when converting to binary form. The value can also be converted to another Python value. In any case, return the possibly new value. NEWVAL should be a single Python value if structvalues is 1, a tuple of structvalues elements otherwise. newval = parse_value(val, display) VAL is an unpacked Python value, which now can be further refined. DISPLAY is the current Display object. Return the new value. VAL will be a single value if structvalues is 1, a tuple of structvalues elements otherwise. If `structcode' is None the Field must have the method f.parse_binary_value() instead. See its documentation string for details. """ name = None default = None structcode = None structvalues = 0 check_value = None parse_value = None keyword_args = False def __init__(self): pass def parse_binary_value(self, data, display, length, format): """value, remaindata = f.parse_binary_value(data, display, length, format) Decode a value for this field from the binary string DATA. If there are a LengthField and/or a FormatField connected to this field, their values will be LENGTH and FORMAT, respectively. If there are no such fields the parameters will be None. DISPLAY is the display involved, which is really only used by the Resource fields. The decoded value is returned as VALUE, and the remaining part of DATA shold be returned as REMAINDATA. """ raise RuntimeError('Neither structcode or parse_binary_value ' \ 'provided for {0}'.format(self)) class Pad(Field): def __init__(self, size): self.size = size self.value = b'\0' * size self.structcode = '{0}x'.format(size) self.structvalues = 0 class ConstantField(Field): def __init__(self, value): self.value = value class Opcode(ConstantField): structcode = 'B' structvalues = 1 class ReplyCode(ConstantField): structcode = 'B' structvalues = 1 def __init__(self): self.value = 1 class LengthField(Field): """A LengthField stores the length of some other Field whose size may vary, e.g. List and String8. Its name should be the same as the name of the field whose size it stores. The other_fields attribute can be used to specify the names of other fields whose sizes are stored by this field, so a single length field can set the length of multiple fields. The lf.get_binary_value() method of LengthFields is not used, instead a lf.get_binary_length() should be provided. Unless LengthField.get_binary_length() is overridden in child classes, there should also be a lf.calc_length(). """ structcode = 'L' structvalues = 1 other_fields = None def calc_length(self, length): """newlen = lf.calc_length(length) Return a new length NEWLEN based on the provided LENGTH. """ return length class TotalLengthField(LengthField): pass class RequestLength(TotalLengthField): structcode = 'H' structvalues = 1 def calc_length(self, length): return length // 4 class ReplyLength(TotalLengthField): structcode = 'L' structvalues = 1 def calc_length(self, length): return (length - 32) // 4 class LengthOf(LengthField): def __init__(self, name, size): if isinstance(name, (list, tuple)): self.name = name[0] self.other_fields = name[1:] else: self.name = name self.structcode = unsigned_codes[size] class OddLength(LengthField): structcode = 'B' structvalues = 1 def __init__(self, name): self.name = name def calc_length(self, length): return length % 2 def parse_value(self, value, display): if value == 0: return 'even' else: return 'odd' class FormatField(Field): """A FormatField encodes the format of some other field, in a manner similar to LengthFields. The ff.get_binary_value() method is not used, replaced by ff.get_binary_format(). """ structvalues = 1 def __init__(self, name, size): self.name = name self.structcode = unsigned_codes[size] Format = FormatField class ValueField(Field): def __init__(self, name, default = None): self.name = name self.default = default class Int8(ValueField): structcode = 'b' structvalues = 1 class Int16(ValueField): structcode = 'h' structvalues = 1 class Int32(ValueField): structcode = 'l' structvalues = 1 class Card8(ValueField): structcode = 'B' structvalues = 1 class Card16(ValueField): structcode = 'H' structvalues = 1 class Card32(ValueField): structcode = 'L' structvalues = 1 class Resource(Card32): cast_function = '__resource__' class_name = 'resource' def __init__(self, name, codes = (), default = None): Card32.__init__(self, name, default) self.codes = codes def check_value(self, value): if hasattr(value, self.cast_function): return getattr(value, self.cast_function)() else: return value def parse_value(self, value, display): # if not display: # return value if value in self.codes: return value c = display.get_resource_class(self.class_name) if c: return c(display, value) else: return value class Window(Resource): cast_function = '__window__' class_name = 'window' class Pixmap(Resource): cast_function = '__pixmap__' class_name = 'pixmap' class Drawable(Resource): cast_function = '__drawable__' class_name = 'drawable' class Fontable(Resource): cast_function = '__fontable__' class_name = 'fontable' class Font(Resource): cast_function = '__font__' class_name = 'font' class GC(Resource): cast_function = '__gc__' class_name = 'gc' class Colormap(Resource): cast_function = '__colormap__' class_name = 'colormap' class Cursor(Resource): cast_function = '__cursor__' class_name = 'cursor' class Bool(ValueField): structvalues = 1 structcode = 'B' def check_value(self, value): return not not value class Set(ValueField): structvalues = 1 def __init__(self, name, size, values, default = None): ValueField.__init__(self, name, default) self.structcode = unsigned_codes[size] self.values = values def check_value(self, val): if val not in self.values: raise ValueError('field %s: argument %s not in %s' % (self.name, val, self.values)) return val class Gravity(Set): def __init__(self, name): Set.__init__(self, name, 1, (X.ForgetGravity, X.StaticGravity, X.NorthWestGravity, X.NorthGravity, X.NorthEastGravity, X.WestGravity, X.CenterGravity, X.EastGravity, X.SouthWestGravity, X.SouthGravity, X.SouthEastGravity)) class FixedBinary(ValueField): structvalues = 1 def __init__(self, name, size): ValueField.__init__(self, name) self.structcode = '{0}s'.format(size) class Binary(ValueField): structcode = None def __init__(self, name, pad = 1): ValueField.__init__(self, name) self.pad = pad def pack_value(self, val): val_bytes = val slen = len(val_bytes) if self.pad: return val_bytes + b'\0' * ((4 - slen % 4) % 4), slen, None else: return val_bytes, slen, None def parse_binary_value(self, data, display, length, format): if length is None: return data, b'' if self.pad: slen = length + ((4 - length % 4) % 4) else: slen = length return data[:length], data[slen:] class String8(ValueField): structcode = None def __init__(self, name, pad = 1): ValueField.__init__(self, name) self.pad = pad def pack_value(self, val): if isinstance(val, bytes): val_bytes = val else: val_bytes = val.encode() slen = len(val_bytes) if self.pad: return val_bytes + b'\0' * ((4 - slen % 4) % 4), slen, None else: return val_bytes, slen, None def parse_binary_value(self, data, display, length, format): if length is None: return decode_string(data), b'' if self.pad: slen = length + ((4 - length % 4) % 4) else: slen = length data_str = decode_string(data[:length]) return data_str, data[slen:] class String16(ValueField): structcode = None def __init__(self, name, pad = 1): ValueField.__init__(self, name) self.pad = pad def pack_value(self, val): """Convert 8-byte string into 16-byte list""" if isinstance(val, bytes): val = list(iterbytes(val)) slen = len(val) if self.pad: pad = b'\0\0' * (slen % 2) else: pad = b'' return struct.pack('>' + 'H' * slen, *val) + pad, slen, None def parse_binary_value(self, data, display, length, format): if length == 'odd': length = len(data) // 2 - 1 elif length == 'even': length = len(data) // 2 if self.pad: slen = length + (length % 2) else: slen = length return struct.unpack('>' + 'H' * length, data[:length * 2]), data[slen * 2:] class List(ValueField): """The List, FixedList and Object fields store compound data objects. The type of data objects must be provided as an object with the following attributes and methods: ... """ structcode = None def __init__(self, name, type, pad = 1): ValueField.__init__(self, name) self.type = type self.pad = pad def parse_binary_value(self, data, display, length, format): if length is None: ret = [] if self.type.structcode is None: while data: val, data = self.type.parse_binary(data, display) ret.append(val) else: scode = '=' + self.type.structcode slen = struct.calcsize(scode) pos = 0 while pos + slen <= len(data): v = struct.unpack(scode, data[pos: pos + slen]) if self.type.structvalues == 1: v = v[0] if self.type.parse_value is None: ret.append(v) else: ret.append(self.type.parse_value(v, display)) pos = pos + slen data = data[pos:] else: ret = [None] * int(length) if self.type.structcode is None: for i in range(0, length): ret[i], data = self.type.parse_binary(data, display) else: scode = '=' + self.type.structcode slen = struct.calcsize(scode) pos = 0 for i in range(0, length): v = struct.unpack(scode, data[pos: pos + slen]) if self.type.structvalues == 1: v = v[0] if self.type.parse_value is None: ret[i] = v else: ret[i] = self.type.parse_value(v, display) pos = pos + slen data = data[pos:] if self.pad: data = data[len(data) % 4:] return ret, data def pack_value(self, val): # Single-char values, we'll assume that means integer lists. if self.type.structcode and len(self.type.structcode) == 1: if self.type.check_value is not None: val = [self.type.check_value(v) for v in val] a = array(struct_to_array_codes[self.type.structcode], val) data = encode_array(a) else: data = [] for v in val: data.append(self.type.pack_value(v)) data = b''.join(data) if self.pad: dlen = len(data) data = data + b'\0' * ((4 - dlen % 4) % 4) return data, len(val), None class FixedList(List): def __init__(self, name, size, type, pad = 1): List.__init__(self, name, type, pad) self.size = size def parse_binary_value(self, data, display, length, format): return List.parse_binary_value(self, data, display, self.size, format) def pack_value(self, val): if len(val) != self.size: raise BadDataError('length mismatch for FixedList %s' % self.name) return List.pack_value(self, val) class Object(ValueField): def __init__(self, name, type, default = None): ValueField.__init__(self, name, default) self.type = type self.structcode = self.type.structcode self.structvalues = self.type.structvalues def parse_binary_value(self, data, display, length, format): return self.type.parse_binary(data, display) def parse_value(self, val, display): return self.type.parse_value(val, display) def pack_value(self, val): return self.type.pack_value(val) def check_value(self, val): if isinstance(val, tuple): vals = [] i = 0 for f in self.type.fields: if f.name: if f.check_value is None: v = val[i] else: v = f.check_value(val[i]) if f.structvalues == 1: vals.append(v) else: vals.extend(v) i = i + 1 return vals if isinstance(val, dict): data = val elif isinstance(val, DictWrapper): data = val._data else: raise TypeError('Object value must be tuple, dictionary or DictWrapper: %s' % val) vals = [] for f in self.type.fields: if f.name: if f.check_value is None: v = data[f.name] else: v = f.check_value(data[f.name]) if f.structvalues == 1: vals.append(v) else: vals.extend(v) return vals class PropertyData(ValueField): structcode = None def parse_binary_value(self, data, display, length, format): if length is None: length = len(data) // (format // 8) else: length = int(length) if format == 0: ret = None elif format == 8: ret = (8, data[:length]) data = data[length + ((4 - length % 4) % 4):] elif format == 16: ret = (16, array(array_unsigned_codes[2], data[:2 * length])) data = data[2 * (length + length % 2):] elif format == 32: ret = (32, array(array_unsigned_codes[4], data[:4 * length])) data = data[4 * length:] return ret, data def pack_value(self, value): fmt, val = value if fmt not in (8, 16, 32): raise BadDataError('Invalid property data format {0}'.format(fmt)) if isinstance(val, binary_type): size = fmt // 8 vlen = len(val) if vlen % size: vlen = vlen - vlen % size data = val[:vlen] else: data = val dlen = vlen // size else: if isinstance(val, tuple): val = list(val) size = fmt // 8 a = array(array_unsigned_codes[size], val) data = encode_array(a) dlen = len(val) dl = len(data) data = data + b'\0' * ((4 - dl % 4) % 4) return data, dlen, fmt class FixedPropertyData(PropertyData): def __init__(self, name, size): PropertyData.__init__(self, name) self.size = size def parse_binary_value(self, data, display, length, format): return PropertyData.parse_binary_value(self, data, display, self.size // (format // 8), format) def pack_value(self, value): data, dlen, fmt = PropertyData.pack_value(self, value) if len(data) != self.size: raise BadDataError('Wrong data length for FixedPropertyData: %s' % (value, )) return data, dlen, fmt class ValueList(Field): structcode = None keyword_args = True default = 'usekeywords' def __init__(self, name, mask, pad, *fields): self.name = name self.maskcode = '={0}{1}x'.format(unsigned_codes[mask], pad).encode() self.maskcodelen = struct.calcsize(self.maskcode) self.fields = [] flag = 1 for f in fields: if f.name: self.fields.append((f, flag)) flag = flag << 1 def pack_value(self, arg, keys): mask = 0 data = b'' if arg == self.default: arg = keys for field, flag in self.fields: if field.name in arg: mask = mask | flag val = arg[field.name] if field.check_value is not None: val = field.check_value(val) d = struct.pack('=' + field.structcode, val) data = data + d + b'\0' * (4 - len(d)) return struct.pack(self.maskcode, mask) + data, None, None def parse_binary_value(self, data, display, length, format): r = {} mask = int(struct.unpack(self.maskcode, data[:self.maskcodelen])[0]) data = data[self.maskcodelen:] for field, flag in self.fields: if mask & flag: if field.structcode: vals = struct.unpack('=' + field.structcode, data[:struct.calcsize('=' + field.structcode)]) if field.structvalues == 1: vals = vals[0] if field.parse_value is not None: vals = field.parse_value(vals, display) else: vals, d = field.parse_binary_value(data[:4], display, None, None) r[field.name] = vals data = data[4:] return DictWrapper(r), data class KeyboardMapping(ValueField): structcode = None def parse_binary_value(self, data, display, length, format): if length is None: dlen = len(data) else: dlen = 4 * length * format a = array(array_unsigned_codes[4], bytes(data[:dlen])) ret = [] for i in range(0, len(a), format): ret.append(a[i : i + format]) return ret, data[dlen:] def pack_value(self, value): keycodes = 0 for v in value: keycodes = max(keycodes, len(v)) a = array(array_unsigned_codes[4]) for v in value: for k in v: a.append(k) for i in range(len(v), keycodes): a.append(X.NoSymbol) return encode_array(a), len(value), keycodes class ModifierMapping(ValueField): structcode = None def parse_binary_value(self, data, display, length, format): a = array(array_unsigned_codes[1], data[:8 * format]) ret = [] for i in range(0, 8): ret.append(a[i * format : (i + 1) * format]) return ret, data[8 * format:] def pack_value(self, value): if len(value) != 8: raise BadDataError('ModifierMapping list should have eight elements') keycodes = 0 for v in value: keycodes = max(keycodes, len(v)) a = array(array_unsigned_codes[1]) for v in value: for k in v: a.append(k) for i in range(len(v), keycodes): a.append(0) return encode_array(a), len(value), keycodes class EventField(ValueField): structcode = None def pack_value(self, value): if not isinstance(value, Event): raise BadDataError('%s is not an Event for field %s' % (value, self.name)) return value._binary, None, None def parse_binary_value(self, data, display, length, format): from . import event estruct = display.event_classes.get(byte2int(data) & 0x7f, event.AnyEvent) if type(estruct) == dict: # this etype refers to a set of sub-events with individual subcodes estruct = estruct[indexbytes(data, 1)] return estruct(display = display, binarydata = data[:32]), data[32:] # # Objects usable for List and FixedList fields. # Struct is also usable. # class ScalarObj(object): def __init__(self, code): self.structcode = code self.structvalues = 1 self.parse_value = None self.check_value = None Card8Obj = ScalarObj('B') Card16Obj = ScalarObj('H') Card32Obj = ScalarObj('L') class ResourceObj(object): structcode = 'L' structvalues = 1 def __init__(self, class_name): self.class_name = class_name self.check_value = None def parse_value(self, value, display): # if not display: # return value c = display.get_resource_class(self.class_name) if c: return c(display, value) else: return value WindowObj = ResourceObj('window') ColormapObj = ResourceObj('colormap') class StrClass(object): structcode = None def pack_value(self, val): return (chr(len(val)) + val).encode() def parse_binary(self, data, display): slen = byte2int(data) + 1 return decode_string(data[1:slen]), data[slen:] Str = StrClass() class Struct(object): """Struct objects represents a binary data structure. It can contain both fields with static and dynamic sizes. However, all static fields must appear before all dynamic fields. Fields are represented by various subclasses of the abstract base class Field. The fields of a structure are given as arguments when instantiating a Struct object. Struct objects have two public methods: to_binary() -- build a binary representation of the structure with the values given as arguments parse_binary() -- convert a binary (string) representation into a Python dictionary or object. These functions will be generated dynamically for each Struct object to make conversion as fast as possible. They are generated the first time the methods are called. """ def __init__(self, *fields): self.fields = fields # Structures for to_binary, parse_value and parse_binary self.static_codes = '=' self.static_values = 0 self.static_fields = [] self.static_size = None self.var_fields = [] for f in self.fields: # Append structcode if there is one and we haven't # got any varsize fields yet. if f.structcode is not None: assert not self.var_fields self.static_codes = self.static_codes + f.structcode # Only store fields with values if f.structvalues > 0: self.static_fields.append(f) self.static_values = self.static_values + f.structvalues # If we have got one varsize field, all the rest must # also be varsize fields. else: self.var_fields.append(f) self.static_size = struct.calcsize(self.static_codes) if self.var_fields: self.structcode = None self.structvalues = 0 else: self.structcode = self.static_codes[1:] self.structvalues = self.static_values # These functions get called only once, as they will override # themselves with dynamically created functions in the Struct # object def to_binary(self, *varargs, **keys): """data = s.to_binary(...) Convert Python values into the binary representation. The arguments will be all value fields with names, in the order given when the Struct object was instantiated. With one exception: fields with default arguments will be last. Returns the binary representation as the string DATA. """ # Emulate Python function argument handling with our field names names = [f.name for f in self.fields \ if isinstance(f, ValueField) and f.name] field_args = dict(zip(names, varargs)) if set(field_args).intersection(keys): dupes = ", ".join(set(field_args).intersection(keys)) raise TypeError("{0} arguments were passed both positionally and by keyword".format(dupes)) field_args.update(keys) for f in self.fields: if f.name and (f.name not in field_args): if f.default is None: raise TypeError("Missing required argument {0}".format(f.name)) field_args[f.name] = f.default # /argument handling # First pack all varfields so their lengths and formats are # available when we pack their static LengthFields and # FormatFields total_length = self.static_size var_vals = {} lengths = {} formats = {} for f in self.var_fields: if f.keyword_args: v, l, fm = f.pack_value(field_args[f.name], keys) else: v, l, fm = f.pack_value(field_args[f.name]) var_vals[f.name] = v lengths[f.name] = l formats[f.name] = fm total_length += len(v) # Construct item list for struct.pack call, packing all static fields. pack_items = [] for f in self.static_fields: if isinstance(f, LengthField): # If this is a total length field, insert # the calculated field value here if isinstance(f, TotalLengthField): pack_items.append(f.calc_length(total_length)) else: pack_items.append(f.calc_length(lengths[f.name])) # Format field, just insert the value we got previously elif isinstance(f, FormatField): pack_items.append(formats[f.name]) # A constant field, insert its value directly elif isinstance(f, ConstantField): pack_items.append(f.value) # Value fields else: if f.structvalues == 1: # If there's a value check/convert function, call it if f.check_value is not None: pack_items.append(f.check_value(field_args[f.name])) # Else just use the argument as provided else: pack_items.append(field_args[f.name]) # Multivalue field. Handled like single valuefield, # but the value are tuple unpacked into separate arguments # which are appended to pack_items else: if f.check_value is not None: pack_items.extend(f.check_value(field_args[f.name])) else: pack_items.extend(field_args[f.name]) static_part = struct.pack(self.static_codes, *pack_items) var_parts = [var_vals[f.name] for f in self.var_fields] return static_part + b''.join(var_parts) def pack_value(self, value): """ This function allows Struct objects to be used in List and Object fields. Each item represents the arguments to pass to to_binary, either a tuple, a dictionary or a DictWrapper. """ if type(value) is tuple: return self.to_binary(*value) elif isinstance(value, dict): return self.to_binary(**value) elif isinstance(value, DictWrapper): return self.to_binary(**value._data) else: raise BadDataError('%s is not a tuple or a list' % (value)) def parse_value(self, val, display, rawdict = False): """This function is used by List and Object fields to convert Struct objects with no var_fields into Python values. """ ret = {} vno = 0 for f in self.static_fields: # Fields without names should be ignored, and there should # not be any length or format fields if this function # ever gets called. (If there were such fields, there should # be a matching field in var_fields and then parse_binary # would have been called instead. if not f.name: pass elif isinstance(f, LengthField): pass elif isinstance(f, FormatField): pass # Value fields else: # If this field has a parse_value method, call it, otherwise # use the unpacked value as is. if f.structvalues == 1: field_val = val[vno] else: field_val = val[vno:vno+f.structvalues] if f.parse_value is not None: field_val = f.parse_value(field_val, display, rawdict=rawdict) ret[f.name] = field_val vno = vno + f.structvalues if not rawdict: return DictWrapper(ret) return ret def parse_binary(self, data, display, rawdict = False): """values, remdata = s.parse_binary(data, display, rawdict = False) Convert a binary representation of the structure into Python values. DATA is a string or a buffer containing the binary data. DISPLAY should be a Xlib.protocol.display.Display object if there are any Resource fields or Lists with ResourceObjs. The Python values are returned as VALUES. If RAWDICT is true, a Python dictionary is returned, where the keys are field names and the values are the corresponding Python value. If RAWDICT is false, a DictWrapper will be returned where all fields are available as attributes. REMDATA are the remaining binary data, unused by the Struct object. """ ret = {} val = struct.unpack(self.static_codes, data[:self.static_size]) lengths = {} formats = {} vno = 0 for f in self.static_fields: # Fields without name should be ignored. This is typically # pad and constant fields if not f.name: pass # Store index in val for Length and Format fields, to be used # when treating varfields. elif isinstance(f, LengthField): f_names = [f.name] if f.other_fields: f_names.extend(f.other_fields) field_val = val[vno] if f.parse_value is not None: field_val = f.parse_value(field_val, display) for f_name in f_names: lengths[f_name] = field_val elif isinstance(f, FormatField): formats[f.name] = val[vno] # Treat value fields the same was as in parse_value. else: if f.structvalues == 1: field_val = val[vno] else: field_val = val[vno:vno+f.structvalues] if f.parse_value is not None: field_val = f.parse_value(field_val, display) ret[f.name] = field_val vno = vno + f.structvalues data = data[self.static_size:] # Call parse_binary_value for each var_field, passing the # length and format values from the unpacked val. for f in self.var_fields: ret[f.name], data = f.parse_binary_value(data, display, lengths.get(f.name), formats.get(f.name), ) if not rawdict: ret = DictWrapper(ret) return ret, data class TextElements8(ValueField): string_textitem = Struct( LengthOf('string', 1), Int8('delta'), String8('string', pad = 0) ) def pack_value(self, value): data = b'' args = {} for v in value: # Let values be simple strings, meaning a delta of 0 if type(v) in (str, bytes): v = (0, v) # A tuple, it should be (delta, string) # Encode it as one or more textitems if isinstance(v, (tuple, dict, DictWrapper)): if isinstance(v, tuple): delta, m_str = v else: delta = v['delta'] m_str = v['string'] while delta or m_str: args['delta'] = delta args['string'] = m_str[:254] data = data + self.string_textitem.to_binary(*(), **args) delta = 0 m_str = m_str[254:] # Else an integer, i.e. a font change else: # Use fontable cast function if instance if isinstance(v, Fontable): v = v.__fontable__() data = data + struct.pack('>BL', 255, v) # Pad out to four byte length dlen = len(data) return data + b'\0' * ((4 - dlen % 4) % 4), None, None def parse_binary_value(self, data, display, length, format): values = [] while 1: if len(data) < 2: break # font change if byte2int(data) == 255: values.append(struct.unpack('>L', bytes(data[1:5]))[0]) data = data[5:] # skip null strings elif byte2int(data) == 0 and indexbytes(data, 1) == 0: data = data[2:] # string with delta else: v, data = self.string_textitem.parse_binary(data, display) values.append(v) return values, '' class TextElements16(TextElements8): string_textitem = Struct( LengthOf('string', 1), Int8('delta'), String16('string', pad = 0) ) class GetAttrData(object): def __getattr__(self, attr): try: if self._data: return self._data[attr] else: raise AttributeError(attr) except KeyError: raise AttributeError(attr) class DictWrapper(GetAttrData): def __init__(self, dict): self.__dict__['_data'] = dict def __getitem__(self, key): return self._data[key] def __setitem__(self, key, value): self._data[key] = value def __delitem__(self, key): del self._data[key] def __setattr__(self, key, value): self._data[key] = value def __delattr__(self, key): del self._data[key] def __str__(self): return str(self._data) def __repr__(self): return '%s(%s)' % (self.__class__.__name__, repr(self._data)) def __lt__(self, other): if isinstance(other, DictWrapper): return self._data < other._data else: return self._data < other def __gt__(self, other): if isinstance(other, DictWrapper): return self._data > other._data else: return self._data > other def __eq__(self, other): if isinstance(other, DictWrapper): return self._data == other._data else: return self._data == other class Request(object): def __init__(self, display, onerror = None, *args, **keys): self._errorhandler = onerror self._binary = self._request.to_binary(*args, **keys) self._serial = None display.send_request(self, onerror is not None) def _set_error(self, error): if self._errorhandler is not None: return call_error_handler(self._errorhandler, error, self) else: return 0 class ReplyRequest(GetAttrData): def __init__(self, display, defer = False, *args, **keys): self._display = display self._binary = self._request.to_binary(*args, **keys) self._serial = None self._data = None self._error = None self._response_lock = lock.allocate_lock() self._display.send_request(self, True) if not defer: self.reply() def reply(self): # Send request and wait for reply if we hasn't # already got one. This means that reply() can safely # be called more than one time. self._response_lock.acquire() while self._data is None and self._error is None: self._display.send_recv_lock.acquire() self._response_lock.release() self._display.send_and_recv(request = self._serial) self._response_lock.acquire() self._response_lock.release() self._display = None # If error has been set, raise it if self._error: raise self._error def _parse_response(self, data): self._response_lock.acquire() self._data, d = self._reply.parse_binary(data, self._display, rawdict = True) self._response_lock.release() def _set_error(self, error): self._response_lock.acquire() self._error = error self._response_lock.release() return 1 def __repr__(self): return '<%s serial = %s, data = %s, error = %s>' % (self.__class__.__name__, self._serial, self._data, self._error) class Event(GetAttrData): def __init__(self, binarydata = None, display = None, **keys): if binarydata: self._binary = binarydata self._data, data = self._fields.parse_binary(binarydata, display, rawdict = True) # split event type into type and send_event bit self._data['send_event'] = not not self._data['type'] & 0x80 self._data['type'] = self._data['type'] & 0x7f else: if self._code: keys['type'] = self._code keys['sequence_number'] = 0 self._binary = self._fields.to_binary(**keys) keys['send_event'] = 0 self._data = keys def __repr__(self): kwlist = [] for kw, val in self._data.items(): if kw == 'send_event': continue if kw == 'type' and self._data['send_event']: val = val | 0x80 kwlist.append('%s = %s' % (kw, repr(val))) kws = ', '.join(kwlist) return '%s(%s)' % (self.__class__.__name__, kws) def __lt__(self, other): if isinstance(other, Event): return self._data < other._data else: return self._data < other def __gt__(self, other): if isinstance(other, Event): return self._data > other._data else: return self._data > other def __eq__(self, other): if isinstance(other, Event): return self._data == other._data else: return self._data == other def call_error_handler(handler, error, request): try: return handler(error, request) except: sys.stderr.write('Exception raised by error handler.\n') traceback.print_exc() return 0 python-xlib-0.33/Xlib/protocol/structs.py000066400000000000000000000123201435211557500205420ustar00rootroot00000000000000# Xlib.protocol.structs -- some common request structures # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Xlib modules from .. import X # Xlib.protocol modules from . import rq def WindowValues(arg): return rq.ValueList( arg, 4, 0, rq.Pixmap('background_pixmap'), rq.Card32('background_pixel'), rq.Pixmap('border_pixmap'), rq.Card32('border_pixel'), rq.Gravity('bit_gravity'), rq.Gravity('win_gravity'), rq.Set('backing_store', 1, (X.NotUseful, X.WhenMapped, X.Always)), rq.Card32('backing_planes'), rq.Card32('backing_pixel'), rq.Bool('override_redirect'), rq.Bool('save_under'), rq.Card32('event_mask'), rq.Card32('do_not_propagate_mask'), rq.Colormap('colormap'), rq.Cursor('cursor'), ) def GCValues(arg): return rq.ValueList( arg, 4, 0, rq.Set('function', 1, (X.GXclear, X.GXand, X.GXandReverse, X.GXcopy, X.GXandInverted, X.GXnoop, X.GXxor, X.GXor, X.GXnor, X.GXequiv, X.GXinvert, X.GXorReverse, X.GXcopyInverted, X.GXorInverted, X.GXnand, X.GXset)), rq.Card32('plane_mask'), rq.Card32('foreground'), rq.Card32('background'), rq.Card16('line_width'), rq.Set('line_style', 1, (X.LineSolid, X.LineOnOffDash, X.LineDoubleDash)), rq.Set('cap_style', 1, (X.CapNotLast, X.CapButt, X.CapRound, X.CapProjecting)), rq.Set('join_style', 1, (X.JoinMiter, X.JoinRound, X.JoinBevel)), rq.Set('fill_style', 1, (X.FillSolid, X.FillTiled, X.FillStippled, X.FillOpaqueStippled)), rq.Set('fill_rule', 1, (X.EvenOddRule, X.WindingRule)), rq.Pixmap('tile'), rq.Pixmap('stipple'), rq.Int16('tile_stipple_x_origin'), rq.Int16('tile_stipple_y_origin'), rq.Font('font'), rq.Set('subwindow_mode', 1, (X.ClipByChildren, X.IncludeInferiors)), rq.Bool('graphics_exposures'), rq.Int16('clip_x_origin'), rq.Int16('clip_y_origin'), rq.Pixmap('clip_mask'), rq.Card16('dash_offset'), rq.Card8('dashes'), rq.Set('arc_mode', 1, (X.ArcChord, X.ArcPieSlice)) ) TimeCoord = rq.Struct( rq.Card32('time'), rq.Int16('x'), rq.Int16('y'), ) Host = rq.Struct( rq.Set('family', 1, (X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos)), rq.Pad(1), rq.LengthOf('name', 2), rq.List('name', rq.Card8Obj) ) CharInfo = rq.Struct( rq.Int16('left_side_bearing'), rq.Int16('right_side_bearing'), rq.Int16('character_width'), rq.Int16('ascent'), rq.Int16('descent'), rq.Card16('attributes'), ) FontProp = rq.Struct( rq.Card32('name'), rq.Card32('value'), ) ColorItem = rq.Struct( rq.Card32('pixel'), rq.Card16('red'), rq.Card16('green'), rq.Card16('blue'), rq.Card8('flags'), rq.Pad(1), ) RGB = rq.Struct( rq.Card16('red'), rq.Card16('green'), rq.Card16('blue'), rq.Pad(2), ) Point = rq.Struct( rq.Int16('x'), rq.Int16('y'), ) Segment = rq.Struct( rq.Int16('x1'), rq.Int16('y1'), rq.Int16('x2'), rq.Int16('y2'), ) Rectangle = rq.Struct( rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), ) Arc = rq.Struct( rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Int16('angle1'), rq.Int16('angle2'), ) python-xlib-0.33/Xlib/rdb.py000066400000000000000000000467711435211557500157620ustar00rootroot00000000000000# Xlib.rdb -- X resource database implementation # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # See end of file for an explanation of the algorithm and # data structures used. # Standard modules import re import sys # Xlib modules from .support import lock # Set up a few regexpes for parsing string representation of resources comment_re = re.compile(r'^\s*!') resource_spec_re = re.compile(r'^\s*([-_a-zA-Z0-9?.*]+)\s*:\s*(.*)$') value_escape_re = re.compile('\\\\([ \tn\\\\]|[0-7]{3,3})') resource_parts_re = re.compile(r'([.*]+)') # Constants used for determining which match is best NAME_MATCH = 0 CLASS_MATCH = 2 WILD_MATCH = 4 MATCH_SKIP = 6 # Option error class class OptionError(Exception): pass class ResourceDB(object): def __init__(self, file = None, string = None, resources = None): self.db = {} self.lock = lock.allocate_lock() if file is not None: self.insert_file(file) if string is not None: self.insert_string(string) if resources is not None: self.insert_resources(resources) def insert_file(self, file): """insert_file(file) Load resources entries from FILE, and insert them into the database. FILE can be a filename (a string)or a file object. """ if type(file) is bytes: file = open(file, 'r') self.insert_string(file.read()) def insert_string(self, data): """insert_string(data) Insert the resources entries in the string DATA into the database. """ # First split string into lines lines = data.split('\n') while lines: line = lines[0] del lines[0] # Skip empty line if not line: continue # Skip comments if comment_re.match(line): continue # Handle continued lines while line[-1] == '\\': if lines: line = line[:-1] + lines[0] del lines[0] else: line = line[:-1] break # Split line into resource and value m = resource_spec_re.match(line) # Bad line, just ignore it silently if not m: continue res, value = m.group(1, 2) # Convert all escape sequences in value splits = value_escape_re.split(value) for i in range(1, len(splits), 2): s = splits[i] if len(s) == 3: splits[i] = chr(int(s, 8)) elif s == 'n': splits[i] = '\n' # strip the last value part to get rid of any # unescaped blanks splits[-1] = splits[-1].rstrip() value = ''.join(splits) self.insert(res, value) def insert_resources(self, resources): """insert_resources(resources) Insert all resources entries in the list RESOURCES into the database. Each element in RESOURCES should be a tuple: (resource, value) Where RESOURCE is a string and VALUE can be any Python value. """ for res, value in resources: self.insert(res, value) def insert(self, resource, value): """insert(resource, value) Insert a resource entry into the database. RESOURCE is a string and VALUE can be any Python value. """ # Split res into components and bindings parts = resource_parts_re.split(resource) # If the last part is empty, this is an invalid resource # which we simply ignore if parts[-1] == '': return self.lock.acquire() db = self.db for i in range(1, len(parts), 2): # Create a new mapping/value group if parts[i - 1] not in db: db[parts[i - 1]] = ({}, {}) # Use second mapping if a loose binding, first otherwise if '*' in parts[i]: db = db[parts[i - 1]][1] else: db = db[parts[i - 1]][0] # Insert value into the derived db if parts[-1] in db: db[parts[-1]] = db[parts[-1]][:2] + (value, ) else: db[parts[-1]] = ({}, {}, value) self.lock.release() def __getitem__(self, keys_tuple): """db[name, class] Return the value matching the resource identified by NAME and CLASS. If no match is found, KeyError is raised. """ # Split name and class into their parts name, cls = keys_tuple namep = name.split('.') clsp = cls.split('.') # It is an error for name and class to have different number # of parts if len(namep) != len(clsp): raise ValueError('Different number of parts in resource name/class: %s/%s' % (name, cls)) complen = len(namep) matches = [] # Lock database and wrap the lookup code in a try-finally # block to make sure that it is unlocked. self.lock.acquire() try: # Precedence order: name -> class -> ? if namep[0] in self.db: bin_insert(matches, _Match((NAME_MATCH, ), self.db[namep[0]])) if clsp[0] in self.db: bin_insert(matches, _Match((CLASS_MATCH, ), self.db[clsp[0]])) if '?' in self.db: bin_insert(matches, _Match((WILD_MATCH, ), self.db['?'])) # Special case for the unlikely event that the resource # only has one component if complen == 1 and matches: x = matches[0] if x.final(complen): return x.value() else: raise KeyError((name, cls)) # Special case for resources which begins with a loose # binding, e.g. '*foo.bar' if '' in self.db: bin_insert(matches, _Match((), self.db[''][1])) # Now iterate over all components until we find the best match. # For each component, we choose the best partial match among # the mappings by applying these rules in order: # Rule 1: If the current group contains a match for the # name, class or '?', we drop all previously found loose # binding mappings. # Rule 2: A matching name has precedence over a matching # class, which in turn has precedence over '?'. # Rule 3: Tight bindings have precedence over loose # bindings. while matches: # Work on the first element == the best current match x = matches[0] del matches[0] # print 'path: ', x.path # if x.skip: # print 'skip: ', x.db # else: # print 'group: ', x.group # print i = x.match_length() for part, score in ((namep[i], NAME_MATCH), (clsp[i], CLASS_MATCH), ('?', WILD_MATCH)): # Attempt to find a match in x match = x.match(part, score) if match: # Hey, we actually found a value! if match.final(complen): return match.value() # Else just insert the new match else: bin_insert(matches, match) # Generate a new loose match match = x.skip_match(complen) if match: bin_insert(matches, match) # Oh well, nothing matched raise KeyError((name, cls)) finally: self.lock.release() def get(self, res, cls, default = None): """get(name, class [, default]) Return the value matching the resource identified by NAME and CLASS. If no match is found, DEFAULT is returned, or None if DEFAULT isn't specified. """ try: return self[(res, cls)] except KeyError: return default def update(self, db): """update(db) Update this database with all resources entries in the resource database DB. """ self.lock.acquire() update_db(self.db, db.db) self.lock.release() def output(self): """output() Return the resource database in text representation. """ self.lock.acquire() text = output_db('', self.db) self.lock.release() return text def getopt(self, name, argv, opts): """getopt(name, argv, opts) Parse X command line options, inserting the recognised options into the resource database. NAME is the application name, and will be prepended to all specifiers. ARGV is the list of command line arguments, typically sys.argv[1:]. OPTS is a mapping of options to resource specifiers. The key is the option flag (with leading -), and the value is an instance of some Option subclass: NoArg(specifier, value): set resource to value. IsArg(specifier): set resource to option itself SepArg(specifier): value is next argument ResArg: resource and value in next argument SkipArg: ignore this option and next argument SkipLine: ignore rest of arguments SkipNArgs(count): ignore this option and count arguments The remaining, non-option, oparguments is returned. rdb.OptionError is raised if there is an error in the argument list. """ while argv and argv[0] and argv[0][0] == '-': try: argv = opts[argv[0]].parse(name, self, argv) except KeyError: raise OptionError('unknown option: %s' % argv[0]) except IndexError: raise OptionError('missing argument to option: %s' % argv[0]) return argv class _Match(object): def __init__(self, path, dbs): self.path = path if type(dbs) is tuple: self.skip = 0 self.group = dbs else: self.skip = 1 self.db = dbs def __lt__(self, other): return self.path < other.path def __gt__(self, other): return self.path > other.path def __eq__(self, other): return self.path == other.path def match_length(self): return len(self.path) def match(self, part, score): if self.skip: if part in self.db: return _Match(self.path + (score, ), self.db[part]) else: return None else: if part in self.group[0]: return _Match(self.path + (score, ), self.group[0][part]) elif part in self.group[1]: return _Match(self.path + (score + 1, ), self.group[1][part]) else: return None def skip_match(self, complen): # Can't make another skip if we have run out of components if len(self.path) + 1 >= complen: return None # If this already is a skip match, clone a new one if self.skip: if self.db: return _Match(self.path + (MATCH_SKIP, ), self.db) else: return None # Only generate a skip match if the loose binding mapping # is non-empty elif self.group[1]: return _Match(self.path + (MATCH_SKIP, ), self.group[1]) # This is a dead end match else: return None def final(self, complen): if not self.skip and len(self.path) == complen and len(self.group) > 2: return 1 else: return 0 def value(self): return self.group[2] # # Helper function for ResourceDB.__getitem__() # def bin_insert(list, element): """bin_insert(list, element) Insert ELEMENT into LIST. LIST must be sorted, and ELEMENT will be inserted to that LIST remains sorted. If LIST already contains ELEMENT, it will not be duplicated. """ if not list: list.append(element) return lower = 0 upper = len(list) - 1 while lower <= upper: center = (lower + upper) // 2 if element < list[center]: upper = center - 1 elif element > list[center]: lower = center + 1 elif element == list[center]: return if element < list[upper]: list.insert(upper, element) elif element > list[upper]: list.insert(upper + 1, element) # # Helper functions for ResourceDB.update() # def update_db(dest, src): for comp, group in src.items(): # DEST already contains this component, update it if comp in dest: # Update tight and loose binding databases update_db(dest[comp][0], group[0]) update_db(dest[comp][1], group[1]) # If a value has been set in SRC, update # value in DEST if len(group) > 2: dest[comp] = dest[comp][:2] + group[2:] # COMP not in src, make a deep copy else: dest[comp] = copy_group(group) def copy_group(group): return (copy_db(group[0]), copy_db(group[1])) + group[2:] def copy_db(db): newdb = {} for comp, group in db.items(): newdb[comp] = copy_group(group) return newdb # # Helper functions for output # def output_db(prefix, db): res = '' for comp, group in db.items(): # There's a value for this component if len(group) > 2: res = res + '%s%s: %s\n' % (prefix, comp, output_escape(group[2])) # Output tight and loose bindings res = res + output_db(prefix + comp + '.', group[0]) res = res + output_db(prefix + comp + '*', group[1]) return res def output_escape(value): value = str(value) if not value: return value for char, esc in (('\\', '\\\\'), ('\000', '\\000'), ('\n', '\\n')): value = value.replace(char, esc) # If first or last character is space or tab, escape them. if value[0] in ' \t': value = '\\' + value if value[-1] in ' \t' and value[-2:-1] != '\\': value = value[:-1] + '\\' + value[-1] return value # # Option type definitions # class Option(object): def __init__(self): pass def parse(self, name, db, args): pass class NoArg(Option): """Value is provided to constructor.""" def __init__(self, specifier, value): self.specifier = specifier self.value = value def parse(self, name, db, args): db.insert(name + self.specifier, self.value) return args[1:] class IsArg(Option): """Value is the option string itself.""" def __init__(self, specifier): self.specifier = specifier def parse(self, name, db, args): db.insert(name + self.specifier, args[0]) return args[1:] class SepArg(Option): """Value is the next argument.""" def __init__(self, specifier): self.specifier = specifier def parse(self, name, db, args): db.insert(name + self.specifier, args[1]) return args[2:] class ResArgClass(Option): """Resource and value in the next argument.""" def parse(self, name, db, args): db.insert_string(args[1]) return args[2:] ResArg = ResArgClass() class SkipArgClass(Option): """Ignore this option and next argument.""" def parse(self, name, db, args): return args[2:] SkipArg = SkipArgClass() class SkipLineClass(Option): """Ignore rest of the arguments.""" def parse(self, name, db, args): return [] SkipLine = SkipLineClass() class SkipNArgs(Option): """Ignore this option and the next COUNT arguments.""" def __init__(self, count): self.count = count def parse(self, name, db, args): return args[1 + self.count:] def get_display_opts(options, argv = sys.argv): """display, name, db, args = get_display_opts(options, [argv]) Parse X OPTIONS from ARGV (or sys.argv if not provided). Connect to the display specified by a *.display resource if one is set, or to the default X display otherwise. Extract the RESOURCE_MANAGER property and insert all resources from ARGV. The four return values are: DISPLAY -- the display object NAME -- the application name (the filname of ARGV[0]) DB -- the created resource database ARGS -- any remaining arguments """ from Xlib import display, Xatom import os name = os.path.splitext(os.path.basename(argv[0]))[0] optdb = ResourceDB() leftargv = optdb.getopt(name, argv[1:], options) dname = optdb.get(name + '.display', name + '.Display', None) d = display.Display(dname) rdbstring = d.screen(0).root.get_full_property(Xatom.RESOURCE_MANAGER, Xatom.STRING) if rdbstring: data = rdbstring.value else: data = None db = ResourceDB(string = data) db.update(optdb) return d, name, db, leftargv # Common X options stdopts = {'-bg': SepArg('*background'), '-background': SepArg('*background'), '-fg': SepArg('*foreground'), '-foreground': SepArg('*foreground'), '-fn': SepArg('*font'), '-font': SepArg('*font'), '-name': SepArg('.name'), '-title': SepArg('.title'), '-synchronous': NoArg('*synchronous', 'on'), '-xrm': ResArg, '-display': SepArg('.display'), '-d': SepArg('.display'), } # Notes on the implementation: # Resource names are split into their components, and each component # is stored in a mapping. The value for a component is a tuple of two # or three elements: # (tightmapping, loosemapping [, value]) # tightmapping contains the next components which are connected with a # tight binding (.). loosemapping contains the ones connected with # loose binding (*). If value is present, then this component is the # last component for some resource which that value. # The top level components are stored in the mapping r.db, where r is # the resource object. # Example: Inserting "foo.bar*gazonk: yep" into an otherwise empty # resource database would give the following structure: # { 'foo': ( { 'bar': ( { }, # { 'gazonk': ( { }, # { }, # 'yep') # } # ) # }, # {}) # } python-xlib-0.33/Xlib/support/000077500000000000000000000000001435211557500163365ustar00rootroot00000000000000python-xlib-0.33/Xlib/support/__init__.py000066400000000000000000000017001435211557500204450ustar00rootroot00000000000000# Xlib.support.__init__ -- support code package # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA __all__ = [ 'lock', 'connect' # The platform specific modules should not be listed here ] python-xlib-0.33/Xlib/support/connect.py000066400000000000000000000060241435211557500203430ustar00rootroot00000000000000# Xlib.support.connect -- OS-independent display connection functions # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA import sys import importlib # List the modules which contain the corresponding functions _display_mods = { 'OpenVMS': 'vms_connect', } _default_display_mod = 'unix_connect' _socket_mods = { 'OpenVMS': 'vms_connect' } _default_socket_mod = 'unix_connect' _auth_mods = { 'OpenVMS': 'vms_connect' } _default_auth_mod = 'unix_connect' # Figure out which OS we're using. # sys.platform is either "OS-ARCH" or just "OS". _parts = sys.platform.split('-') platform = _parts[0] del _parts def _relative_import(modname): return importlib.import_module('..' + modname, __name__) def get_display(display): """dname, protocol, host, dno, screen = get_display(display) Parse DISPLAY into its components. If DISPLAY is None, use the default display. The return values are: DNAME -- the full display name (string) PROTOCOL -- the protocol to use (None if automatic) HOST -- the host name (string, possibly empty) DNO -- display number (integer) SCREEN -- default screen number (integer) """ modname = _display_mods.get(platform, _default_display_mod) mod = _relative_import(modname) return mod.get_display(display) def get_socket(dname, protocol, host, dno): """socket = get_socket(dname, protocol, host, dno) Connect to the display specified by DNAME, PROTOCOL, HOST and DNO, which are the corresponding values from a previous call to get_display(). Return SOCKET, a new socket object connected to the X server. """ modname = _socket_mods.get(platform, _default_socket_mod) mod = _relative_import(modname) return mod.get_socket(dname, protocol, host, dno) def get_auth(sock, dname, protocol, host, dno): """auth_name, auth_data = get_auth(sock, dname, protocol, host, dno) Return authentication data for the display on the other side of SOCK, which was opened with DNAME, HOST and DNO, using PROTOCOL. Return AUTH_NAME and AUTH_DATA, two strings to be used in the connection setup request. """ modname = _auth_mods.get(platform, _default_auth_mod) mod = _relative_import(modname) return mod.get_auth(sock, dname, protocol, host, dno) python-xlib-0.33/Xlib/support/lock.py000066400000000000000000000030131435211557500176350ustar00rootroot00000000000000# Xlib.support.lock -- allocate a lock # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA class _DummyLock(object): def __init__(self): # This might be nerdy, but by assigning methods like this # instead of defining them all, we create a single bound # method object once instead of one each time one of the # methods is called. # This gives some speed improvements which should reduce the # impact of the threading infrastructure in the regular code, # when not using threading. self.acquire = self.release = self.locked = self.__noop def __noop(self, *args): return # More optimisations: we use a single lock for all lock instances _dummy_lock = _DummyLock() def allocate_lock(): return _dummy_lock python-xlib-0.33/Xlib/support/unix_connect.py000066400000000000000000000157441435211557500214170ustar00rootroot00000000000000# Xlib.support.unix_connect -- Unix-type display connection functions # # Copyright (C) 2000,2002 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA import re import os import platform import socket from Xlib import error, xauth SUPPORTED_PROTOCOLS = (None, 'tcp', 'unix') # Darwin funky socket. uname = platform.uname() if (uname[0] == 'Darwin') and ([int(x) for x in uname[2].split('.')] >= [9, 0]): SUPPORTED_PROTOCOLS += ('darwin',) DARWIN_DISPLAY_RE = re.compile(r'^/private/tmp/[-:a-zA-Z0-9._]*:(?P[0-9]+)(\.(?P[0-9]+))?$') DISPLAY_RE = re.compile(r'^((?Ptcp|unix)/)?(?P[-:a-zA-Z0-9._]*):(?P[0-9]+)(\.(?P[0-9]+))?$') def get_display(display): # Use $DISPLAY if display isn't provided if display is None: display = os.environ.get('DISPLAY', '') re_list = [(DISPLAY_RE, {})] if 'darwin' in SUPPORTED_PROTOCOLS: re_list.insert(0, (DARWIN_DISPLAY_RE, {'protocol': 'darwin'})) for re, defaults in re_list: m = re.match(display) if m is not None: protocol, host, dno, screen = [ m.groupdict().get(field, defaults.get(field)) for field in ('proto', 'host', 'dno', 'screen') ] break else: raise error.DisplayNameError(display) if protocol == 'tcp' and not host: # Host is mandatory when protocol is TCP. raise error.DisplayNameError(display) dno = int(dno) if screen: screen = int(screen) else: screen = 0 return display, protocol, host, dno, screen def _get_tcp_socket(host, dno): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, 6000 + dno)) return s def _get_unix_socket(address): s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect(address) return s def get_socket(dname, protocol, host, dno): assert protocol in SUPPORTED_PROTOCOLS try: # Darwin funky socket. if protocol == 'darwin': s = _get_unix_socket(dname) # TCP socket, note the special case: `unix:0.0` is equivalent to `:0.0`. elif (protocol is None or protocol != 'unix') and host and host != 'unix': s = _get_tcp_socket(host, dno) # Unix socket. else: address = '/tmp/.X11-unix/X%d' % dno if not os.path.exists(address): # Use abstract address. address = '\0' + address try: s = _get_unix_socket(address) except socket.error: if not protocol and not host: # If no protocol/host was specified, fallback to TCP. s = _get_tcp_socket(host, dno) else: raise except socket.error as val: raise error.DisplayConnectionError(dname, str(val)) # Make sure that the connection isn't inherited in child processes. _ensure_not_inheritable(s) return s def _ensure_not_inheritable(sock): # According to PEP446, in Python 3.4 and above, # it is not inherited in child processes by default. # However, just in case, we explicitly make it non-inheritable. # Also, we don't use the code like the following, # because there would be no possibility of backporting to past versions. # if sys.version_info.major == 3 and sys.version_info.minor >= 4: # sock.set_inheritable(False) # return # We just check if the socket has `set_inheritable`. if hasattr(sock, 'set_inheritable'): sock.set_inheritable(False) return # On Windows, # Python doesn't support fcntl module because Windows doesn't have fcntl API. # At least by not importing fcntl, we will be able to import python-xlib on Windows. if platform.system() == 'Windows': # so.. unfortunately, for Python 3.3 and below, on Windows, # we can't make sure that the connection isn't inherited in child processes for now. return import fcntl fcntl.fcntl(sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC) def new_get_auth(sock, dname, protocol, host, dno): assert protocol in SUPPORTED_PROTOCOLS # Translate socket address into the xauth domain if protocol == 'darwin': family = xauth.FamilyLocal addr = socket.gethostname() elif protocol == 'tcp': family = xauth.FamilyInternet # Convert the prettyprinted IP number into 4-octet string. # Sometimes these modules are too damn smart... octets = sock.getpeername()[0].split('.') addr = bytearray(int(x) for x in octets) else: family = xauth.FamilyLocal addr = socket.gethostname().encode() try: au = xauth.Xauthority() except error.XauthError: return b'', b'' while 1: try: return au.get_best_auth(family, addr, dno) except error.XNoAuthError: pass # We need to do this to handle ssh's X forwarding. It sets # $DISPLAY to localhost:10, but stores the xauth cookie as if # DISPLAY was :10. Hence, if localhost and not found, try # again as a Unix socket. if family == xauth.FamilyInternet and addr == b'\x7f\x00\x00\x01': family = xauth.FamilyLocal addr = socket.gethostname().encode() else: return b'', b'' def old_get_auth(sock, dname, host, dno): # Find authorization cookie auth_name = auth_data = b'' try: # We could parse .Xauthority, but xauth is simpler # although more inefficient data = os.popen('xauth list %s 2>/dev/null' % dname).read() # If there's a cookie, it is of the format # DISPLAY SCHEME COOKIE # We're interested in the two last parts for the # connection establishment lines = data.split('\n') if len(lines) >= 1: parts = lines[0].split(None, 2) if len(parts) == 3: auth_name = parts[1] hexauth = parts[2] auth = b'' # Translate hexcode into binary for i in range(0, len(hexauth), 2): auth = auth + chr(int(hexauth[i:i+2], 16)) auth_data = auth except os.error: pass return auth_name, auth_data get_auth = new_get_auth python-xlib-0.33/Xlib/support/vms_connect.py000066400000000000000000000040471435211557500212330ustar00rootroot00000000000000# Xlib.support.vms_connect -- VMS-type display connection functions # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA import re import socket from Xlib import error display_re = re.compile(r'^([-a-zA-Z0-9._]*):([0-9]+)(\.([0-9]+))?$') def get_display(display): # Use dummy display if none is set. We really should # check DECW$DISPLAY instead, but that has to wait if display is None: return ':0.0', None, 'localhost', 0, 0 m = display_re.match(display) if not m: raise error.DisplayNameError(display) name = display # Always return a host, since we don't have AF_UNIX sockets host = m.group(1) if not host: host = 'localhost' dno = int(m.group(2)) screen = m.group(4) if screen: screen = int(screen) else: screen = 0 return name, None, host, dno, screen def get_socket(dname, protocol, host, dno): try: # Always use TCP/IP sockets. Later it would be nice to # be able to use DECNET och LOCAL connections. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, 6000 + dno)) except socket.error as val: raise error.DisplayConnectionError(dname, str(val)) return s def get_auth(sock, dname, host, dno): # VMS doesn't have xauth return '', '' python-xlib-0.33/Xlib/threaded.py000066400000000000000000000021101435211557500167460ustar00rootroot00000000000000# Xlib.threaded -- Import this module to enable threading # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA from six.moves import _thread # We change the allocate_lock function in Xlib.support.lock to # return a basic Python lock, instead of the default dummy lock from Xlib.support import lock lock.allocate_lock = _thread.allocate_lock python-xlib-0.33/Xlib/xauth.py000066400000000000000000000103751435211557500163330ustar00rootroot00000000000000# Xlib.xauth -- ~/.Xauthority access # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA import os import struct from Xlib import X, error FamilyInternet = X.FamilyInternet FamilyDECnet = X.FamilyDECnet FamilyChaos = X.FamilyChaos FamilyServerInterpreted = X.FamilyServerInterpreted FamilyInternetV6 = X.FamilyInternetV6 FamilyLocal = 256 class Xauthority(object): def __init__(self, filename = None): if filename is None: filename = os.environ.get('XAUTHORITY') if filename is None: try: filename = os.path.join(os.environ['HOME'], '.Xauthority') except KeyError: raise error.XauthError( '$HOME not set, cannot find ~/.Xauthority') try: with open(filename, 'rb') as fp: raw = fp.read() except IOError as err: raise error.XauthError('could not read from {0}: {1}'.format(filename, err)) self.entries = [] # entry format (all shorts in big-endian) # short family; # short addrlen; # char addr[addrlen]; # short numlen; # char num[numlen]; # short namelen; # char name[namelen]; # short datalen; # char data[datalen]; n = 0 try: while n < len(raw): family, = struct.unpack('>H', raw[n:n+2]) n = n + 2 length, = struct.unpack('>H', raw[n:n+2]) n = n + length + 2 addr = raw[n - length : n] length, = struct.unpack('>H', raw[n:n+2]) n = n + length + 2 num = raw[n - length : n] length, = struct.unpack('>H', raw[n:n+2]) n = n + length + 2 name = raw[n - length : n] length, = struct.unpack('>H', raw[n:n+2]) n = n + length + 2 data = raw[n - length : n] if len(data) != length: break self.entries.append((family, addr, num, name, data)) except struct.error: print("Xlib.xauth: warning, failed to parse part of xauthority file {0}, aborting all further parsing".format(filename)) if len(self.entries) == 0: print("Xlib.xauth: warning, no xauthority details available") # raise an error? this should get partially caught by the XNoAuthError in get_best_auth.. def __len__(self): return len(self.entries) def __getitem__(self, i): return self.entries[i] def get_best_auth(self, family, address, dispno, types = ( b"MIT-MAGIC-COOKIE-1", )): """Find an authentication entry matching FAMILY, ADDRESS and DISPNO. The name of the auth scheme must match one of the names in TYPES. If several entries match, the first scheme in TYPES will be choosen. If an entry is found, the tuple (name, data) is returned, otherwise XNoAuthError is raised. """ num = str(dispno).encode() matches = {} for efam, eaddr, enum, ename, edata in self.entries: if enum == b'' and ename not in matches: enum = num if efam == family and eaddr == address and num == enum: matches[ename] = edata for t in types: try: return (t, matches[t]) except KeyError: pass raise error.XNoAuthError((family, address, dispno)) python-xlib-0.33/Xlib/xobject/000077500000000000000000000000001435211557500162605ustar00rootroot00000000000000python-xlib-0.33/Xlib/xobject/__init__.py000066400000000000000000000017141435211557500203740ustar00rootroot00000000000000# Xlib.xobject.__init__ -- glue for Xlib.xobject package # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA __all__ = [ 'colormap', 'cursor', 'drawable', 'fontable', 'icccm', 'resource', ] python-xlib-0.33/Xlib/xobject/colormap.py000066400000000000000000000131351435211557500204510ustar00rootroot00000000000000# Xlib.xobject.colormap -- colormap object # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA from Xlib import error from Xlib.protocol import request from . import resource import re rgb_res = [ re.compile(r'\Argb:([0-9a-fA-F]{1,4})/([0-9a-fA-F]{1,4})/([0-9a-fA-F]{1,4})\Z'), re.compile(r'\A#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])\Z'), re.compile(r'\A#([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])\Z'), re.compile(r'\A#([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])\Z'), re.compile(r'\A#([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])\Z'), ] class Colormap(resource.Resource): __colormap__ = resource.Resource.__resource__ def free(self, onerror = None): request.FreeColormap(display = self.display, onerror = onerror, cmap = self.id) self.display.free_resource_id(self.id) def copy_colormap_and_free(self, scr_cmap): mid = self.display.allocate_resource_id() request.CopyColormapAndFree(display = self.display, mid = mid, src_cmap = src_cmap) cls = self.display.get_resource_class('colormap', Colormap) return cls(self.display, mid, owner = 1) def install_colormap(self, onerror = None): request.InstallColormap(display = self.display, onerror = onerror, cmap = self.id) def uninstall_colormap(self, onerror = None): request.UninstallColormap(display = self.display, onerror = onerror, cmap = self.id) def alloc_color(self, red, green, blue): return request.AllocColor(display = self.display, cmap = self.id, red = red, green = green, blue = blue) def alloc_named_color(self, name): for r in rgb_res: m = r.match(name) if m: rs = m.group(1) r = int(rs + '0' * (4 - len(rs)), 16) gs = m.group(2) g = int(gs + '0' * (4 - len(gs)), 16) bs = m.group(3) b = int(bs + '0' * (4 - len(bs)), 16) return self.alloc_color(r, g, b) try: return request.AllocNamedColor(display = self.display, cmap = self.id, name = name) except error.BadName: return None def alloc_color_cells(self, contiguous, colors, planes): return request.AllocColorCells(display = self.display, contiguous = contiguous, cmap = self.id, colors = colors, planes = planes) def alloc_color_planes(self, contiguous, colors, red, green, blue): return request.AllocColorPlanes(display = self.display, contiguous = contiguous, cmap = self.id, colors = colors, red = red, green = green, blue = blue) def free_colors(self, pixels, plane_mask, onerror = None): request.FreeColors(display = self.display, onerror = onerror, cmap = self.id, plane_mask = plane_mask, pixels = pixels) def store_colors(self, items, onerror = None): request.StoreColors(display = self.display, onerror = onerror, cmap = self.id, items = items) def store_named_color(self, name, pixel, flags, onerror = None): request.StoreNamedColor(display = self.display, onerror = onerror, flags = flags, cmap = self.id, pixel = pixel, name = name) def query_colors(self, pixels): r = request.QueryColors(display = self.display, cmap = self.id, pixels = pixels) return r.colors def lookup_color(self, name): return request.LookupColor(display = self.display, cmap = self.id, name = name) python-xlib-0.33/Xlib/xobject/cursor.py000066400000000000000000000034711435211557500201540ustar00rootroot00000000000000# Xlib.xobject.cursor -- cursor object # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA from Xlib.protocol import request from . import resource class Cursor(resource.Resource): __cursor__ = resource.Resource.__resource__ def free(self, onerror = None): request.FreeCursor(display = self.display, onerror = onerror, cursor = self.id) self.display.free_resource_id(self.id) def recolor(self, foreground, background, onerror=None): fore_red, fore_green, fore_blue = foreground back_red, back_green, back_blue = background request.RecolorCursor(display = self.display, onerror = onerror, cursor = self.id, fore_red = fore_red, fore_green = fore_green, fore_blue = fore_blue, back_red = back_red, back_green = back_green, back_blue = back_blue) python-xlib-0.33/Xlib/xobject/drawable.py000066400000000000000000001031651435211557500204210ustar00rootroot00000000000000# Xlib.xobject.drawable -- drawable objects (window and pixmap) # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA from Xlib import X, Xatom from Xlib.protocol import request, rq # Other X resource objects from . import resource from . import colormap from . import cursor from . import fontable # Inter-client communication conventions from . import icccm class Drawable(resource.Resource): __drawable__ = resource.Resource.__resource__ def get_geometry(self): return request.GetGeometry(display = self.display, drawable = self) def create_pixmap(self, width, height, depth): pid = self.display.allocate_resource_id() request.CreatePixmap(display = self.display, depth = depth, pid = pid, drawable = self.id, width = width, height = height) cls = self.display.get_resource_class('pixmap', Pixmap) return cls(self.display, pid, owner = 1) def create_gc(self, **keys): cid = self.display.allocate_resource_id() request.CreateGC(display = self.display, cid = cid, drawable = self.id, attrs = keys) cls = self.display.get_resource_class('gc', fontable.GC) return cls(self.display, cid, owner = 1) def copy_area(self, gc, src_drawable, src_x, src_y, width, height, dst_x, dst_y, onerror = None): request.CopyArea(display = self.display, onerror = onerror, src_drawable = src_drawable, dst_drawable = self.id, gc = gc, src_x = src_x, src_y = src_y, dst_x = dst_x, dst_y = dst_y, width = width, height = height) def copy_plane(self, gc, src_drawable, src_x, src_y, width, height, dst_x, dst_y, bit_plane, onerror = None): request.CopyPlane(display = self.display, onerror = onerror, src_drawable = src_drawable, dst_drawable = self.id, gc = gc, src_x = src_x, src_y = src_y, dst_x = dst_x, dst_y = dst_y, width = width, height = height, bit_plane = bit_plane) def poly_point(self, gc, coord_mode, points, onerror = None): request.PolyPoint(display = self.display, onerror = onerror, coord_mode = coord_mode, drawable = self.id, gc = gc, points = points) def point(self, gc, x, y, onerror = None): request.PolyPoint(display = self.display, onerror = onerror, coord_mode = X.CoordModeOrigin, drawable = self.id, gc = gc, points = [(x, y)]) def poly_line(self, gc, coord_mode, points, onerror = None): request.PolyLine(display = self.display, onerror = onerror, coord_mode = coord_mode, drawable = self.id, gc = gc, points = points) def line(self, gc, x1, y1, x2, y2, onerror = None): request.PolySegment(display = self.display, onerror = onerror, drawable = self.id, gc = gc, segments = [(x1, y1, x2, y2)]) def poly_segment(self, gc, segments, onerror = None): request.PolySegment(display = self.display, onerror = onerror, drawable = self.id, gc = gc, segments = segments) def poly_rectangle(self, gc, rectangles, onerror = None): request.PolyRectangle(display = self.display, onerror = onerror, drawable = self.id, gc = gc, rectangles = rectangles) def rectangle(self, gc, x, y, width, height, onerror = None): request.PolyRectangle(display = self.display, onerror = onerror, drawable = self.id, gc = gc, rectangles = [(x, y, width, height)]) def poly_arc(self, gc, arcs, onerror = None): request.PolyArc(display = self.display, onerror = onerror, drawable = self.id, gc = gc, arcs = arcs) def arc(self, gc, x, y, width, height, angle1, angle2, onerror = None): request.PolyArc(display = self.display, onerror = onerror, drawable = self.id, gc = gc, arcs = [(x, y, width, height, angle1, angle2)]) def fill_poly(self, gc, shape, coord_mode, points, onerror = None): request.FillPoly(display = self.display, onerror = onerror, shape = shape, coord_mode = coord_mode, drawable = self.id, gc = gc, points = points) def poly_fill_rectangle(self, gc, rectangles, onerror = None): request.PolyFillRectangle(display = self.display, onerror = onerror, drawable = self.id, gc = gc, rectangles = rectangles) def fill_rectangle(self, gc, x, y, width, height, onerror = None): request.PolyFillRectangle(display = self.display, onerror = onerror, drawable = self.id, gc = gc, rectangles = [(x, y, width, height)]) def poly_fill_arc(self, gc, arcs, onerror = None): request.PolyFillArc(display = self.display, onerror = onerror, drawable = self.id, gc = gc, arcs = arcs) def fill_arc(self, gc, x, y, width, height, angle1, angle2, onerror = None): request.PolyFillArc(display = self.display, onerror = onerror, drawable = self.id, gc = gc, arcs = [(x, y, width, height, angle1, angle2)]) def put_image(self, gc, x, y, width, height, format, depth, left_pad, data, onerror = None): request.PutImage(display = self.display, onerror = onerror, format = format, drawable = self.id, gc = gc, width = width, height = height, dst_x = x, dst_y = y, left_pad = left_pad, depth = depth, data = data) # Trivial little method for putting PIL images. Will break on anything # but depth 1 or 24... def put_pil_image(self, gc, x, y, image, onerror = None): width, height = image.size if image.mode == '1': format = X.XYBitmap depth = 1 if self.display.info.bitmap_format_bit_order == 0: rawmode = '1;R' else: rawmode = '1' pad = self.display.info.bitmap_format_scanline_pad stride = roundup(width, pad) >> 3 elif image.mode == 'RGB': format = X.ZPixmap depth = 24 if self.display.info.image_byte_order == 0: rawmode = 'BGRX' else: rawmode = 'RGBX' pad = self.display.info.bitmap_format_scanline_pad unit = self.display.info.bitmap_format_scanline_unit stride = roundup(width * unit, pad) >> 3 else: raise ValueError('Unknown data format') maxlen = (self.display.info.max_request_length << 2) \ - request.PutImage._request.static_size split = maxlen // stride x1 = 0 x2 = width y1 = 0 while y1 < height: h = min(height, split) if h < height: subimage = image.crop((x1, y1, x2, y1 + h)) else: subimage = image w, h = subimage.size data = subimage.tobytes("raw", rawmode, stride, 0) self.put_image(gc, x, y, w, h, format, depth, 0, data) y1 = y1 + h y = y + h def get_image(self, x, y, width, height, format, plane_mask): return request.GetImage(display = self.display, format = format, drawable = self.id, x = x, y = y, width = width, height = height, plane_mask = plane_mask) def draw_text(self, gc, x, y, text, onerror = None): request.PolyText8(display = self.display, onerror = onerror, drawable = self.id, gc = gc, x = x, y = y, items = [text]) def poly_text(self, gc, x, y, items, onerror = None): request.PolyText8(display = self.display, onerror = onerror, drawable = self.id, gc = gc, x = x, y = y, items = items) def poly_text_16(self, gc, x, y, items, onerror = None): request.PolyText16(display = self.display, onerror = onerror, drawable = self.id, gc = gc, x = x, y = y, items = items) def image_text(self, gc, x, y, string, onerror = None): request.ImageText8(display = self.display, onerror = onerror, drawable = self.id, gc = gc, x = x, y = y, string = string) def image_text_16(self, gc, x, y, string, onerror = None): request.ImageText16(display = self.display, onerror = onerror, drawable = self.id, gc = gc, x = x, y = y, string = string) def query_best_size(self, item_class, width, height): return request.QueryBestSize(display = self.display, item_class = item_class, drawable = self.id, width = width, height = height) class Window(Drawable): __window__ = resource.Resource.__resource__ _STRING_ENCODING = 'ISO-8859-1' _UTF8_STRING_ENCODING = 'UTF-8' def create_window(self, x, y, width, height, border_width, depth, window_class = X.CopyFromParent, visual = X.CopyFromParent, onerror = None, **keys): wid = self.display.allocate_resource_id() request.CreateWindow(display = self.display, onerror = onerror, depth = depth, wid = wid, parent = self.id, x = x, y = y, width = width, height = height, border_width = border_width, window_class = window_class, visual = visual, attrs = keys) cls = self.display.get_resource_class('window', Window) return cls(self.display, wid, owner = 1) def change_attributes(self, onerror = None, **keys): request.ChangeWindowAttributes(display = self.display, onerror = onerror, window = self.id, attrs = keys) def get_attributes(self): return request.GetWindowAttributes(display = self.display, window = self.id) def destroy(self, onerror = None): request.DestroyWindow(display = self.display, onerror = onerror, window = self.id) self.display.free_resource_id(self.id) def destroy_sub_windows(self, onerror = None): request.DestroySubWindows(display = self.display, onerror = onerror, window = self.id) def change_save_set(self, mode, onerror = None): request.ChangeSaveSet(display = self.display, onerror = onerror, mode = mode, window = self.id) def reparent(self, parent, x, y, onerror = None): request.ReparentWindow(display = self.display, onerror = onerror, window = self.id, parent = parent, x = x, y = y) def map(self, onerror = None): request.MapWindow(display = self.display, onerror = onerror, window = self.id) def map_sub_windows(self, onerror = None): request.MapSubwindows(display = self.display, onerror = onerror, window = self.id) def unmap(self, onerror = None): request.UnmapWindow(display = self.display, onerror = onerror, window = self.id) def unmap_sub_windows(self, onerror = None): request.UnmapSubwindows(display = self.display, onerror = onerror, window = self.id) def configure(self, onerror = None, **keys): request.ConfigureWindow(display = self.display, onerror = onerror, window = self.id, attrs = keys) def circulate(self, direction, onerror = None): request.CirculateWindow(display = self.display, onerror = onerror, direction = direction, window = self.id) def raise_window(self, onerror = None): """alias for raising the window to the top - as in XRaiseWindow""" self.configure(onerror, stack_mode = X.Above) def query_tree(self): return request.QueryTree(display = self.display, window = self.id) def change_property(self, property, property_type, format, data, mode = X.PropModeReplace, onerror = None): request.ChangeProperty(display = self.display, onerror = onerror, mode = mode, window = self.id, property = property, type = property_type, data = (format, data)) def change_text_property(self, property, property_type, data, mode = X.PropModeReplace, onerror = None): if not isinstance(data, bytes): if property_type == Xatom.STRING: data = data.encode(self._STRING_ENCODING) elif property_type == self.display.get_atom('UTF8_STRING'): data = data.encode(self._UTF8_STRING_ENCODING) self.change_property(property, property_type, 8, data, mode=mode, onerror=onerror) def delete_property(self, property, onerror = None): request.DeleteProperty(display = self.display, onerror = onerror, window = self.id, property = property) def get_property(self, property, property_type, offset, length, delete = False): r = request.GetProperty(display = self.display, delete = delete, window = self.id, property = property, type = property_type, long_offset = offset, long_length = length) if r.property_type: fmt, value = r.value r.format = fmt r.value = value return r else: return None def get_full_property(self, property, property_type, sizehint = 10): prop = self.get_property(property, property_type, 0, sizehint) if prop: val = prop.value if prop.bytes_after: prop = self.get_property(property, property_type, sizehint, prop.bytes_after // 4 + 1) val = val + prop.value prop.value = val return prop else: return None def get_full_text_property(self, property, property_type=X.AnyPropertyType, sizehint = 10): prop = self.get_full_property(property, property_type, sizehint=sizehint) if prop is None or prop.format != 8: return None if prop.property_type == Xatom.STRING: prop.value = prop.value.decode(self._STRING_ENCODING) elif prop.property_type == self.display.get_atom('UTF8_STRING'): prop.value = prop.value.decode(self._UTF8_STRING_ENCODING) # FIXME: at least basic support for compound text would be nice. # elif prop.property_type == self.display.get_atom('COMPOUND_TEXT'): return prop.value def list_properties(self): r = request.ListProperties(display = self.display, window = self.id) return r.atoms def set_selection_owner(self, selection, time, onerror = None): request.SetSelectionOwner(display = self.display, onerror = onerror, window = self.id, selection = selection, time = time) def convert_selection(self, selection, target, property, time, onerror = None): request.ConvertSelection(display = self.display, onerror = onerror, requestor = self.id, selection = selection, target = target, property = property, time = time) def send_event(self, event, event_mask = 0, propagate = False, onerror = None): request.SendEvent(display = self.display, onerror = onerror, propagate = propagate, destination = self.id, event_mask = event_mask, event = event) def grab_pointer(self, owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, time): r = request.GrabPointer(display = self.display, owner_events = owner_events, grab_window = self.id, event_mask = event_mask, pointer_mode = pointer_mode, keyboard_mode = keyboard_mode, confine_to = confine_to, cursor = cursor, time = time) return r.status def grab_button(self, button, modifiers, owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, onerror = None): request.GrabButton(display = self.display, onerror = onerror, owner_events = owner_events, grab_window = self.id, event_mask = event_mask, pointer_mode = pointer_mode, keyboard_mode = keyboard_mode, confine_to = confine_to, cursor = cursor, button = button, modifiers = modifiers) def ungrab_button(self, button, modifiers, onerror = None): request.UngrabButton(display = self.display, onerror = onerror, button = button, grab_window = self.id, modifiers = modifiers) def grab_keyboard(self, owner_events, pointer_mode, keyboard_mode, time): r = request.GrabKeyboard(display = self.display, owner_events = owner_events, grab_window = self.id, time = time, pointer_mode = pointer_mode, keyboard_mode = keyboard_mode) return r.status def grab_key(self, key, modifiers, owner_events, pointer_mode, keyboard_mode, onerror = None): request.GrabKey(display = self.display, onerror = onerror, owner_events = owner_events, grab_window = self.id, modifiers = modifiers, key = key, pointer_mode = pointer_mode, keyboard_mode = keyboard_mode) def ungrab_key(self, key, modifiers, onerror = None): request.UngrabKey(display = self.display, onerror = onerror, key = key, grab_window = self.id, modifiers = modifiers) def query_pointer(self): return request.QueryPointer(display = self.display, window = self.id) def get_motion_events(self, start, stop): r = request.GetMotionEvents(display = self.display, window = self.id, start = start, stop = stop) return r.events def translate_coords(self, src_window, src_x, src_y): return request.TranslateCoords(display = self.display, src_wid = src_window, dst_wid = self.id, src_x = src_x, src_y = src_y) def warp_pointer(self, x, y, src_window = 0, src_x = 0, src_y = 0, src_width = 0, src_height = 0, onerror = None): request.WarpPointer(display = self.display, onerror = onerror, src_window = src_window, dst_window = self.id, src_x = src_x, src_y = src_y, src_width = src_width, src_height = src_height, dst_x = x, dst_y = y) def set_input_focus(self, revert_to, time, onerror = None): request.SetInputFocus(display = self.display, onerror = onerror, revert_to = revert_to, focus = self.id, time = time) def clear_area(self, x = 0, y = 0, width = 0, height = 0, exposures = False, onerror = None): request.ClearArea(display = self.display, onerror = onerror, exposures = exposures, window = self.id, x = x, y = y, width = width, height = height) def create_colormap(self, visual, alloc): mid = self.display.allocate_resource_id() request.CreateColormap(display = self.display, alloc = alloc, mid = mid, window = self.id, visual = visual) cls = self.display.get_resource_class('colormap', colormap.Colormap) return cls(self.display, mid, owner = 1) def list_installed_colormaps(self): r = request.ListInstalledColormaps(display = self.display, window = self.id) return r.cmaps def rotate_properties(self, properties, delta, onerror = None): request.RotateProperties(display = self.display, onerror = onerror, window = self.id, delta = delta, properties = properties) def set_wm_name(self, name, onerror = None): self.change_text_property(Xatom.WM_NAME, Xatom.STRING, name, onerror = onerror) def get_wm_name(self): return self.get_full_text_property(Xatom.WM_NAME, Xatom.STRING) def set_wm_icon_name(self, name, onerror = None): self.change_text_property(Xatom.WM_ICON_NAME, Xatom.STRING, name, onerror = onerror) def get_wm_icon_name(self): return self.get_full_text_property(Xatom.WM_ICON_NAME, Xatom.STRING) def set_wm_class(self, inst, cls, onerror = None): self.change_text_property(Xatom.WM_CLASS, Xatom.STRING, '%s\0%s\0' % (inst, cls), onerror = onerror) def get_wm_class(self): value = self.get_full_text_property(Xatom.WM_CLASS, Xatom.STRING) if value is None: return None parts = value.split('\0') if len(parts) < 2: return None else: return parts[0], parts[1] def set_wm_transient_for(self, window, onerror = None): self.change_property(Xatom.WM_TRANSIENT_FOR, Xatom.WINDOW, 32, [window.id], onerror = onerror) def get_wm_transient_for(self): d = self.get_property(Xatom.WM_TRANSIENT_FOR, Xatom.WINDOW, 0, 1) if d is None or d.format != 32 or len(d.value) < 1: return None else: cls = self.display.get_resource_class('window', Window) return cls(self.display, d.value[0]) def set_wm_protocols(self, protocols, onerror = None): self.change_property(self.display.get_atom('WM_PROTOCOLS'), Xatom.ATOM, 32, protocols, onerror = onerror) def get_wm_protocols(self): d = self.get_full_property(self.display.get_atom('WM_PROTOCOLS'), Xatom.ATOM) if d is None or d.format != 32: return [] else: return d.value def set_wm_colormap_windows(self, windows, onerror = None): self.change_property(self.display.get_atom('WM_COLORMAP_WINDOWS'), Xatom.WINDOW, 32, map(lambda w: w.id, windows), onerror = onerror) def get_wm_colormap_windows(self): d = self.get_full_property(self.display.get_atom('WM_COLORMAP_WINDOWS'), Xatom.WINDOW) if d is None or d.format != 32: return [] else: cls = self.display.get_resource_class('window', Window) return map(lambda i, d = self.display, c = cls: c(d, i), d.value) def set_wm_client_machine(self, name, onerror = None): self.change_text_property(Xatom.WM_CLIENT_MACHINE, Xatom.STRING, name, onerror = onerror) def get_wm_client_machine(self): return self.get_full_text_property(Xatom.WM_CLIENT_MACHINE, Xatom.STRING) def set_wm_normal_hints(self, hints = {}, onerror = None, **keys): self._set_struct_prop(Xatom.WM_NORMAL_HINTS, Xatom.WM_SIZE_HINTS, icccm.WMNormalHints, hints, keys, onerror) def get_wm_normal_hints(self): return self._get_struct_prop(Xatom.WM_NORMAL_HINTS, Xatom.WM_SIZE_HINTS, icccm.WMNormalHints) def set_wm_hints(self, hints = {}, onerror = None, **keys): self._set_struct_prop(Xatom.WM_HINTS, Xatom.WM_HINTS, icccm.WMHints, hints, keys, onerror) def get_wm_hints(self): return self._get_struct_prop(Xatom.WM_HINTS, Xatom.WM_HINTS, icccm.WMHints) def set_wm_state(self, hints = {}, onerror = None, **keys): atom = self.display.get_atom('WM_STATE') self._set_struct_prop(atom, atom, icccm.WMState, hints, keys, onerror) def get_wm_state(self): atom = self.display.get_atom('WM_STATE') return self._get_struct_prop(atom, atom, icccm.WMState) def set_wm_icon_size(self, hints = {}, onerror = None, **keys): self._set_struct_prop(Xatom.WM_ICON_SIZE, Xatom.WM_ICON_SIZE, icccm.WMIconSize, hints, keys, onerror) def get_wm_icon_size(self): return self._get_struct_prop(Xatom.WM_ICON_SIZE, Xatom.WM_ICON_SIZE, icccm.WMIconSize) # Helper function for getting structured properties. # pname and ptype are atoms, and pstruct is a Struct object. # Returns a DictWrapper, or None def _get_struct_prop(self, pname, ptype, pstruct): r = self.get_property(pname, ptype, 0, pstruct.static_size // 4) if r and r.format == 32: value = rq.encode_array(r.value) if len(value) == pstruct.static_size: return pstruct.parse_binary(value, self.display)[0] return None # Helper function for setting structured properties. # pname and ptype are atoms, and pstruct is a Struct object. # hints is a mapping or a DictWrapper, keys is a mapping. keys # will be modified. onerror is the error handler. def _set_struct_prop(self, pname, ptype, pstruct, hints, keys, onerror): if isinstance(hints, rq.DictWrapper): keys.update(hints._data) else: keys.update(hints) value = pstruct.to_binary(*(), **keys) self.change_property(pname, ptype, 32, value, onerror = onerror) class Pixmap(Drawable): __pixmap__ = resource.Resource.__resource__ def free(self, onerror = None): request.FreePixmap(display = self.display, onerror = onerror, pixmap = self.id) self.display.free_resource_id(self.id) def create_cursor(self, mask, foreground, background, x, y): fore_red, fore_green, fore_blue = foreground back_red, back_green, back_blue = background cid = self.display.allocate_resource_id() request.CreateCursor(display = self.display, cid = cid, source = self.id, mask = mask, fore_red = fore_red, fore_green = fore_green, fore_blue = fore_blue, back_red = back_red, back_green = back_green, back_blue = back_blue, x = x, y = y) cls = self.display.get_resource_class('cursor', cursor.Cursor) return cls(self.display, cid, owner = 1) def roundup(value, unit): return (value + (unit - 1)) & ~(unit - 1) python-xlib-0.33/Xlib/xobject/fontable.py000066400000000000000000000102171435211557500204250ustar00rootroot00000000000000# Xlib.xobject.fontable -- fontable objects (GC, font) # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA from Xlib.protocol import request from . import resource from . import cursor class Fontable(resource.Resource): __fontable__ = resource.Resource.__resource__ def query(self): return request.QueryFont(display = self.display, font = self.id) def query_text_extents(self, string): return request.QueryTextExtents(display = self.display, font = self.id, string = string) class GC(Fontable): __gc__ = resource.Resource.__resource__ def change(self, onerror = None, **keys): request.ChangeGC(display = self.display, onerror = onerror, gc = self.id, attrs = keys) def copy(self, src_gc, mask, onerror = None): request.CopyGC(display = self.display, onerror = onerror, src_gc = src_gc, dst_gc = self.id, mask = mask) def set_dashes(self, offset, dashes, onerror = None): request.SetDashes(display = self.display, onerror = onerror, gc = self.id, dash_offset = offset, dashes = dashes) def set_clip_rectangles(self, x_origin, y_origin, rectangles, ordering, onerror = None): request.SetClipRectangles(display = self.display, onerror = onerror, ordering = ordering, gc = self.id, x_origin = x_origin, y_origin = y_origin, rectangles = rectangles) def free(self, onerror = None): request.FreeGC(display = self.display, onerror = onerror, gc = self.id) self.display.free_resource_id(self.id) class Font(Fontable): __font__ = resource.Resource.__resource__ def close(self, onerror = None): request.CloseFont(display = self.display, onerror = onerror, font = self.id) self.display.free_resource_id(self.id) def create_glyph_cursor(self, mask, source_char, mask_char, foreground, background): fore_red, fore_green, fore_blue = foreground back_red, back_green, back_blue = background cid = self.display.allocate_resource_id() request.CreateGlyphCursor(display = self.display, cid = cid, source = self.id, mask = mask, source_char = source_char, mask_char = mask_char, fore_red = fore_red, fore_green = fore_green, fore_blue = fore_blue, back_red = back_red, back_green = back_green, back_blue = back_blue) cls = self.display.get_resource_class('cursor', cursor.Cursor) return cls(self.display, cid, owner = 1) python-xlib-0.33/Xlib/xobject/icccm.py000066400000000000000000000064461435211557500177220ustar00rootroot00000000000000# Xlib.xobject.icccm -- ICCCM structures # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA from Xlib import X, Xutil from Xlib.protocol import rq Aspect = rq.Struct( rq.Int32('num'), rq.Int32('denum') ) WMNormalHints = rq.Struct( rq.Card32('flags'), rq.Pad(16), rq.Int32('min_width', default = 0), rq.Int32('min_height', default = 0), rq.Int32('max_width', default = 0), rq.Int32('max_height', default = 0), rq.Int32('width_inc', default = 0), rq.Int32('height_inc', default = 0), rq.Object('min_aspect', Aspect, default = (0, 0)), rq.Object('max_aspect', Aspect, default = (0, 0)), rq.Int32('base_width', default = 0), rq.Int32('base_height', default = 0), rq.Int32('win_gravity', default = 0), ) WMHints = rq.Struct( rq.Card32('flags'), rq.Card32('input', default = 0), rq.Set('initial_state', 4, # withdrawn is totally bogus according to # ICCCM, but some window managers seem to # use this value to identify dockapps. # Oh well. ( Xutil.WithdrawnState, Xutil.NormalState, Xutil.IconicState ), default = Xutil.NormalState), rq.Pixmap('icon_pixmap', default = 0), rq.Window('icon_window', default = 0), rq.Int32('icon_x', default = 0), rq.Int32('icon_y', default = 0), rq.Pixmap('icon_mask', default = 0), rq.Window('window_group', default = 0), ) WMState = rq.Struct( rq.Set('state', 4, ( Xutil.WithdrawnState, Xutil.NormalState, Xutil.IconicState )), rq.Window('icon', ( X.NONE, )), ) WMIconSize = rq.Struct( rq.Card32('min_width'), rq.Card32('min_height'), rq.Card32('max_width'), rq.Card32('max_height'), rq.Card32('width_inc'), rq.Card32('height_inc'), ) python-xlib-0.33/Xlib/xobject/resource.py000066400000000000000000000033111435211557500204570ustar00rootroot00000000000000# Xlib.xobject.resource -- any X resource object # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA from Xlib.protocol import request class Resource(object): def __init__(self, display, rid, owner = 0): self.display = display self.id = rid self.owner = owner def __resource__(self): return self.id def __eq__(self, obj): if isinstance(obj, Resource): if self.display == obj.display: return self.id == obj.id else: return False else: return id(self) == id(obj) def __ne__(self, obj): return not self == obj def __hash__(self): return int(self.id) def __repr__(self): return '<%s 0x%08x>' % (self.__class__.__name__, self.id) def kill_client(self, onerror = None): request.KillClient(display = self.display, onerror = onerror, resource = self.id) python-xlib-0.33/codecov.yml000066400000000000000000000001641435211557500160720ustar00rootroot00000000000000comment: layout: header, changes, diff coverage: ignore: - examples/.* - test/.* status: patch: false python-xlib-0.33/debian/000077500000000000000000000000001435211557500151465ustar00rootroot00000000000000python-xlib-0.33/debian/changelog000066400000000000000000000003061435211557500170170ustar00rootroot00000000000000python-xlib (0.8-1) unstable; urgency=low * Initial Release. (Closes: #105388) -- Moshe Zadka Sun, 15 Jul 2001 13:12:01 +0300 Local variables: mode: debian-changelog End: python-xlib-0.33/debian/control000066400000000000000000000005051435211557500165510ustar00rootroot00000000000000Source: python-xlib Section: x11 Priority: extra Maintainer: Moshe Zadka Build-Depends: debhelper Standards-Version: 3.0.1 Package: python-xlib Architecture: all Depends: python Description: Interface for Python to the X11 Protocol python-xlib is a 100% pure python implementation of the X11 protocol. python-xlib-0.33/debian/copyright000066400000000000000000000005011435211557500170750ustar00rootroot00000000000000This package was debianized by Moshe Zadka on sun, 15 Jul 2001 13:03:04 +0300. It was downloaded from http://python-xlib.sf.net Upstream Author(s): Peter Liljenberg Copyright: Copyright (C) 2000,2001 Peter Liljenberg The Python X Library is released under GPL, see the file COPYING for details. python-xlib-0.33/debian/dirs000066400000000000000000000002211435211557500160250ustar00rootroot00000000000000usr/lib/python1.5/site-packages/Xlib usr/share/info usr/share/doc/python-xlib/ usr/share/doc/python-xlib/examples usr/share/doc/python-xlib/html python-xlib-0.33/debian/postinst000066400000000000000000000013321435211557500167530ustar00rootroot00000000000000#!/bin/sh if [ "$1" = "configure" -o "$1" = "upgrade" ]; then install-info --section "Development" "Development" --quiet /usr/share/info/python-xlib.info fi if [ "$1" = "configure" ]; then if [ -d /usr/doc -a ! -e /usr/doc/python-xlib -a -d /usr/share/doc/python-xlib ]; then ln -sf ../share/doc/python-xlib /usr/doc/python-xlib fi fi NAME=python-xlib case "$1" in configure|abort-upgrade|abort-remove|abort-deconfigure) dpkg --listfiles $NAME | grep '\.py$' | \ xargs -n 1 /usr/bin/python -c 'import py_compile,sys;py_compile.compile(sys.argv[1])' dpkg --listfiles $NAME | grep '\.py$' | \ xargs -n 1 /usr/bin/python -O -c 'import py_compile,sys;py_compile.compile(sys.argv[1])' ;; esac python-xlib-0.33/debian/prerm000066400000000000000000000005461435211557500162230ustar00rootroot00000000000000#!/bin/sh if [ "$1" = "remove" -o "$1" = "upgrade" ]; then install-info --quiet --remove /usr/share/info/python-xlib.info fi NAME=python-xlib dpkg --listfiles $NAME | awk '$0~/\.py$/ {print $0"c\n" $0"o"}' | xargs rm -f >&2 if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/python-xlib ]; then rm -f /usr/doc/python-xlib fi python-xlib-0.33/debian/rules000066400000000000000000000031661435211557500162310ustar00rootroot00000000000000#!/usr/bin/make -f #-*- makefile -*- # Made with the aid of dh_make, by Craig Small # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. # Some lines taken from debmake, by Christoph Lameter. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # This is the debhelper compatibility version to use. export DH_COMPAT=1 build: build-stamp build-stamp: dh_testdir touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp install-stamp # Add here commands to clean up after the build process. dh_clean install: install-stamp install-stamp: build-stamp dh_testdir dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package into debian/tmp. cp -r Xlib debian/tmp/usr/lib/python1.5/site-packages/ cp README NEWS TODO debian/tmp/usr/share/doc/python-xlib cp doc/html/*.html debian/tmp/usr/share/doc/python-xlib/html cp doc/info/*.info debian/tmp/usr/share/info gzip -9 debian/tmp/usr/share/info/python-xlib.info cp examples/*.py debian/tmp/usr/share/doc/python-xlib/examples cp debian/copyright debian/tmp/usr/share/doc/python-xlib/ touch install-stamp binary-arch: build install # We have nothing to do by default. binary-indep: build install # dh_testversion dh_testdir dh_testroot dh_link dh_strip dh_installchangelogs dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb source diff: @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install python-xlib-0.33/dev-requirements.txt000066400000000000000000000000521435211557500177610ustar00rootroot00000000000000coverage codecov mock nose setuptools-scm python-xlib-0.33/doc/000077500000000000000000000000001435211557500144715ustar00rootroot00000000000000python-xlib-0.33/doc/Makefile000066400000000000000000000003371435211557500161340ustar00rootroot00000000000000# Top-level makefile for Python Xlib documentation FORMATS = info ps html all: $(FORMATS) info:: (cd info; make) ps:: (cd ps; make) html:: (cd html; make) clean: for f in $(FORMATS); do (cd $$f; make clean); done python-xlib-0.33/doc/html/000077500000000000000000000000001435211557500154355ustar00rootroot00000000000000python-xlib-0.33/doc/html/Makefile000066400000000000000000000003201435211557500170700ustar00rootroot00000000000000# Make HTML documentation for Python Xlib include ../src/defs python-xlib_toc.html: $(SRCS) texi2html --output=. --split=node --menu $(TOPSRC) ln -sf python-xlib_toc.html index.html clean: rm -f *.html python-xlib-0.33/doc/info/000077500000000000000000000000001435211557500154245ustar00rootroot00000000000000python-xlib-0.33/doc/info/Makefile000066400000000000000000000002561435211557500170670ustar00rootroot00000000000000# Make info documentation for Python Xlib include ../src/defs python-xlib.info: $(SRCS) makeinfo --force --no-split -P $(SRCDIR) $(TOPSRC) clean: rm -f python-xlib.info python-xlib-0.33/doc/ps/000077500000000000000000000000001435211557500151135ustar00rootroot00000000000000python-xlib-0.33/doc/ps/Makefile000066400000000000000000000007241435211557500165560ustar00rootroot00000000000000# Make postscript documentation for Python Xlib include ../src/defs python-xlib.ps: python-xlib.dvi dvips -o python-xlib.ps python-xlib.dvi python-xlib.dvi: $(SRCS) if test -f python-xlib.aux; then \ cp python-xlib.aux python-xlib.auxtmp; \ else touch python-xlib.auxtmp; fi texi2dvi -b $(TOPSRC) # If xref has changed, rebuild again to catch them cmp python-xlib.aux python-xlib.auxtmp || texi2dvi -b $(TOPSRC) clean: rm -f python-xlib.* python-xlib-0.33/doc/src/000077500000000000000000000000001435211557500152605ustar00rootroot00000000000000python-xlib-0.33/doc/src/Makefile000066400000000000000000000002601435211557500167160ustar00rootroot00000000000000# When make:ing in the src dir, just do info info: (cd ..; make info) ps: (cd ..; make ps) html: (cd ..; make html) all: (cd ..; make all) clean: (cd ..; make clean) python-xlib-0.33/doc/src/concepts.texi000066400000000000000000000006631435211557500177760ustar00rootroot00000000000000@c The Python X Library -- concepts @c @c Copyright 2000 Peter Liljenberg @c @node Basic X Concepts @chapter Basic X Concepts Here you might find an introduction to X concepts sometime in the future. For now, I just refer to the introduction parts of the standard X documentation. A vast collection of X documentation links can be found at @uref{https://web.archive.org/web/20201228053920/http://www.rahul.net/kenton/xsites.html}. python-xlib-0.33/doc/src/connect.texi000066400000000000000000000062671435211557500176170ustar00rootroot00000000000000@c The Python X Library -- display connection @c @c Copyright 2000 Peter Liljenberg @c @node Connect to a Display @chapter Connect to a Display To be able to perform any X operations, you must first establish a connection to the display. This is done by instantiating a @code{display.Display} object: @deffn Class Display ( [ displayname ] ) Create a connection to the display called @var{displayname}. If @var{displayname} is None or not provided, connect to the default display. If the connection fails for some reason, one of the errors from the following error class tree is raised: @display @group Exception \_error.DisplayError \_error.DisplayNameError \_error.DisplayConnectionError @end group @end display @code{error.DisplayNameError} is raised if @var{displayname}, or the default display name, is malformed. @code{error.DisplayConnectionError} is raised if the connection to the X server fails. This might be caused by the network connection to the display failing, or if the client isn't authorized to connect to the display. @end deffn The syntax of a display name and how the library finds the default display name depends on the operating system where the client runs. @menu * Unix Display Names:: Most Unix-style operating systems. * OpenVMS Display Names:: Digital^H^H^H^H^H^H^HCompaq OpenVMS. @end menu @node Unix Display Names @section Unix Display Names A display name on Unix has the following syntax: @example [hostname]:displayno[.screenno] @end example If @var{hostname} is omitted this refers to a display on the same machine as the client is running on. A Unix socket is used to connect to the display identified by @code{displayno}, which must be an integer from 0 and upwards. If @var{hostname} is specified, it gives the network name or IP-number of the machine to contact. A TCP socket is used, connecting to port 6000+@var{displayno} on @var{hostname}. If the display contains more than one screen, @var{screenno} can be specified to make another screen than 0 the default screen. If the number is larger than the available maximum screen number, it will be set to the maximum. A few examples: @example :0 Display 0 on this host, connects to the Unix socket /tmp/.X11-unix/X0 :0.1 Same as above, but specifying a different default screen myhost:0 Display 0 on myhost, connects to TCP port 6000 myhost:10 Display 10 on myhost, connects to TCP port 6010 localhost:0 Display 0 on localhost, i.e. the same host as the client runs on. Uses a TCP socket, while :0 uses a Unix socket @end example The default display name is stored in the environmental variable @code{DISPLAY}. If that isn't set, @code{error.DisplayNameError} is raised. @node OpenVMS Display Names @section OpenVMS Display Names Currently the X Python Library only supports TCP connections on OpenVMS. Display names are identical to Unix display names, but if the hostname is omitted, @code{localhost} is used. The default display name is hard-coded to @code{localhost:0.0}. In the future, the native DECWindows system should be used. This means using LOCAL or DECNET transports if set, and using the logical name @code{DECW$DISPLAY} as the default display. python-xlib-0.33/doc/src/defs000066400000000000000000000004271435211557500161270ustar00rootroot00000000000000# Definitions for documentation makefiles SRCDIR = ../src TOPSRC = $(SRCDIR)/python-xlib.texi SRCS = $(TOPSRC) \ $(SRCDIR)/concepts.texi $(SRCDIR)/package.texi \ $(SRCDIR)/connect.texi $(SRCDIR)/errors.texi \ $(SRCDIR)/events.texi $(SRCDIR)/objects.texi python-xlib-0.33/doc/src/errors.texi000066400000000000000000000110131435211557500174630ustar00rootroot00000000000000@c The Python X Library -- error handling @c @c Copyright 2000 Peter Liljenberg @c @node Error Handling @chapter Error Handling If an X object method generates an error, it will be handled in one of two different ways depending on the kind of method. Errors are represented by X error objects in the Xlib. If the method @emph{does not} return data, the error will most likely be detected after the method has returned. All methods which does not return data has a parameter called @code{onerror}, which can be used to provide a error handler for any error generated by this method. The error handler is called with to arguments: the error object and the low-level request object. The error @emph{must not} do call any X object methods. If that is necessary, the error handler must store the error away for later retrieval. The class @code{error.CatchError} is provided for this purpose. If no error handler is given when calling a method which generates an error, the error will be passed to the default error handler. If no default error handler is specified, the error is simply printed on @code{sys.stderr}. If the method @emph{does} return data, the error will make it impossible for it to return any valid data. An exception is raised with the error object as the exception value. It is not passed to any error handlers. @menu * X Error Classes:: X error class hierarchy. * CatchError:: Error handler class. @end menu @node X Error Classes @section X Error Classes X errors are structured in the following class hierarchy: @example @group Exception \_ error.XError \_ error.BadRequest \_ error.BadValue \_ error.BadAtom \_ error.BadMatch \_ error.BadAccess \_ error.BadAlloc \_ error.BadName \_ error.BadLength \_ error.BadImplementation \_ error.XResourceError \_ error.BadWindow \_ error.BadPixmap \_ error.BadCursor \_ error.BadFont \_ error.BadDrawable \_ error.BadColor \_ error.BadGC \_ error.BadIDChoice @end group @end example All error objects has the following attributes: @table @code @item code The numeric error code @item sequence_number The sequence number of the failed request @item resource_id The bad resource id. For all the @code{error.XResourceError} this is a X resource object. For the other errors it is an integer, which for some errors might have no meaning @item major_opcode The major opcode for the failed request @item minor_opcode The minor opcode for the failed request. This will be zero for all base X11R6 request, but will be interesting for extension requests @end table @node CatchError @section CatchError @code{error.CatchError} is an object which can be used as an error handler. It collects an error matching any of the specified types, which can be retrieved later. If several errors occur, only the last one is remembered. @deffn Class CatchError ( *errors ) Create a new error handler object. Initialize by providing all error classes you are interested in as arguments. If no error classes are provided at all, this means that all errors will be considered. @end deffn Pass the @code{error.CatchError} object as the @code{onerror} parameter to X object methods. If these methods generated any errors matching the ones specified, it can be retrieved with the following functions: @defmethod CatchError get_error ( ) Return the last error object caught, or None if no matching errors has occured. @end defmethod @defmethod CatchError get_request ( ) Return the request object for the last error caught, or None if no matching errors has occured. @end defmethod @code{error.CatchError} objects can be reused: @defmethod CatchError reset ( ) Forget any caught error. @end defmethod Since the X protocol is mostly asynchronous any error we're watching for might not have been received when we call @code{get_error}. To make sure that the request has been processed by the server and any error generated has been received by the Xlib, we must synchronize with the server. An example of using @code{error.CatchError}: @example @group # Resize and the foo window # If it has been destroyed since we looked at it the last time, # reset variable foo to None # Create a error handler for BadWindow errors ec = error.CatchError(error.BadWindow) # Perform the operation foo.configure(width = 100, height = 200, onerror = ec) # Sync communication with server display.sync() # And check if there was any error if ec.get_error(): foo = None @end group @end example python-xlib-0.33/doc/src/events.texi000066400000000000000000000637761435211557500175020ustar00rootroot00000000000000 @node Event Handling @chapter Event Handling Events are sent from the X server to the X client. Most of the event types deal with user input, but there are also event types used for inter-client communication. Most X applications are built around an event loop, where the client waits for the server to send events. The client responds to the events, typically by doing one or more X requests. @menu * Getting Events:: Waiting for events. * Selecting Events:: Selecting interesting events. * Event Types:: Details on all event types. * Sending Events:: Clients sending events to other clients. @end menu @node Getting Events @section Getting Events Events can be sent at any time, not necessarily when the client is ready to receive an event. Therefore they must be stored temporarily from that they are read from the network until the client is ready to handle them. Read but unhandled events are stored on an event queue in the Display object. There are two functions to access this queue: @defmethod Display next_event ( ) Return the next event in the event queue. If the event queue is empty, block until an event is read from the network, and return that one. @end defmethod @defmethod Display pending_events ( ) Return the number of events which can be returned without blocking. @end defmethod A trivial event loop would simply loop infinitely, waiting for an event and then handling it. It could look like this: @example while 1: event = disp.next_event() handle_event(event) @end example However, most applications need more control, e.g. to simultaneously handle a network connection or at regular intervals schedule timeouts. The module @code{select} is often used for this. @code{Display} objects can be used with @code{select}, since they have the required @code{fileno()} method. When @code{select} indicates that a @code{Display} object is ready for reading, that means that the server has sent some data to the client. That alone doesn't guarantee that an entire event has arrived, so one must first use @code{pending_events()} to make sure that @code{next_event()} will return without blocking. A simple event loop which waits for events or a one-second timeout looks like this: @example while 1: # Wait for display to send something, or a timeout of one second readable, w, e = select.select([disp], [], [], 1) # if no files are ready to be read, it's an timeout if not readable: handle_timeout() # if display is readable, handle as many events as have been received elif disp in readable: i = disp.pending_events() while i > 0: event = disp.next_event() handle_event(event) i = i - 1 # loop around to wait for more things to happen @end example @node Selecting Events @section Selecting Events To avoid flooding the clients with events in which they have no interest, they must explicitly tell the server which events they are interested in. This is done by providing the @code{event_mask} attribute when creating windows with @code{Window.create_window} or in calls to @code{Window.change_attributes}. The value of this attribute is a mask of all types of events the client is interested in on that particular window. Whenever the server generates an event for a window which matches the clients event mask on that window, the event will be sent to the client. The following table lists all event masks and the corresponding event types and classes. All event masks and types are integer constants defined in the module @code{Xlib.X}. Classes have the same name as the event type, and are defined in @code{Xlib.protocol.event}. @multitable {SubstructureRedirectMask} {VisibilityNotify} {Colormap changed or installed} @item @strong{Mask} @tab @strong{Type and Class} @tab @strong{Generated when} @item ButtonMotionMask @* Button1MotionMask @* Button2MotionMask @* Button3MotionMask @* Button4MotionMask @* Button5MotionMask @tab MotionNotify @tab Pointer moved with any or a certain button down @item @tab @tab @item ButtonPressMask @tab ButtonPress @tab Pointer button pressed @item ButtonReleaseMask @tab ButtonRelease @tab Pointer button released @item @tab @tab @item ColormapChangeMask @tab ColormapNotify @tab Colormap changed or installed @item @tab @tab @item EnterWindowMask @tab EnterNotify @tab Pointer enters window @item LeaveWindowMask @tab LeaveNotify @tab Pointer leaves window @item @tab @tab @item ExposureMask @tab Expose @* NoExpose @tab Window needs to be redrawn @item @tab @tab @item FocusChangeMask @tab FocusIn @* FocusOut @tab Focus changes @item KeymapStateMask @tab KeymapNotify @tab After EnterNotify and FocusIn @item @tab @tab @item KeyPressMask @tab KeyPress @tab Key is pressed @item KeyReleaseMask @tab ReleasePress @tab Key is released @item @tab @tab @item PointerMotionMask @tab MotionNotify @tab Pointer is moved @item @tab @tab @item PropertyChangeMask @tab PropertyNotify @tab Window properties change @item @tab @tab @item StructureNotifyMask @tab CirculateNotify @* ConfigureNotify @* DestroyNotify @* GravityNotify @* MapNotify @* ReparentNotify @* UnmapNotify @tab Window structure changes @item @tab @tab @item SubstructureNotifyMask @tab CirculateNotify @* ConfigureNotify @* CreateNotify @* DestroyNotify @* GravityNotify @* MapNotify @* ReparentNotify @* UnmapNotify @tab Child window structure changes @item @tab @tab @item ResizeRedirectMask @tab ResizeRequest @tab Controlling window size change @item @tab @tab @item SubstructureRedirectMask @tab CirculateRequest @* ConfigureRequest @* MapRequest @tab Controlling changes to child windows @item @tab @tab @item VisibilityChangeMask @tab VisibilityNotify @tab Window is obscured or visible @end multitable There are also some event types which are always sent to the clients, regardless of any event masks: @multitable {@strong{Type and Class}} {Other client sends message} @item @strong{Type and Class} @tab @strong{Cut'n'pasting between windows} @item ClientMessage @tab Other client sends message @item @tab @item MappingMotify @tab Keyboard mapping changes @item @tab @item SelectionClear @* SelectionNotify @* SelectionRequest @tab Cut'n'pasting between windows @end multitable @node Event Types @section Event Types This section describes all event types by listing their fields and basic information on when they are generated. All events are defined in the module @code{Xlib.protocol.event}. All event types have the following two attributes: @defivar Event type Stores the X type code of this event. Type codes are integers in the range 2-127, and are defined with symbolic names in @code{Xlib.X}. The symbolic names are the same as the event class names, except for the special event @code{AnyEvent}. @end defivar @defivar Event send_event This attribute is normally 0, meaning that the event was generated by the X server. It is set to 1 if this event was instead sent from another client. @end defivar Event object can be created by instantiating the corresponding event class, providing all the attributes described for the event as keyword arguments. @defvr Event KeyPress @defvrx Event KeyRelease @defvrx Event ButtonPress @defvrx Event ButtonRelease @defvrx Event MotionNotify These events are generated when a key or a button logically changes state, or when the pointer logically moves. In the discussion below, the @dfn{source window} is the window that the event occured in. The event may be generated on some other window than the source window, see XKeyEvent(3X11) for details. The same man page also describes @code{MotionNotify}. @defivar KeyButtonPointerEvent time The server X time when this event was generated. @end defivar @defivar KeyButtonPointerEvent root The root window which the source window is an inferior of. @end defivar @defivar KeyButtonPointerEvent window The window the event is reported on. @end defivar @defivar KeyButtonPointerEvent same_screen Set to 1 if @code{window} is on the same screen as @code{root}, 0 otherwise. @end defivar @defivar KeyButtonPointerEvent child If the source window is an inferior of @code{window}, @code{child} is set to the child of @code{window} that is the ancestor of (or is) the source window. Otherwise it is set to @code{X.NONE}. @end defivar @defivar KeyButtonPointerEvent root_x @defivarx KeyButtonPointerEvent root_y The pointer coordinates at the time of the event, relative to the root window. @end defivar @defivar KeyButtonPointerEvent event_x @defivarx KeyButtonPointerEvent event_y The pointer coordinates at the time of the event, relative to @code{window}. If @code{window} is not on the same screen as @code{root}, these are set to 0. @end defivar @defivar KeyButtonPointerEvent state The logical state of the button and modifier keys just before the event. @end defivar @defivar KeyButtonPointerEvent detail For @code{KeyPress} and @code{KeyRelease}, this is the keycode of the event key. For @code{ButtonPress} and @code{ButtonRelease}, this is the button of the event. For @code{MotionNotify}, this is either @code{X.NotifyNormal} or @code{X.NotifyHint}. @end defivar @end defvr @defvr Event EnterNotify @defvrx Event LeaveNotify If pointer motion or window hierarchy change causes the pointer to be in another window than before, these events are generated instead of a @code{MotionNotify} event. The semantics are quite complex, see XCrossingEvent(3X11) for details. @defivar EnterLeaveEvent time The server X time when this event was generated. @end defivar @defivar EnterLeaveEvent root The root window of the pointer at the end of this event. @end defivar @defivar EnterLeaveEvent window The window the event is reported for. @end defivar @defivar EnterLeaveEvent child In a @code{LeaveNotify} event, if a child of @code{window} contains the initial pointer position, this is set to that child window. In a @code{EnterNotify} event, if a child of @code{window} contains the final pointer position, this is set to that child window. Otherwise this is set to @code{X.NONE}. @end defivar @defivar EnterLeaveEvent root_x @defivarx EnterLeaveEvent root_y The final pointer position relative to @code{root}. @end defivar @defivar EnterLeaveEvent event_x @defivarx EnterLeaveEvent event_y The final pointer position relative to @code{window}. @end defivar @defivar EnterLeaveEvent state The modifier and button state at the time of the event. @end defivar @defivar EnterLeaveEvent mode One of @code{X.NotifyNormal}, @code{X.NotifyGrab} or @code{X.NotifyUngrab}. @end defivar @defivar EnterLeaveEvent detail One of @code{X.NotifyAncestor}, @code{X.NotifyVirtual}, @code{X.NotifyInferior}, @code{X.NotifyNonlinear}, or @code{X.NotifyNonlinearVirtual}. @end defivar @defivar EnterLeaveEvent flags If bit 0 is set, @code{window} is the focus window or an inferior of it. If bit 1 is set, @code{window} is on the same screen as @code{root}. @end defivar @end defvr @defvr Event FocusIn @defvrx Event FocusOut These events are generated when the focus changes. This is also very complex events, see XFocusChangeEvent(3X11) for details. @defivar FocusEvent window The window the event is generated for. @end defivar @defivar FocusEvent mode One of @code{X.NotifyNormal}, @code{X.NotifyWhileGrabbed}, @code{X.NotifyGrab}, or @code{X.NotifyUngrab}. @end defivar @defivar FocusEvent detail One of @code{X.NotifyAncestor}, @code{X.NotifyVirtual}, @code{X.NotifyInferior}, @code{X.NotifyNonlinear}, @code{X.NotifyNonlinearVirtual}, @code{X.NotifyPointer}, @code{X.NotifyPointerRoot}, or @code{X.NONE}. @end defivar @end defvr @defvr Event KeymapNotify This event is generated immediately after every @code{EnterNotify} and @code{FocusIn}. @defivar KeymapNotify data A list of 31 eight-bit integers, as returned by query_keymap. @end defivar @end defvr @defvr Event Expose This event is generated when regions of a window has to be redrawn. The regions are decomposed into a set of rectangles, and an @code{Expose} event is generated for each rectangle. @defivar Expose window The window containing regions to redraw. @end defivar @defivar Expose x @defivarx Expose y @defivarx Expose width @defivarx Expose height The coordinates of the rectangle to redraw. @end defivar @defivar Expose count At least this many more @code{Expose} events will immediately follow for this window. If this is the last event, @code{count} is set to 0. This allows a simple application to ignore all @code{Expose} events with a non-zero @code{count}, and then redraw the entire window when the zero event is received. @end defivar @end defvr @defvr Event GraphicsExpose @defvrx Event NoExpose These events may be generated for drawables when a graphics context with @code{graphics_exposures} selected is used. See XGraphicsExposeEvent(3X11) for details. Both events have these attributes: @defivar GraphicsExpose drawable The drawable of the event. @end defivar @defivar GraphicsExpose major_event @defivarx GraphicsExpose minor_event The major and minor number of the request that generated this event. For the core protocol @code{major_event} is always 62 (CopyArea) or 63 (CopyPlane), and @code{minor_event} is always 0. @end defivar GraphicsExpose have these additional attributes: @defivar GraphicsExpose x @defivarx GraphicsExpose y @defivarx GraphicsExpose width @defivarx GraphicsExpose height The coordinates of the event region. @end defivar @defivar GraphicsExpose count At least this many more @code{GraphicsExposure} events follows. The last one has @code{count} set to 0. @end defivar @end defvr @defvr Event VisibilityNotify These events are generated when the visibility of a viewable window is changed. See XVisibilityNotifyEvent(3X11). @defivar VisibiltyNotify window The window of the event. @end defivar @defivar VisibiltyNotify state One of @code{X.VisibilityUnobscured}, @code{X.VisibilityPartiallyObscured}, or @code{X.VisibilityFullyObscured}. @end defivar @end defvr @defvr Event CreateNotify This event is generated when a window is created. @code{X.SubstructureNotifyMask} must be selected on the parent of the new window to receive this event. @defivar CreateNotify parent The parent of the new window. @end defivar @defivar CreateNotify window The new window. @end defivar @defivar CreateNotify x @defivarx CreateNotify y @defivarx CreateNotify width @defivarx CreateNotify height @defivarx CreateNotify border_width @defivarx CreateNotify override These values are fetched from the @code{create_window} call. @end defivar @end defvr @defvr Event DestroyNotify This event is generated when a window is destroyed. @defivar DestroyNotify event The window that the event is generated for. @end defivar @defivar DestroyNotify window The window that was destroyed. @end defivar @end defvr @defvr Event UnmapNotify This event is generated when a window is unmapped. @defivar UnmapNotify event The window that the event is generated for. @end defivar @defivar UnmapNotify window The window that was unmapped. @end defivar @defivar Event from_configure This is true if @code{window} was unmapped because its parent was resized and @code{window} had win-gravity @code{X.UnmapGravity}. @end defivar @end defvr @defvr Event MapNotify This event is generated when a window is mapped. @defivar MapNotify event The window that the event is generated for. @end defivar @defivar MapNotify window The window that was mapped. @end defivar @defivar Event override This is set from the corresponding window attribute. @end defivar @end defvr @defvr Event MapRequest This event is reported to the client that has set @code{X.SubstructureRedirectMask} on a window, and an unmapped child of that window attempts to be mapped by some other client, unless the child has override-redirect set. @defivar MapRequest parent The parent window. @end defivar @defivar MapRequest window The child window that attempts to be mapped. @end defivar @end defvr @defvr Event ReparentNotify This event is reported to clients selecting @code{X.SubstructureNotifyMask} on either the old or the new parent and to clients selecting @code{X.StructureNotifyMask} on the reparented window. @defivar ReparentNotify event The window the event is generated for. @end defivar @defivar ReparentNotify window The reparented window. @end defivar @defivar ReparentNotify parent The new parent window. @end defivar @defivar ReparentNotify x @defivarx ReparentNotify y The coordinates of the upper-left outer corner of @code{window} in @code{parent}. @end defivar @defivar ReparentNotify override This is set from the corresponding attribute on @code{window}. @end defivar @end defvr @defvr Event ConfigureNotify This event is generated when a configure request actually changes the state of the window. @defivar ConfigureNotify event The window that the event is generated for. @end defivar @defivar ConfigureNotify window The window that has been changed. @end defivar @defivar ConfigureNotify x @defivarx ConfigureNotify y @defivarx ConfigureNotify width @defivarx ConfigureNotify height @defivarx ConfigureNotify border_width The new coordinate and geometry of @code{window}. @end defivar @defivar ConfigureNotify above_sibling This is @code{X.NONE} if this window is at the bottom of the window stack. Otherwise it is the sibling window that @code{window} is immediately above. @end defivar @defivar ConfigureNotify override This is set from the corresponding attribute on @code{window}. @end defivar @end defvr @defvr Event ConfigureRequest This event is reported to the client that has set @code{X.SubstructureRedirectMask} on the parent of a window that another client attempts to configure, unless the window has override-redirect set. @defivar ConfigureRequest parent The parent of the window being configured. @end defivar @defivar ConfigureRequest window The window being configured. @end defivar @defivar ConfigureRequest value_mask A bitmask indicating which values that the caller tries to change. @end defivar @defivar ConfigureRequest x @defivarx ConfigureRequest y @defivarx ConfigureRequest width @defivarx ConfigureRequest height @defivarx ConfigureRequest border_width The window geometry in the configure call. If @code{X.CWX}, @code{X.CWY}, @code{X.CWWidth}, @code{X.CWHeight}, or @code{X.CWBorderWidth} is set in @code{value_mask}, the corresponding attributes contains the new value as given in the configure call, otherwise the current value is used. @end defivar @defivar ConfigureRequest stack_mode If @code{X.CWStackMode} is set in @code{value_mask}, this is the stack mode specified in the configure call, one of @code{X.Above}, @code{X.Below}, @code{X.TopIf}, @code{X.BottomIf}, or @code{X.Opposite}. If the flag is not set, this is set to @code{X.Above}. @end defivar @defivar ConfigureRequest sibling If @code{X.CWSibling} is set in @code{value_mask}, this is the sibling window specified in the configure call. If the flag is not set, this is set to @code{X.NONE}. @end defivar @end defvr @defvr Event GravityNotify This event is generated when a window is moved because its parent's size has changed. @defivar GravityNotify event The window the event is generated for. @end defivar @defivar GravityNotify window The window that moved. @end defivar @defivar GravityNotify x @defivarx GravityNotify y The new coordinates of the upper-left outer corner of @code{window}. @end defivar @end defvr @defvr Event ResizeRequest This is reported to the client selecting @code{X.ResizeRedirectMask} on a window, and another client attempts to resize it. @defivar ResizeRedirect window The window that was attempted to be resized. @end defivar @defivar ResizeRedirect width @defivarx ResizeRedirect height The requested size of the window, excluding the border. @end defivar @end defvr @defvr Event CirculateNotify This event is generated when a window is restacked caused by a circulate call. @defivar Event event The window the event is reported on. @end defivar @defivar Event window The window that has been restacked. @end defivar @defivar Event place Either @code{X.PlaceOnTop} or @code{X.PlaceOnBottom}. @end defivar @end defvr @defvr Event CirculateRequest This event is reported to the client that has set @code{X.SubstructureRedirectMask} on the parent of a window that needs to be restacked as a result of a circulate call on the parent. @defivar CirculateRequest parent The parent window. @end defivar @defivar CirculateRequest window The window that should be restacked. @end defivar @defivar CirculateRequest place Where @code{window} should be placed, either @code{X.PlaceOnTop} or @code{X.PlaceOnBottom}. @end defivar @end defvr @defvr Event PropertyNotify This event is generated when a property on a window is changed. @defivar Event window The window which the property is or was set on. @end defivar @defivar Event atom The atom identifying the property. @end defivar @defivar Event time The server X time when the property was changed. @end defivar @defivar Event state What was changed, either @code{X.PropertyNewValue} or @code{X.PropertyDelete}. @end defivar @end defvr @defvr Event SelectionClear This event is reported to the owner of a selection when it has gotten a new owner. @defivar SelectionClear window The owner window of the selection. @end defivar @defivar SelectionClear atom The selection atom. @end defivar @defivar SelectionClear time The server X time when the selection was last changed. @end defivar @end defvr @defvr Event SelectionRequest This event is reported to the owner of a selection when a client requests it by calling convert_selection. @defivar SelectionRequest owner The owner window of the selection. @end defivar @defivar SelectionRequest requestor @defivarx SelectionRequest selection @defivarx SelectionRequest target @defivarx SelectionRequest property @defivarx SelectionRequest time These attributes are fetched from the convert_selection call. @end defivar @end defvr @defvr Event SelectionNotify This event is generated by the server if there are no owner of a selection when convert_selection is called. If there is an owner, it should send this event to the requestor when the selection has been converted. @defivar SelectionNotify requestor @defivarx SelectionNotify selection @defivarx SelectionNotify target @defivarx SelectionNotify property @defivarx SelectionNotify time See XSelectionEvent(3X11). @end defivar @end defvr @defvr Event ColormapNotify This event is generated when the colormap attribute of a window is set, or when a window's colormap is installed or uninstalled. @defivar ColormapNotify window The affected window. @end defivar @defivar ColormapNotify colormap The colormap of the window, or @code{X.NONE}. @end defivar @defivar ColormapNotify new Set to 1 if the colormap attribute has been set, 0 when the colormap is installed or uninstalled. @end defivar @defivar ColormapNotify state Indicates whether the colormap is installed or not, either @code{X.ColormapInstalled} or @code{X.ColormapUninstalled}. @end defivar @end defvr @defvr Event MappingNotify This event is sent to all clients, without any event mask having to be set. It is sent when the keyboard or pointer mapping is changed. @defivar MappingNotify request The mapping that has changed, one of @code{X.MappingModifier}, @code{X.MappingKeyboard} or @code{X.Pointer}. @end defivar @defivar MappingNotify first_keycode @defivarx MappingNotify count If the keyboard mapping has changed, this is the range of modified keycodes. @end defivar @end defvr @defvr Event ClientMessage This event is only generated by clients using send_event. @defivar ClientMessage window The destination window of the event. @end defivar @defivar ClientMessage client_type The type of message, an atom. @end defivar @defivar ClientMessage data The message data as a tuple: @code{(format, mdata)} Format must be one of 8, 16, or 32. mdata must either be a string of exactly 20 characters, or a list of exactly 20, 10 or 5 integers depending of the format. @end defivar @end defvr @defvr Event AnyEvent This event is represents an event the Xlib does not recognise. These should never be returned by @code{Display.next_event()}, but they might be useful for sending special events to other clients. @defivar AnyEvent detail An eight-bit integer. @end defivar @defivar AnyEvent data A string of exactly 28 characters. @end defivar @end defvr @node Sending Events @section Sending Events Clients can send events to each other. Most often these are general-purpose @code{ClientMessage} events, but any event type can be sent. To send an event, an event object must be created. This is done by instantiating an event class, providing values to all its fields as keyword parameters. The event is then sent with the @code{send_event()} method: @defmethod Window send_event ( event, event_mask = 0, propagate = 0, @w{onerror = None )} Send @var{event} to this window. If @var{event_mask} is 0, the event is sent to the client that created the window. Otherwise the event is sent to every client selecting any of the event types in @var{event_mask}. If no clients have selected any of the event types and @var{propagate} is true, the X server will search for an ancestor of this window on which some client has selected any of the event types. For details, see XSendEvent(3X11). @end defmethod @defmethod Display send_event ( destination, event, @w{event_mask = 0,} @w{propagate = 0,} @w{onerror = None )} Send @var{event} to @var{destination}, which can either be a @code{Window} object or a constant: If @code{X.PointerWindow} is specified, send the event to the window the pointer is in. If @code{X.InputFocus} is specified and the focus window contains the pointer, send the event to the window that the pointer is in. Otherwise, send the event to the focus window. @end defmethod As an example, this creates and sends a @code{ClientMessage} event of the client specific type @code{HELLO_WORLD} (an atom), to the window @code{dest} and with the 8-bitformat value @code{"G'day, mate"} (which must be exactly twenty bytes): @example cm_event = Xlib.protocol.event.ClientMessage( window = dest, client_type = HELLO_WORLD, data = (8, "G'day mate\0\0\0\0\0\0\0\0\0\0")) dest.send_event(cm_event) @end example python-xlib-0.33/doc/src/objects.texi000066400000000000000000001047221435211557500176120ustar00rootroot00000000000000 @node X Objects @chapter X Objects All X operations are performed by invoking object methods. The objects and their methods are listed in the following nodes, however with no detailed explanations. The reader are referred to other sources of X documentation for details, e.g. the X protocol specification, the C Xlib documentation or man pages. A vast collection of X documentation links can be found at @uref{http://www.rahul.net/kenton/xsites.html}. Methods returning a single value will return that directly. Otherwise, an object containing attributes for each of the result values is returned. Methods returning some value will raise an exception on error. Methods which does not return any value have instead an @code{on_error} parameter, which can be used to specify an error handler. @menu * Display:: Methods on Display objects. * Resource:: Methods common to all the following resource objects. * Colormap:: Methods on Colormap objects. * Cursor:: Methods on Cursor objects. * Drawable:: Methods common to Window and Pixmap objects. * Window:: Methods on Window objects. * Pixmap:: Methods on Pixmap objects. * Fontable:: Methods common to GC and Font objects. * GC:: Methods on GC objects. * Font:: Methods on Font objects. @end menu @node Display @section Display Display information retrieval methods: @defmethod Display get_display_name ( ) Returns the name used to connect to the server, either provided when creating the @code{Display} object, or fetched from the environmental variable @code{$DISPLAY}. @end defmethod @defmethod Display fileno ( ) Returns the file descriptor number of the underlying socket. This method is provided to allow @code{Display} objects to be passed @code{select.select()}. @end defmethod @defmethod Display close ( ) Close the display, freeing the resources that it holds. @end defmethod @defmethod Display set_error_handler ( handler ) Set the default error handler which will be called for all unhandled errors. @var{handler} should take two arguments as a normal request error handler, but the second argument (the request) will be None. @xref{Error Handling}. @end defmethod @defmethod Display flush ( ) Flush the request queue, building and sending the queued requests. This can be necessary in applications that never wait for events, and in threaded applications. @end defmethod @defmethod Display sync ( ) Flush the queue and wait until the server has processed all the queued requests. Use this e.g. when it is important that errors caused by a certain request is trapped. @end defmethod @defmethod Display next_event ( ) Return the next event. If there are no events queued, it will block until the next event is fetched from the server. @end defmethod @defmethod Display pending_events ( ) Return the number of events queued, i.e. the number of times that @code{Display.next_event()} can be called without blocking. @end defmethod @defmethod Display has_extension ( extension ) Check if both the server and the client library support the X extension named @var{extension}. @end defmethod @defmethod Display create_resource_object ( type, id ) Create a resource object of @var{type} for the integer @var{id}. @var{type} should be one of the following strings: @table @code @item resource @itemx drawable @itemx window @itemx pixmap @itemx fontable @itemx font @itemx gc @itemx colormap @itemx cursor @end table This function can be used when a resource ID has been fetched e.g. from an resource or a command line argument. Resource objects should never be created by instantiating the appropriate class directly, since any X extensions dynamically added by the library will not be available. @end defmethod @defmethod Display screen ( sno = None ) Return the information about screen number @var{sno}, or the default screen if @var{sno} is @code{None}. The return object has the following attributes: @table @code @item root The screen root window. @item default_colormap The default colormap for the root window and its children. @item white_pixel @itemx black_pixel The pixel values for white and black, respectively, in the default colormap. @item current_input_mask The event mask of the root window at the time the connection was set up. @item width_in_pixels @itemx height_in_pixels The size of the root window in pixels, i.e. the size of the entire screen. @item width_in_mms @itemx height_in_mms The physical size of the screen, in millimeters. @item min_installed_maps @itemx max_installed_maps The minimum and maximum number of colormaps that can be installed at the same time. @item root_visual The visual type of the root window. @item backing_store Whether the screen supports backing store, one of the values @code{X.WhenMapped}, @code{X.NotUseful}, or @code{X.Always}. @item save_unders True if the screen supports save unders. @item root_depth The depth of the root window. @item allowed_depths A list of the pixmap and windows depths that this screen supports. The list items have the following attributes: @table @code @item depth This depth is supported by the screen. @item visuals A list of visual types that is valid for this depth. If this list is empty, this depth is only valid for pixmaps and not for windows. The list items have the following attributes: @table @code @item visual_id The ID of this visual. @item visual_class One of @code{X.StaticGray}, @code{X.StaticColor}, @code{X.TrueColor}, @code{X.GrayScale}, @code{X.PseudoColor}, or @code{X.DirectColor}. @item bits_per_rgb_value The number of bits used to represent an entire RGB-value, allowing a total of @code{2^bits_per_rgb_value} distinct colors. @item colormap_entries The number of free entries in a newly created colormap. @item red_mask @itemx blue_mask @itemx green_mask Bitmasks selecting the three color components from the entire RGB value. @end table @end table @end table @end defmethod @defmethod Display screen_count ( ) Return the total number of screens on the display. @end defmethod @defmethod Display get_default_screen ( ) Return the number of the default screen, extracted from the display name. @end defmethod @defmethod Display keycode_to_keysym ( keycode, index ) Convert a @var{keycode} to a keysym, looking in entry @var{index}. Normally index 0 is unshifted, 1 is shifted, 2 is alt grid, and 3 is shift+alt grid. If that key entry is not bound, @code{X.NoSymbol} is returned. @end defmethod @defmethod Display keysym_to_keycode ( keysym ) Look up the primary keycode that is bound to @var{keysym}. If several keycodes are found, the one with the lowest index and lowest code is returned. If @var{keysym} is not bound to any key, 0 is returned. @end defmethod @defmethod Display keysym_to_keycodes ( keysym ) Look up all the keycodes that is bound to @code{keysym}. A list of tuples @code{(keycode, index)} is returned, sorted primarily on the lowest index and secondarily on the lowest keycode. @end defmethod @defmethod Display refresh_keyboard_mapping ( evt ) This method should be called once when a @code{MappingNotify} event is received, to update the keymap cache. @var{evt} should be the event object. @end defmethod @defmethod Display lookup_string ( keysym ) Attempt to convert @var{keysym} into a single character or a string. If no translation is found, @code{None} is returned. @end defmethod @defmethod Display rebind_string ( keysym, newstring ) Set the string representation of @code{keysym} to @code{newstring}, so that it will be returned by @code{Display.lookup_string()}. @end defmethod X requests methods: @defmethod Display intern_atom ( name, only_if_exists = 0 ) Intern the string @var{name}, returning its atom number. If @var{only_if_exists} is true and the atom does not already exist, it will not be created and @code{X.NONE} is returned. @end defmethod @defmethod Display get_atom_name ( atom ) Look up the name of @var{atom}, returning it as a string. Will raise @code{BadAtom} if @var{atom} does not exist. @end defmethod @defmethod Display get_selection_owner ( selection ) Return the window that owns @var{selection} (an atom), or @code{X.NONE} if there is no owner for the selection. Can raise @code{BadAtom}. @end defmethod @defmethod Display send_event ( destination, event, @w{event_mask = 0,} @w{propagate = 0,} @w{onerror = None )} Send a synthetic event to the window @code{destination} which can be a window object, or @code{X.PointerWindow} or @code{X.InputFocus}. @code{event} is the event object to send, instantiated from one of the classes in @code{protocol.events}. See XSendEvent(3X11) for details. There is also a @code{Window.send_event()} method. @end defmethod @defmethod Display ungrab_pointer ( time, onerror = None ) Release a grabbed pointer and any queued events. See XUngrabPointer(3X11). @end defmethod @defmethod Display change_active_pointer_grab ( event_mask, cursor, time, @w{onerror = None )} Change the dynamic parameters of a pointer grab. See XChangeActivePointerGrab(3X11). @end defmethod @defmethod Display ungrab_keyboard ( time, onerror = None ) Ungrab a grabbed keyboard and any queued events. See XUngrabKeyboard(3X11). @end defmethod @defmethod Display allow_events ( mode, time, @w{onerror = None )} Release some queued events. @var{mode} should be one of @code{X.AsyncPointer}, @code{X.SyncPointer}, @code{X.AsyncKeyboard}, @code{X.SyncKeyboard}, @code{X.ReplayPointer}, @code{X.ReplayKeyboard}, @code{X.AsyncBoth}, or @code{X.SyncBoth}. @var{time} should be a timestamp or @code{X.CurrentTime}. @end defmethod @defmethod Display grab_server ( onerror = None ) Disable processing of requests on all other client connections until the server is ungrabbed. Server grabbing should be avoided as much as possible. @end defmethod @defmethod Display ungrab_server ( onerror = None ) Release the server if it was previously grabbed by this client. @end defmethod @defmethod Display warp_pointer ( x, y, @w{src_window = X.NONE,} @w{src_x = 0,} @w{src_y = 0,} @w{src_width = 0,} @w{src_height = 0,} @w{onerror = None )} Move the pointer relative its current position by the offsets (@var{x}, @var{y}). However, if @var{src_window} is a window the pointer is only moved if the specified rectangle in @var{src_window} contains it. If @var{src_width} is 0 it will be replaced with the width of @var{src_window} - @var{src_x}. @var{src_height} is treated in a similar way. To move the pointer to absolute coordinates, use @code{Window.warp_pointer()}. @end defmethod @defmethod Display set_input_focus ( focus, revert_to, time, @w{onerror = None )} Set input focus to @var{focus}, which should be a window, @code{X.PointerRoot} or @code{X.NONE}. @var{revert_to} specifies where the focus reverts to if the focused window becomes not visible, and should be @code{X.RevertToParent}, @code{RevertToPointerRoot}, or @code{RevertToNone}. See XSetInputFocus(3X11) for details. There is also a @code{Window.set_input_focus()}. @end defmethod @defmethod Display get_input_focus ( ) Return an object with the following attributes: @table @code @item focus The window which currently holds the input focus, @code{X.NONE} or @code{X.PointerRoot}. @item revert_to Where the focus will revert, one of @code{X.RevertToParent}, @code{RevertToPointerRoot}, or @code{RevertToNone}. @end table @end defmethod @defmethod Display query_keymap ( ) Return a bit vector for the logical state of the keyboard, where each bit set to 1 indicates that the corresponding key is currently pressed down. The vector is represented as a list of 32 integers. List item N contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N. @end defmethod @defmethod Display open_font ( name ) Open the font identifed by the pattern @var{name} and return its font object. If @var{name} does not match any font, @code{None} is returned. @end defmethod @defmethod Display list_fonts ( pattern, max_names ) Return a list of font names matching @var{pattern}. No more than @var{max_names} will be returned. @end defmethod @defmethod Display list_fonts_with_info ( pattern, max_names ) Return a list of fonts matching @var{pattern}. No more than @var{max_names} will be returned. Each list item represents one font and has the following properties: @table @code @item name The name of the font. @item min_bounds @itemx max_bounds @itemx min_char_or_byte2 @itemx max_char_or_byte2 @itemx default_char @itemx draw_direction @itemx min_byte1 @itemx max_byte1 @itemx all_chars_exist @itemx font_ascent @itemx font_descent @itemx replies_hint See the description of XFontStruct in XGetFontProperty(3X11) for details on these values. @item properties A list of properties. Each entry has two attributes: @table @code @item name The atom identifying this property. @item value A 32-bit unsigned value. @end table @end table @end defmethod @defmethod Display set_font_path ( path, onerror = None ) Set the font path to @var{path}, which should be a list of strings. If @var{path} is empty, the default font path of the server will be restored. @end defmethod @defmethod Display get_font_path ( ) Return the current font path as a list of strings. @end defmethod @defmethod Display query_extension ( name ) Ask the server if it supports the extension @var{name}. If it is supported an object with the following attributes is returned: @table @code @item major_opcode The major opcode that the requests of this extension uses. @item first_event The base event code if the extension have additional events, or 0. @item first_error The base error code if the extension have additional errors, or 0. @end table If the extension is not supported, @code{None} is returned. @end defmethod @defmethod Display list_extensions ( ) Return a list of all the extensions provided by the server. @end defmethod @defmethod Display change_keyboard_mapping ( first_keycode, keysyms, @w{onerror = None )} Modify the keyboard mapping, starting with @var{first_keycode}. @var{keysyms} is a list of tuples of keysyms. @code{keysyms[n][i]} will be assigned to keycode @code{first_keycode+n} at index @code{i}. @end defmethod @defmethod Display get_keyboard_mapping ( first_keycode, count ) Return the current keyboard mapping as a list of tuples, starting at @var{first_keycount} and no more than @var{count}. @end defmethod @defmethod Display change_keyboard_control ( @w{onerror = None,} **keys ) Change the parameters provided as keyword arguments: @table @code @item key_click_percent The volume of key clicks between 0 (off) and 100 (load). -1 will restore default setting. @item bell_percent The base volume of the bell, coded as above. @item bell_pitch The pitch of the bell in Hz, -1 restores the default. @item bell_duration The duration of the bell in milliseconds, -1 restores the default. @item led @itemx led_mode @code{led_mode} should be @code{X.LedModeOff} or @code{X.LedModeOn}. If @code{led} is provided, it should be a 32-bit mask listing the LEDs that should change. If @code{led} is not provided, all LEDs are changed. @item key @itemx auto_repeat_mode @code{auto_repeat_mode} should be one of @code{X.AutoRepeatModeOff}, @code{X.AutoRepeatModeOn}, or @code{X.AutoRepeatModeDefault}. If @code{key} is provided, that key will be modified, otherwise the global state for the entire keyboard will be modified. @end table @end defmethod @defmethod Display get_keyboard_control ( ) Return an object with the following attributes: @table @code @item global_auto_repeat @code{X.AutoRepeatModeOn} or @code{X.AutoRepeatModeOff}. @item auto_repeats A list of 32 integers. List item N contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N. If a bit is on, autorepeat is enabled for the corresponding key. @item led_mask A 32-bit mask indicating which LEDs are on. @item key_click_percent The volume of key click, from 0 to 100. @item bell_percent @itemx bell_pitch @itemx bell_duration The volume, pitch and duration of the bell. @end table @end defmethod @defmethod Display bell ( percent = 0, onerror = None ) Ring the bell at the volume @var{percent} which is relative the base volume. See XBell(3X11). @end defmethod @defmethod Display change_pointer_control ( @w{accel = None,} @w{threshold = None,} @w{onerror = None )} To change the pointer acceleration, set @var{accel} to a tuple @code{(num, denum)}. The pointer will then move @code{num/denum} times the normal speed if it moves beyond the threshold number of pixels at once. To change the threshold, set it to the number of pixels. -1 restores the default. @end defmethod @defmethod Display get_pointer_control ( ) Return an object with the following attributes: @table @code @item accel_num @itemx accel_denom The acceleration as numerator/denumerator. @item threshold The number of pixels the pointer must move before the acceleration kicks in. @end table @end defmethod @defmethod Display set_screen_saver ( timeout, interval, prefer_blank, allow_exposures, @w{onerror = None )} See XSetScreenSaver(3X11). @end defmethod @defmethod Display get_screen_saver ( ) Return an object with the attributes @code{timeout}, @code{interval}, @code{prefer_blanking}, @code{allow_exposures}. See XGetScreenSaver(3X11) for details. @end defmethod @defmethod Display change_hosts ( mode, host_family, host, @w{onerror = None )} @var{mode} is either @code{X.HostInsert} or @code{X.HostDelete}. @var{host_family} is one of @code{X.FamilyInternet}, @code{X.FamilyDECnet}, @code{X.FamilyChaos}, @code{X.FamilyServerInterpreted} or @code{X.FamilyInternetV6}. @var{host} is a list of bytes. For the Internet family, it should be the four bytes of an IPv4 address. @end defmethod @defmethod Display list_hosts ( ) Return an object with the following attributes: @table @code @item mode @code{X.EnableAccess} if the access control list is used, @code{X.DisableAccess} otherwise. @item hosts The hosts on the access list. Each entry has the following attributes: @table @code @item family @code{X.FamilyInternet}, @code{X.FamilyDECnet}, @code{X.FamilyChaos}, @code{X.FamilyServerInterpreted} or @code{X.FamilyInternetV6}. @item name A list of byte values, the coding depends on @code{family}. For the Internet family, it is the 4 bytes of an IPv4 address. @end table @end table @end defmethod @defmethod Display set_access_control ( mode, onerror = None ) Enable use of access control lists at connection setup if @var{mode} is @code{X.EnableAccess}, disable if it is @code{X.DisableAccess}. @end defmethod @defmethod Display set_close_down_mode ( mode, onerror = None ) Control what will happen with the client's resources at connection close. The default is @code{X.DestroyAll}, the other values are @code{X.RetainPermanent} and @code{X.RetainTemporary}. @end defmethod @defmethod Display force_screen_saver ( mode, onerror = None ) If @var{mode} is @code{X.ScreenSaverActive} the screen saver is activated. If it is @code{X.ScreenSaverReset}, the screen saver is deactivated as if device input had been received. @end defmethod @defmethod Display set_pointer_mapping ( map ) Set the mapping of the pointer buttons. @var{map} is a list of logical button numbers. @var{map} must be of the same length as the list returned by @code{Display.get_pointer_mapping()}. @code{map[n]} sets the logical number for the physical button @code{n+1}. Logical number 0 disables the button. Two physical buttons cannot be mapped to the same logical number. If one of the buttons to be altered are logically in the down state, @code{X.MappingBusy} is returned and the mapping is not changed. Otherwise the mapping is changed and @code{X.MappingSuccess} is returned. @end defmethod @defmethod Display get_pointer_mapping ( ) Return a list of the pointer button mappings. Entry N in the list sets the logical button number for the physical button N+1. @end defmethod @defmethod Display set_modifier_mapping ( keycodes ) Set the keycodes for the eight modifiers @code{X.Shift}, @code{X.Lock}, @code{X.Control}, @code{X.Mod1}, @code{X.Mod2}, @code{X.Mod3}, @code{X.Mod4} and @code{X.Mod5}. @var{keycodes} should be a eight-element list where each entry is a list of the keycodes that should be bound to that modifier. If any changed key is logically in the down state, @code{X.MappingBusy} is returned and the mapping is not changed. If the mapping violates some server restriction, @code{X.MappingFailed} is returned. Otherwise the mapping is changed and @code{X.MappingSuccess} is returned. @end defmethod @defmethod Display get_modifier_mapping ( ) Return a list of eight lists, one for each modifier. The list can be indexed using @code{X.ShiftMapIndex}, @code{X.Mod1MapIndex}, and so on. The sublists list the keycodes bound to that modifier. @end defmethod @defmethod Display no_operation ( onerror = None ) Do nothing but send a request to the server. @end defmethod @node Resource @section Resource All resource objects can be compared and hashed, so they can be used as mapping indices. They also have this method: @defmethod Resource kill_client ( onerror = None ) @end defmethod @node Colormap @section Colormap @xref{Resource}, for additional methods on @code{Colormap} objects. @defmethod Colormap free ( onerror = None ) @end defmethod @defmethod Colormap copy_colormap_and_free ( scr_cmap ) Returns Colormap. @end defmethod @defmethod Colormap install_colormap ( onerror = None ) @end defmethod @defmethod Colormap uninstall_colormap ( onerror = None ) @end defmethod @defmethod Colormap alloc_color ( red, green, blue ) @end defmethod @defmethod Colormap alloc_named_color ( name ) Returns None or Card32('pixel'), Card16('exact_red'), Card16('exact_green'), Card16('exact_blue'), Card16('screen_red'), Card16('screen_green'), Card16('screen_blue'), @end defmethod @defmethod Colormap alloc_color_cells ( contiguous, colors, planes ) Returns List('pixels', Card32Obj), List('masks', Card32Obj), @end defmethod @defmethod Colormap alloc_color_planes ( contiguous, colors, red, green, blue ) Returns Card32('red_mask'), Card32('green_mask'), Card32('blue_mask'), List('pixels', Card32Obj), @end defmethod @defmethod Colormap free_colors ( pixels, plane_mask, onerror = None ) @end defmethod @defmethod Colormap store_colors ( items, onerror = None ) @end defmethod @defmethod Colormap store_named_color ( name, pixel, flags, onerror = None ) @end defmethod @defmethod Colormap query_colors ( pixels ) Returns List('colors', structs.RGB), @end defmethod @defmethod Colormap lookup_color ( name ) Returns Card16('exact_red'), Card16('exact_green'), Card16('exact_blue'), Card16('screen_red'), Card16('screen_green'), Card16('screen_blue'), @end defmethod @node Cursor @section Cursor @xref{Resource}, for additional methods on @code{Cursor} objects. @defmethod Cursor free ( onerror = None ) @end defmethod @defmethod Cursor recolor ( (fore_red, fore_green, fore_blue), (back_red, back_green, back_blue), onerror = None ) @end defmethod @node Drawable @section Drawable @code{Drawable} is a base class of @code{Window} and @code{Pixmap} objects. @xref{Window}, and @ref{Pixmap}. @xref{Resource}, for additional methods. @defmethod Drawable get_geometry ( ) Returns Window('root'), Int16('x'), Int16('y'), Card16('width'), Card16('height'), Card16('border_width'), @end defmethod @defmethod Drawable create_pixmap ( width, height, depth ) Returns Pixmap. @end defmethod @defmethod Drawable create_gc ( **keys ) Returns GC. @end defmethod @defmethod Drawable copy_area ( gc, src_drawable, src_x, src_y, width, height, dst_x, dst_y, onerror = None ) @end defmethod @defmethod Drawable copy_plane ( gc, src_drawable, src_x, src_y, width, height, dst_x, dst_y, bit_plane, onerror = None ) @end defmethod @defmethod Drawable poly_point ( gc, coord_mode, points, onerror = None ) @end defmethod request.PolyPoint(display = self.display, onerror = onerror, coord_mode = coord_mode, drawable = self.id, gc = gc, points = points) @defmethod Drawable point ( gc, x, y, onerror = None ) @end defmethod @defmethod Drawable poly_line ( gc, coord_mode, points, onerror = None ) @end defmethod @defmethod Drawable line ( gc, x1, y1, x2, y2, onerror = None ) @end defmethod @defmethod Drawable poly_segment ( gc, segments, onerror = None ) @end defmethod @defmethod Drawable poly_rectangle ( gc, rectangles, onerror = None ) @end defmethod @defmethod Drawable rectangle ( gc, x, y, width, height, onerror = None ) @end defmethod @defmethod Drawable poly_arc ( gc, arcs, onerror = None ) @end defmethod @defmethod Drawable arc ( gc, x, y, width, height, angle1, angle2, onerror = None ) @end defmethod @defmethod Drawable fill_poly ( gc, shape, coord_mode, points, onerror = None ) @end defmethod @defmethod Drawable poly_fill_rectangle ( gc, rectangles, onerror = None ) @end defmethod @defmethod Drawable fill_rectangle ( gc, x, y, width, height, onerror = None ) @end defmethod @defmethod Drawable poly_fill_arc ( gc, arcs, onerror = None ) @end defmethod @defmethod Drawable fill_arc ( gc, x, y, width, height, angle1, angle2, onerror = None ) @end defmethod @defmethod Drawable put_image ( ) Not implemented yet. @end defmethod @defmethod Drawable get_image ( ) Not implemented yet. @end defmethod @defmethod Drawable draw_text ( gc, x, y, text, onerror = None ) @end defmethod @defmethod Drawable poly_text ( gc, x, y, items, onerror = None ) @end defmethod @defmethod Drawable poly_text_16 ( gc, x, y, items, onerror = None ) @end defmethod @defmethod Drawable image_text ( gc, x, y, string, onerror = None ) @end defmethod @defmethod Drawable image_text_16 ( gc, x, y, string, onerror = None ) @end defmethod @defmethod Drawable query_best_size ( item_class, width, height ) Returns Card16('width'), Card16('height'), @end defmethod @node Window @section Window @code{Window} objects have additional objects, see @ref{Resource} and @ref{Drawable}. @defmethod Window create_window ( x, y, width, height, border_width, depth, window_class = X.CopyFromParent, visual = X.CopyFromParent, **keys ) Returns Window @end defmethod @defmethod Window change_attributes ( onerror = None, **keys ) @end defmethod @defmethod Window get_attributes ( ) Returns Card8('backing_store'), Card32('visual'), Card16('class'), Card8('bit_gravity'), Card8('win_gravity'), Card32('backing_bit_planes'), Card32('backing_pixel'), Card8('save_under'), Card8('map_is_installed'), Card8('map_state'), Card8('override_redirect'), Colormap('colormap', (X.NONE, )), Card32('all_event_masks'), Card32('your_event_mask'), Card16('do_not_propagate_mask'), @end defmethod @defmethod Window destroy ( onerror = None ) @end defmethod @defmethod Window destroy_sub_windows ( onerror = None ) @end defmethod @defmethod Window change_save_set ( mode, onerror = None ) @end defmethod @defmethod Window reparent ( parent, x, y, onerror = None ) @end defmethod @defmethod Window map ( onerror = None ) @end defmethod @defmethod Window map_sub_windows ( onerror = None ) @end defmethod @defmethod Window unmap ( onerror = None ) @end defmethod @defmethod Window unmap_sub_windows ( onerror = None ) @end defmethod @defmethod Window configure ( onerror = None, **keys ) @end defmethod @defmethod Window circulate ( direction, onerror = None ) @end defmethod @defmethod Window query_tree ( ) Returns Window('root'), Window('parent', (X.NONE, )), List('children', WindowObj), @end defmethod @defmethod Window change_property ( property, type, format, data, mode = X.PropModeReplace, onerror = None ) @end defmethod @defmethod Window delete_property ( property, onerror = None ) @end defmethod @defmethod Window get_property ( property, type, offset, length, delete = 0 ) Returns None or Card32('property_type'), Card8('format'), PropertyData('value'), Card32('bytes_after'), @end defmethod @defmethod Window get_full_property ( property, type, sizehint = 10 ) Returns None or Card32('property_type'), Card8('format'), PropertyData('value'), Card32('bytes_after'), @end defmethod @defmethod Window list_properties ( ) Returns List('atoms', Card32Obj), @end defmethod @defmethod Window set_selection_owner ( selection, time, onerror = None ) @end defmethod @defmethod Window convert_selection ( selection, target, property, time, onerror = None ) @end defmethod @defmethod Window send_event ( event, event_mask = 0, propagate = 0, onerror = None ) @end defmethod @defmethod Window grab_pointer ( owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, time ) Returns Card8('status'), @end defmethod @defmethod Window grab_button ( button, modifiers, owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, onerror = None ) @end defmethod @defmethod Window ungrab_button ( button, modifiers, onerror = None ) @end defmethod @defmethod Window grab_keyboard ( owner_events, pointer_mode, keyboard_mode, time ) Returns Card8('status'), @end defmethod @defmethod Window grab_key ( key, modifiers, owner_events, pointer_mode, keyboard_mode, onerror = None ) @end defmethod @defmethod Window ungrab_key ( key, modifiers, onerror = None ) @end defmethod @defmethod Window query_pointer ( ) Returns Card8('same_screen'), Window('root'), Window('child', (X.NONE, )), Int16('root_x'), Int16('root_y'), Int16('win_x'), Int16('win_y'), Card16('mask'), @end defmethod @defmethod Window get_motion_events ( start, stop ) Returns List('events', structs.TimeCoord), @end defmethod @defmethod Window translate_coords ( src_window, src_x, src_y ) Returns Window('child', (X.NONE, )), Int16('x'), Int16('y'), @end defmethod @defmethod Window warp_pointer ( x, y, src_window = 0, src_x = 0, src_y = 0, src_width = 0, src_height = 0, onerror = None ) @end defmethod @defmethod Window set_input_focus ( revert_to, time, onerror = None ) @end defmethod @defmethod Window clear_area ( x = 0, y = 0, width = 0, height = 0, exposures = 0, onerror = None ) @end defmethod @defmethod Window create_colormap ( visual, alloc ) Returns Colormap. @end defmethod @defmethod Window list_installed_colormaps ( ) Returns List('cmaps', ColormapObj), @end defmethod @defmethod Window rotate_properties ( properties, delta, onerror = None ) @end defmethod @defmethod Window set_wm_name ( name, onerror = None ) @end defmethod @defmethod Window get_wm_name ( ) Returns None or string. @end defmethod @defmethod Window set_wm_icon_name ( name, onerror = None ) @end defmethod @defmethod Window get_wm_icon_name ( ) Returns None or string. @end defmethod @defmethod Window set_wm_class ( inst, cls, onerror = None ) @end defmethod @defmethod Window get_wm_class ( ) Returns None or (instance, class) @end defmethod @defmethod Window set_wm_transient_for ( window, onerror = None ) @end defmethod @defmethod Window get_wm_transient_for ( ) Returns None or Window. @end defmethod @defmethod Window set_wm_protocols ( protocols, onerror = None ) @end defmethod @defmethod Window get_wm_protocols ( ) Returns list of atoms. @end defmethod @defmethod Window set_wm_colormap_windows ( windows, onerror = None ) @end defmethod @defmethod Window get_wm_colormap_windows ( ) Returns list of Windows. @end defmethod @defmethod Window set_wm_client_machine ( name, onerror = None ) @end defmethod @defmethod Window get_wm_client_machine ( ) Returns None or string. @end defmethod @defmethod Window set_wm_normal_hints ( hints = {}, onerror = None, **keys ) @end defmethod @defmethod Window get_wm_normal_hints ( ) Returns Card32('flags'), Int32('min_width', default = 0), Int32('min_height', default = 0), Int32('max_width', default = 0), Int32('max_height', default = 0), Int32('width_inc', default = 0), Int32('height_inc', default = 0), Object('min_aspect', Aspect, default = (0, 0)), Object('max_aspect', Aspect, default = (0, 0)), Int32('base_width', default = 0), Int32('base_height', default = 0), Int32('win_gravity', default = 0), @end defmethod @defmethod Window set_wm_hints ( hints = {}, onerror = None, **keys ) @end defmethod @defmethod Window get_wm_hints ( ) Returns Card32('flags'), Card32('input', default = 0), Set('initial_state', 4, ( Xutil.NormalState, Xutil.IconicState ), default = Xutil.NormalState), Pixmap('icon_pixmap', default = 0), Window('icon_window', default = 0), Int32('icon_x', default = 0), Int32('icon_y', default = 0), Pixmap('icon_mask', default = 0), Window('window_group', default = 0), @end defmethod @defmethod Window set_wm_state ( hints = {}, onerror = None, **keys ) @end defmethod @defmethod Window get_wm_state ( ) Returns Set('state', 4, ( Xutil.WithdrawnState, Xutil.NormalState, Xutil.IconicState )), Window('icon', ( X.NONE, )), @end defmethod @defmethod Window set_wm_icon_size ( hints = {}, onerror = None, **keys ) @end defmethod @defmethod Window get_wm_icon_size ( ) Returns Card32('min_width'), Card32('min_height'), Card32('max_width'), Card32('max_height'), Card32('width_inc'), Card32('height_inc'), @end defmethod @node Pixmap @section Pixmap @code{Pixmap} objects have additional objects, see @ref{Resource} and @ref{Drawable}. @defmethod Pixmap free ( onerror = None ) @end defmethod @defmethod Pixmap create_cursor ( mask, (fore_red, fore_green, fore_blue), (back_red, back_green, back_blue), x, y ) Returns Cursor. @end defmethod @node Fontable @section Fontable @code{Fontable} is a base class of @code{GC} and @code{Font} objects. @xref{GC}, and @ref{Font}. @xref{Resource}, for additional methods. @defmethod Fontable query ( ) Returns Object('min_bounds', structs.CharInfo), Object('max_bounds', structs.CharInfo), Card16('min_char_or_byte2'), Card16('max_char_or_byte2'), Card16('default_char'), Card8('draw_direction'), Card8('min_byte1,'), Card8('max_byte1,'), Card8('all_chars_exist'), Int16('font_ascent'), Int16('font_descent'), List('properties', structs.FontProp), List('char_infos', structs.CharInfo), @end defmethod @defmethod Fontable query_text_extents ( string ) Returns Card8('draw_direction'), Int16('font_ascent'), Int16('font_descent'), Int16('overall_ascent'), Int16('overall_descent'), Int32('overall_width'), Int32('overall_left'), Int32('overall_right'), @end defmethod @node GC @section GC @code{GC} objects have additional objects, see @ref{Resource} and @ref{Fontable}. @defmethod GC change ( onerror = None, **keys ) @end defmethod @defmethod GC copy ( src_gc, mask, onerror = None ) @end defmethod @defmethod GC set_dashes ( offset, dashes, onerror = None ) @end defmethod @defmethod GC set_clip_rectangles ( x_origin, y_origin, rectangles, ordering, onerror = None ) @end defmethod @defmethod GC free ( onerror = None ) @end defmethod @node Font @section Font @code{Font} objects have additional objects, see @ref{Resource} and @ref{Fontable}. @defmethod Font close ( onerror = None ) @end defmethod @defmethod Font create_glyph_cursor ( mask, source_char, mask_char, (fore_red, fore_green, fore_blue), (back_red, back_green, back_blue) ) Returns Cursor. @end defmethod python-xlib-0.33/doc/src/package.texi000066400000000000000000000033171435211557500175520ustar00rootroot00000000000000@c The Python X Library -- package layout @c @c Copyright 2000 Peter Liljenberg @c @node Package Layout @chapter Package Layout The Python X Library is distributed as a Python package, named @code{Xlib}. It contains a number of modules providing the main library interface: @table @code @item display Contains the @code{Display} class, providing the X connection and access to all other X objects and operations. @item error Contains all @code{Xlib} exception classes. @item threaded Imported to set up the library to be thread-safe. @item rdb Contains @code{ResourceDB}, an X resource database class, and related code. @item X Contains symbolic names for all basic X protocol constants. @item Xutil Contains additional constants for mainly the ICCCM standard. @item XK Contains symbolic names for all X keysyms. @item Xatom Contains symbolic names for all standard X atoms. @item Xcursorfont Contains symbolic names for all standard X fonts. @end table There is also a number of subpackages, but they will mainly be of interest to developers of the Xlib itself: @table @code @item protocol The low-level protocol implementation. Contains definitions of all X request, responses, events and errors, in addition to the core network code. The high-level object oriented interface provided by @code{Xlib.display} is merely a wrapper around this package. @item support Miscellaneous supporting code for handling threads and operating system-specific features. @item xobject Contains classes for all X objects, which are returned by various display operations. @item ext Contains various X protocol extensions. Extensions supported by the server are loaded automatically at the display connection. @end table python-xlib-0.33/doc/src/python-xlib.texi000066400000000000000000000100121435211557500204220ustar00rootroot00000000000000\input texinfo @c -*-texinfo-*- @c @c %**start of header @setfilename python-xlib.info @settitle The Python X Library @setchapternewpage odd @c %**end of header @ifinfo This file documents the Python X Library. Copyright 2000-2001 Peter Liljenberg Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. @ignore Permission is granted to process this file through TeX and print the results, provided the printed document carries a copying permission notice identical to this one except for the removal of this paragraph (this paragraph not being relevant to the printed manual). @end ignore Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections entitled ``Copying'' and ``GNU General Public License'' are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. @end ifinfo @titlepage @title The Python X Library @author Peter Liljenberg @c The following two commands @c start the copyright page. @page @vskip 0pt plus 1filll Copyright @copyright{} 2000--2001 Peter Liljenberg Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections entitled ``Copying'' and ``GNU General Public License'' are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. @end titlepage @contents @node Top @top Introduction The Python X Library is a complete library for writing X Windows client applications in Python. It implements the entire X11R6 protocol and some extensions, and also some supplementary functionality such as a resource database. It is written entirely in Python, and is therefore entirely independent of the traditional C Xlib; it only requires a Python installation with network support. Although the X11R6 protocol is the basis of all X client applications, it is a little too low-level to be useful for writing advanced graphical interfaces. To this end, many different widget sets has been developed, a few of the more popular are Motif, Qt and Gtk. The Python X Library is not compatible with any of these, as they are based on the C Xlib. As a result the Python X Library isn't in itself very useful for writing GUIs, but is eminent for writing small X applications with no advanced GUI, e.g. simple monitor programs, or for that matter more advanced background applications such as window managers. @menu * Basic X Concepts:: The fundamental X Windows concepts. * Package Layout:: The layout of the Python Xlib package. * Connect to a Display:: Connecting to a X server display. * Error Handling:: Handling X errors. * Event Handling:: Handling X events. @c * Xlib and Threads:: Using the Python Xlib in threaded applications. @c * Asynchronicity:: The asynchronous nature of X. * X Objects:: X objects and their operations. @c * Extensions:: Various X protocol extensions. @end menu @include concepts.texi @include package.texi @include connect.texi @include errors.texi @include events.texi @include objects.texi @bye python-xlib-0.33/examples/000077500000000000000000000000001435211557500155425ustar00rootroot00000000000000python-xlib-0.33/examples/childwin.py000077500000000000000000000076561435211557500177360ustar00rootroot00000000000000#!/usr/bin/python # # examples/childwin.py -- demonstrate child windows. # # Copyright (C) 2008 David Bronke # Copyright (C) 2002 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys import os # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import X, display, Xutil # Application window class Window(object): def __init__(self, display): self.d = display # Find which screen to open the window on self.screen = self.d.screen() # background pattern bgsize = 20 bgpm = self.screen.root.create_pixmap( bgsize, bgsize, self.screen.root_depth ) bggc = self.screen.root.create_gc( foreground=self.screen.black_pixel, background=self.screen.black_pixel ) bgpm.fill_rectangle(bggc, 0, 0, bgsize, bgsize) bggc.change(foreground=self.screen.white_pixel) bgpm.arc(bggc, -bgsize // 2, 0, bgsize, bgsize, 0, 360 * 64) bgpm.arc(bggc, bgsize // 2, 0, bgsize, bgsize, 0, 360 * 64) bgpm.arc(bggc, 0, -bgsize // 2, bgsize, bgsize, 0, 360 * 64) bgpm.arc(bggc, 0, bgsize // 2, bgsize, bgsize, 0, 360 * 64) # Actual window self.window = self.screen.root.create_window( 100, 100, 400, 300, 0, self.screen.root_depth, X.InputOutput, X.CopyFromParent, # special attribute values background_pixmap=bgpm, event_mask=( X.StructureNotifyMask | X.ButtonReleaseMask ), colormap=X.CopyFromParent ) # Set some WM info self.WM_DELETE_WINDOW = self.d.intern_atom('WM_DELETE_WINDOW') self.WM_PROTOCOLS = self.d.intern_atom('WM_PROTOCOLS') self.window.set_wm_name('Xlib example: childwin.py') self.window.set_wm_icon_name('childwin.py') self.window.set_wm_class('childwin', 'XlibExample') self.window.set_wm_protocols([self.WM_DELETE_WINDOW]) self.window.set_wm_hints( flags=Xutil.StateHint, initial_state=Xutil.NormalState ) self.window.set_wm_normal_hints( flags=(Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), min_width=50, min_height=50 ) # Map the window, making it visible self.window.map() # Child window (self.childWidth, self.childHeight) = (20, 20) self.childWindow = self.window.create_window( 20, 20, self.childWidth, self.childHeight, 0, self.screen.root_depth, X.CopyFromParent, X.CopyFromParent, # special attribute values background_pixel=self.screen.white_pixel, colormap=X.CopyFromParent, ) self.childWindow.map() # Main loop, handling events def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Button released, add or subtract elif e.type == X.ButtonRelease: if e.detail == 1: print("Moving child window.") self.childWindow.configure( x=e.event_x - self.childWidth // 2, y=e.event_y - self.childHeight // 2 ) self.d.flush() # Somebody wants to tell us something elif e.type == X.ClientMessage: if e.client_type == self.WM_PROTOCOLS: fmt, data = e.data if fmt == 32 and data[0] == self.WM_DELETE_WINDOW: sys.exit(0) if __name__ == '__main__': Window(display.Display()).loop() python-xlib-0.33/examples/dpms.py000077500000000000000000000077541435211557500170770ustar00rootroot00000000000000#!/usr/bin/python # # examples/dpms.py -- DPMS usage examples. # # Copyright (C) 2020 Thiago Kenji Okada # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA import random import time from Xlib import display from Xlib.ext import dpms class DPMSExamples(object): def __init__(self): self.d = display.Display() capable = self.d.dpms_capable() assert capable, 'DPMS is not supported in your system' self.initial_info = self.d.dpms_info() self.initial_timeouts = self.d.dpms_get_timeouts() # Making sure that DPMS is enable for this examples self.d.dpms_enable() self.d.sync() def print_dpms(self): current_info = self.d.dpms_info() print('\nDPMS state: {}\nPower level: {}'.format(current_info.state, current_info.power_level)) current_timeouts = self.d.dpms_get_timeouts() print('Standby: {}, Suspend: {}, Off: {}\n'.format(current_timeouts.standby_timeout, current_timeouts.suspend_timeout, current_timeouts.off_timeout)) def toggle_dpms(self): current_info = self.d.dpms_info() if current_info.state: self.d.dpms_disable() else: self.d.dpms_enable() self.d.sync() def restore(self): print('Restoring DPMS configuration') self.d.dpms_set_timeouts(self.initial_timeouts.standby_timeout, self.initial_timeouts.suspend_timeout, self.initial_timeouts.off_timeout) if self.initial_info.state: self.d.dpms_enable() else: self.d.dpms_disable() self.d.sync() self.print_dpms() def set_random_timeouts(self): # Can be any number greater than 0 # Using 10 just to not turnoff the screen suddenly standby_timeout = random.randint(10, 600) # Shouldn't be smaller than standby_timeout suspend_timeout = random.randint(standby_timeout, 600) # Shouldn't be smaller than standby_timeout or suspend_timeout off_timeout = random.randint(suspend_timeout, 600) self.d.dpms_set_timeouts(standby_timeout, suspend_timeout, off_timeout) self.d.sync() def turn_off_display(self): self.d.dpms_force_level(dpms.DPMSModeOff) self.d.sync() def turn_on_display(self): self.d.dpms_force_level(dpms.DPMSModeOn) self.d.sync() def main(): try: examples = DPMSExamples() print('Initial state') examples.print_dpms() print('Setting random timeouts') examples.set_random_timeouts() examples.print_dpms() print('The next example will turn-off your screen, press Ctrl-C to cancel.') time.sleep(2) examples.turn_off_display() print('Turning it on again...') time.sleep(2) examples.turn_on_display() print() print('Toggle DPMS') examples.toggle_dpms() examples.print_dpms() print('Toggle it again') examples.toggle_dpms() examples.print_dpms() finally: examples.restore() if __name__ == '__main__': main() python-xlib-0.33/examples/draw-proto.py000077500000000000000000000160641435211557500202240ustar00rootroot00000000000000#!/usr/bin/python # # examples/draw.py -- protocol test application. # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA import sys import os # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import X from Xlib.protocol import display from Xlib.protocol.request import * # Application window (only one) class Window(object): def __init__(self, display): self.d = display self.objects = [] # Find which screen to open the window on self.screen = self.d.info.roots[self.d.default_screen] # Allocate ids to the window and gc self.window = self.d.allocate_resource_id() self.gc = self.d.allocate_resource_id() # Create a window CreateWindow(self.d, None, self.screen.root_depth, self.window, self.screen.root, 50, 50, 300, 200, 2, X.InputOutput, X.CopyFromParent, # special attribute values background_pixel = self.screen.white_pixel, event_mask = (X.ExposureMask | X.StructureNotifyMask | X.ButtonPressMask | X.ButtonReleaseMask | X.Button1MotionMask), colormap = X.CopyFromParent) # Create a gc for drawing CreateGC(self.d, None, self.gc, self.window, # special attribute values foreground = self.screen.black_pixel, background = self.screen.white_pixel) # Map the window, making it visible MapWindow(self.d, None, self.window) # Main loop, handling events def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Some part of the window has been exposed, # redraw all the objects. if e.type == X.Expose: for o in self.objects: o.expose(e) # Left button pressed, start to draw if e.type == X.ButtonPress and e.detail == 1: current = Movement(self, e) self.objects.append(current) # Left button released, finish drawing if e.type == X.ButtonRelease and e.detail == 1 and current: current.finish(e) current = None # Mouse movement with button pressed, draw if e.type == X.MotionNotify and current: current.motion(e) # A drawed objects, consisting of either a single # rhomboid, or two rhomboids connected by a winding line class Movement(object): def __init__(self, win, ev): self.win = win self.left = ev.event_x - 5 self.right = ev.event_x + 5 self.top = ev.event_y - 5 self.bottom = ev.event_y + 5 self.time = ev.time self.lines = [(ev.event_x, ev.event_y)] self.first = Rhomboid(self.win, ev) self.last = None def motion(self, ev): # Find all the mouse coordinates since the # last event received r = GetMotionEvents(self.win.d, window = self.win.window, start = self.time, stop = ev.time) # Record the previous last coordinate, and append # the new coordinates firstline = len(self.lines) - 1 if r.events: # Discard the first coordinate if that is identical to # the last recorded coordinate pos = r.events[0] if (pos.x, pos.y) == self.lines[-1]: events = r.events[1:] else: events = r.events # Append all coordinates for pos in events: x = pos.x y = pos.y if x < self.left: self.left = x if x > self.right: self.right = x if y < self.top: self.top = y if y > self.bottom: self.bottom = y self.lines.append((x, y)) # Append the event coordinate, if that is different from the # last movement coordinate if (ev.event_x, ev.event_y) != self.lines[-1]: self.lines.append((ev.event_x, ev.event_y)) # Draw a line between the new coordinates PolyLine(self.win.d, None, X.CoordModeOrigin, self.win.window, self.win.gc, self.lines[firstline:]) self.time = ev.time def finish(self, ev): self.motion(ev) if len(self.lines) > 1: self.last = Rhomboid(self.win, ev) self.left = min(ev.event_x - 5, self.left) self.right = max(ev.event_x + 5, self.right) self.top = min(ev.event_y - 5, self.top) self.bottom = max(ev.event_y + 5, self.bottom) def expose(self, ev): # We should check if this object is in the exposed # area, but I can't be bothered right now, so just # redraw on the last Expose in every batch if ev.count == 0: self.first.draw() if self.last: # Redraw all the lines PolyLine(self.win.d, None, X.CoordModeOrigin, self.win.window, self.win.gc, self.lines) self.last.draw() # A rhomboid, drawed around the Movement endpoints class Rhomboid(object): def __init__(self, win, ev): self.win = win self.x = ev.event_x self.y = ev.event_y self.draw() def draw(self): # Draw the segments of the rhomboid PolyLine(self.win.d, None, X.CoordModePrevious, self.win.window, self.win.gc, [(self.x, self.y - 5), (5, 5), (-5, 5), (-5, -5), (5, -5)]) if __name__ == '__main__': Window(display.Display()).loop() python-xlib-0.33/examples/draw.py000077500000000000000000000165121435211557500170610ustar00rootroot00000000000000#!/usr/bin/python # # examples/draw.py -- high-level xlib test application. # # Copyright (C) 2000 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA import sys import os # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import X, display, Xutil # Application window (only one) class Window(object): def __init__(self, display): self.d = display self.objects = [] # Find which screen to open the window on self.screen = self.d.screen() self.window = self.screen.root.create_window( 50, 50, 300, 200, 2, self.screen.root_depth, X.InputOutput, X.CopyFromParent, # special attribute values background_pixel = self.screen.white_pixel, event_mask = (X.ExposureMask | X.StructureNotifyMask | X.ButtonPressMask | X.ButtonReleaseMask | X.Button1MotionMask), colormap = X.CopyFromParent, ) self.gc = self.window.create_gc( foreground = self.screen.black_pixel, background = self.screen.white_pixel, ) # Set some WM info self.WM_DELETE_WINDOW = self.d.intern_atom('WM_DELETE_WINDOW') self.WM_PROTOCOLS = self.d.intern_atom('WM_PROTOCOLS') self.window.set_wm_name('Xlib example: draw.py') self.window.set_wm_icon_name('draw.py') self.window.set_wm_class('draw', 'XlibExample') self.window.set_wm_protocols([self.WM_DELETE_WINDOW]) self.window.set_wm_hints(flags = Xutil.StateHint, initial_state = Xutil.NormalState) self.window.set_wm_normal_hints(flags = (Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), min_width = 20, min_height = 20) # Map the window, making it visible self.window.map() # Main loop, handling events def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Some part of the window has been exposed, # redraw all the objects. if e.type == X.Expose: for o in self.objects: o.expose(e) # Left button pressed, start to draw if e.type == X.ButtonPress and e.detail == 1: current = Movement(self, e) self.objects.append(current) # Left button released, finish drawing if e.type == X.ButtonRelease and e.detail == 1 and current: current.finish(e) current = None # Mouse movement with button pressed, draw if e.type == X.MotionNotify and current: current.motion(e) if e.type == X.ClientMessage: if e.client_type == self.WM_PROTOCOLS: fmt, data = e.data if fmt == 32 and data[0] == self.WM_DELETE_WINDOW: sys.exit(0) # A drawed objects, consisting of either a single # rhomboid, or two rhomboids connected by a winding line class Movement(object): def __init__(self, win, ev): self.win = win self.left = ev.event_x - 5 self.right = ev.event_x + 5 self.top = ev.event_y - 5 self.bottom = ev.event_y + 5 self.time = ev.time self.lines = [(ev.event_x, ev.event_y)] self.first = Rhomboid(self.win, ev) self.last = None def motion(self, ev): # Find all the mouse coordinates since the # last event received events = self.win.window.get_motion_events(self.time, ev.time) self.time = ev.time # Record the previous last coordinate, and append # the new coordinates firstline = len(self.lines) - 1 if events: # Discard the first coordinate if that is identical to # the last recorded coordinate pos = events[0] if (pos.x, pos.y) == self.lines[-1]: events = events[1:] # Append all coordinates for pos in events: x = pos.x y = pos.y if x < self.left: self.left = x if x > self.right: self.right = x if y < self.top: self.top = y if y > self.bottom: self.bottom = y self.lines.append((x, y)) # Append the event coordinate, if that is different from the # last movement coordinate if (ev.event_x, ev.event_y) != self.lines[-1]: self.lines.append((ev.event_x, ev.event_y)) # Draw a line between the new coordinates self.win.window.poly_line(self.win.gc, X.CoordModeOrigin, self.lines[firstline:]) def finish(self, ev): self.motion(ev) if len(self.lines) > 1: self.last = Rhomboid(self.win, ev) self.left = min(ev.event_x - 5, self.left) self.right = max(ev.event_x + 5, self.right) self.top = min(ev.event_y - 5, self.top) self.bottom = max(ev.event_y + 5, self.bottom) def expose(self, ev): # We should check if this object is in the exposed # area, but I can't be bothered right now, so just # redraw on the last Expose in every batch if ev.count == 0: self.first.draw() if self.last: # Redraw all the lines self.win.window.poly_line(self.win.gc, X.CoordModeOrigin, self.lines) self.last.draw() # A rhomboid, drawed around the Movement endpoints class Rhomboid(object): def __init__(self, win, ev): self.win = win self.x = ev.event_x self.y = ev.event_y self.draw() def draw(self): # Draw the segments of the rhomboid self.win.window.poly_line(self.win.gc, X.CoordModePrevious, [(self.x, self.y - 5), (5, 5), (-5, 5), (-5, -5), (5, -5)]) if __name__ == '__main__': Window(display.Display()).loop() python-xlib-0.33/examples/eventthread.py000077500000000000000000000040031435211557500204250ustar00rootroot00000000000000#!/usr/bin/env python # # examples/eventthread.py -- Tests multithreaded event handling # # Copyright (C) 2010-2011 Outpost Embedded, LLC # Forest Bond # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys import os # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import time from threading import Thread from Xlib import Xatom, threaded from Xlib.display import Display class EventThread(Thread): display = None _stop = None def __init__(self, display): super(EventThread, self).__init__() self.display = display self.daemon = True def run(self): while True: event = self.display.next_event() print('event: %r' % event) def main(argv): display = Display() thread = EventThread(display) thread.start() time.sleep(1) screen = display.screen() # The get_property call should not deadlock, despite the blocking next_event # call in the thread. atom = display.intern_atom('_XROOTPMAP_ID', True) response = screen.root.get_property(atom, Xatom.PIXMAP, 0, 1) print('get_property response: %r' % response) display.close() if __name__ == '__main__': sys.exit(main(sys.argv)) python-xlib-0.33/examples/get_selection.py000077500000000000000000000126231435211557500207470ustar00rootroot00000000000000#!/usr/bin/env python # # examples/get_selection.py -- demonstrate getting selections # (equivalent to pasting from the clipboard) # # Copyright (C) 2013 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA import binascii import sys import os # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import X, display, Xutil, Xatom def log(msg, *args): sys.stderr.write(msg.format(*args) + '\n') def error(msg, *args): log(msg, *args) sys.exit(1) def main(): if len(sys.argv) < 2 or len(sys.argv) > 3: sys.exit('usage: {0} SELECTION [TYPE]\n\n' 'SELECTION is typically PRIMARY, SECONDARY or CLIPBOARD.\n' 'If TYPE is omitted, the available types for the selction are listed.' .format(sys.argv[0])) d = display.Display() sel_name = sys.argv[1] sel_atom = d.get_atom(sel_name) if len(sys.argv) > 2: target_name = sys.argv[2] target_atom = d.get_atom(target_name) else: target_name = 'TARGETS' target_atom = d.get_atom('TARGETS') # Ask the server who owns this selection, if any owner = d.get_selection_owner(sel_atom) if owner == X.NONE: log('No owner for selection {0}', sel_name) return log('selection {0} owner: 0x{1:08x} {2}', sel_name, owner.id, owner.get_wm_name()) # Create ourselves a window and a property for the returned data w = d.screen().root.create_window( 0, 0, 10, 10, 0, X.CopyFromParent) w.set_wm_name(os.path.basename(sys.argv[0])) data_atom = d.get_atom('SEL_DATA') # The data_atom should not be set according to ICCCM, and since # this is a new window that is already the case here. # Ask for the selection. We shouldn't use X.CurrentTime, but # since we don't have an event here we have to. w.convert_selection(sel_atom, target_atom, data_atom, X.CurrentTime) # Wait for the notification that we got the selection while True: e = d.next_event() if e.type == X.SelectionNotify: break # Do some sanity checks if (e.requestor != w or e.selection != sel_atom or e.target != target_atom): error('SelectionNotify event does not match our request: {0}', e) if e.property == X.NONE: log('selection lost or conversion to {0} failed', target_name) return if e.property != data_atom: error('SelectionNotify event does not match our request: {0}', e) # Get the data r = w.get_full_property(data_atom, X.AnyPropertyType, sizehint = 10000) # Can the data be used directly or read incrementally if r.property_type == d.get_atom('INCR'): log('reading data incrementally: at least {0} bytes', r.value[0]) handle_incr(d, w, data_atom, target_name) else: output_data(d, r, target_name) # Tell selection owner that we're done w.delete_property(data_atom) def handle_incr(d, w, data_atom, target_name): # This works by us removing the data property, the selection owner # getting a notification of that, and then setting the property # again with more data. To notice that, we must listen for # PropertyNotify events. w.change_attributes(event_mask = X.PropertyChangeMask) while True: # Delete data property to tell owner to give us more data w.delete_property(data_atom) # Wait for notification that we got data while True: e = d.next_event() if (e.type == X.PropertyNotify and e.state == X.PropertyNewValue and e.window == w and e.atom == data_atom): break r = w.get_full_property(data_atom, X.AnyPropertyType, sizehint = 10000) # End of data if len(r.value) == 0: return output_data(d, r, target_name) # loop around def output_data(d, r, target_name): log('got {0}:{1}, length {2}', d.get_atom_name(r.property_type), r.format, len(r.value)) if r.format == 8: if r.property_type == Xatom.STRING: value = r.value.decode('ISO-8859-1') elif r.property_type == d.get_atom('UTF8_STRING'): value = r.value.decode('UTF-8') else: value = binascii.hexlify(r.value).decode('ascii') sys.stdout.write(value) elif r.format == 32 and r.property_type == Xatom.ATOM: for v in r.value: sys.stdout.write('{0}\n'.format(d.get_atom_name(v))) else: for v in r.value: sys.stdout.write('{0}\n'.format(v)) if __name__ == '__main__': main() python-xlib-0.33/examples/nvcontrol.py000077500000000000000000000105361435211557500201500ustar00rootroot00000000000000#!/usr/bin/python # # examples/nvcontrol.py -- demonstrate the NV-CONTROL extension # # Copyright (C) 2019 Roberto Leinardi # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys import os # Change path so we find Xlib from pprint import pprint from Xlib.display import Display from Xlib.ext.nvcontrol import Gpu, Cooler sys.path.append(os.path.join(os.path.dirname(__file__), '..')) if __name__ == '__main__': display = Display() # Check for extension if not display.has_extension('NV-CONTROL'): sys.stderr.write('{}: server does not have the NV-CONTROL extension\n'.format(sys.argv[0])) ext = display.query_extension('NV-CONTROL') print(ext) sys.stderr.write("\n".join(display.list_extensions())) if ext is None: sys.exit(1) gpu = Gpu(0) fan = Cooler(0) perf_level = 3 dic = { 'get_gpu_count': display.nvcontrol_get_gpu_count(), 'get_vram': display.nvcontrol_get_vram(gpu), 'get_irq': display.nvcontrol_get_irq(gpu), 'supports_framelock': display.nvcontrol_supports_framelock(gpu), 'get_core_temp': display.nvcontrol_get_core_temp(gpu), 'get_core_threshold': display.nvcontrol_get_core_threshold(gpu), 'get_default_core_threshold': display.nvcontrol_get_default_core_threshold(gpu), 'get_max_core_threshold': display.nvcontrol_get_max_core_threshold(gpu), 'get_ambient_temp': display.nvcontrol_get_ambient_temp(gpu), 'get_cuda_cores': display.nvcontrol_get_cuda_cores(gpu), 'get_memory_bus_width': display.nvcontrol_get_memory_bus_width(gpu), 'get_total_dedicated_gpu_memory': display.nvcontrol_get_total_dedicated_gpu_memory(gpu), 'get_used_dedicated_gpu_memory': display.nvcontrol_get_used_dedicated_gpu_memory(gpu), 'get_curr_pcie_link_width': display.nvcontrol_get_curr_pcie_link_width(gpu), 'get_max_pcie_link_width': display.nvcontrol_get_max_pcie_link_width(gpu), 'get_curr_pcie_link_generation': display.nvcontrol_get_curr_pcie_link_generation(gpu), 'get_encoder_utilization': display.nvcontrol_get_encoder_utilization(gpu), 'get_decoder_utilization': display.nvcontrol_get_decoder_utilization(gpu), 'get_current_performance_level': display.nvcontrol_get_current_performance_level(gpu), 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu, perf_level), 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu, perf_level), 'get_cooler_manual_control_enabled': display.nvcontrol_get_cooler_manual_control_enabled(gpu), 'get_fan_duty': display.nvcontrol_get_fan_duty(fan), 'get_fan_rpm': display.nvcontrol_get_fan_rpm(fan), 'get_coolers_used_by_gpu': display.nvcontrol_get_coolers_used_by_gpu(gpu), 'get_max_displays': display.nvcontrol_get_max_displays(gpu), 'get_name': display.nvcontrol_get_name(gpu), 'get_driver_version': display.nvcontrol_get_driver_version(gpu), 'get_vbios_version': display.nvcontrol_get_vbios_version(gpu), 'get_gpu_uuid': display.nvcontrol_get_gpu_uuid(gpu), 'get_utilization_rates': display.nvcontrol_get_utilization_rates(gpu), 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu), 'get_gpu_nvclock_offset_range': display.nvcontrol_get_gpu_nvclock_offset_range(gpu, perf_level), 'get_mem_transfer_rate_offset_range': display.nvcontrol_get_mem_transfer_rate_offset_range(gpu, perf_level), 'get_clock_info': display.nvcontrol_get_clock_info(gpu) } pprint(dic) display.close() python-xlib-0.33/examples/profilex.py000077500000000000000000000022171435211557500177510ustar00rootroot00000000000000#!/usr/bin/python # # Program to generate profiling data. Run with one argument, # the profile stats file to generate. # Python 2/3 compatibility. from __future__ import print_function import sys import os # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import X, display, Xatom import profile def dostuff(): d = display.Display() r = d.screen().root cm = d.screen().default_colormap for i in range(0, 1000): if i % 50 == 0: print('Iteration', i) r.delete_property(Xatom.WM_NORMAL_HINTS) r.delete_property(Xatom.WM_NORMAL_HINTS) r.get_geometry() r.get_geometry() r.delete_property(Xatom.WM_NORMAL_HINTS) r.delete_property(Xatom.WM_NORMAL_HINTS) r.change_property(Xatom.WM_NORMAL_HINTS, Xatom.STRING, 32, [1, 2, 3, 4]) r.query_tree() cm.query_colors([0, 1, 2, 3, 4, 5, 6, 7]) def main(filename): profile.run('dostuff()', filename) if __name__ == '__main__': if len(sys.argv) == 2: main(sys.argv[1]) else: print(sys.argv[0], "") python-xlib-0.33/examples/put_selection.py000077500000000000000000000127101435211557500207750ustar00rootroot00000000000000#!/usr/bin/env python # # examples/put_selection.py -- demonstrate putting selections # (equivalent to copying to the clipboard) # # Copyright (C) 2013 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA import sys import os # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import X, display, Xutil, Xatom from Xlib.protocol import event # This script does not implement fancy stuff like INCR or MULTIPLE, so # put a hard limit on the amount of data we allow sending this way MAX_SIZE = 50000 def log(msg, *args): sys.stderr.write(msg.format(*args) + '\n') def error(msg, *args): log(msg, *args) sys.exit(1) def main(): if len(sys.argv) < 3: sys.exit('usage: {0} SELECTION TYPE [FILE [TYPE [FILE...]]]\n\n' 'SELECTION is typically PRIMARY, SECONDARY or CLIPBOARD.\n' 'If FILE is omitted, stdin is read.\n' 'Multiple type/file combos can be specified.\n' .format(sys.argv[0])) args = sys.argv[1:] d = display.Display() sel_name = args[0] del args[0] sel_atom = d.get_atom(sel_name) # map type atom -> data types = {} while args: type_atom = d.get_atom(args[0]) del args[0] if args: f = open(args[0], 'rb') del args[0] else: f = sys.stdin # Limit selection size to avoid implementing INCR data = f.read(MAX_SIZE) f.close() if len(data) >= MAX_SIZE: log('too much data: {0} bytes, max is {1} bytes', len(data), MAX_SIZE) error('INCR support not implemented to put larger files') types[type_atom] = data targets_atom = d.get_atom('TARGETS') # We must have a window to own a selection w = d.screen().root.create_window( 0, 0, 10, 10, 0, X.CopyFromParent) # And to grab the selection we must have a timestamp, get one with # a property notify when we're anyway setting wm_name w.change_attributes(event_mask = X.PropertyChangeMask) w.set_wm_name(os.path.basename(sys.argv[0])) e = d.next_event() sel_time = e.time w.change_attributes(event_mask = 0) # Grab the selection and make sure we actually got it w.set_selection_owner(sel_atom, sel_time) if d.get_selection_owner(sel_atom) != w: log('could not take ownership of {0}', sel_name) return log('took ownership of selection {0}', sel_name) # The event loop, waiting for and processing requests while True: e = d.next_event() if (e.type == X.SelectionRequest and e.owner == w and e.selection == sel_atom): client = e.requestor if e.property == X.NONE: log('request from obsolete client!') client_prop = e.target # per ICCCM recommendation else: client_prop = e.property target_name = d.get_atom_name(e.target) log('got request for {0}, dest {1} on 0x{2:08x} {3}', target_name, d.get_atom_name(client_prop), client.id, client.get_wm_name()) # Is the client asking for which types we support? if e.target == targets_atom: # Then respond with TARGETS and the type prop_value = [targets_atom] + types.keys() prop_type = Xatom.ATOM prop_format = 32 # Request for the offered type elif e.target in types: prop_value = types[e.target] prop_type = e.target prop_format = 8 # Something else, tell client they can't get it else: log('refusing conversion to {0}', target_name) client_prop = X.NONE # Put the data on the dest window, if possible if client_prop != X.NONE: client.change_property( client_prop, prop_type, prop_format, prop_value) # And always send a selection notification ev = event.SelectionNotify( time = e.time, requestor = e.requestor, selection = e.selection, target = e.target, property = client_prop) client.send_event(ev) # Done! elif (e.type == X.SelectionClear and e.window == w and e.atom == sel_atom): log('lost ownership of selection {0}', sel_name) return # A proper owner would also look for PropertyNotify here on # the selector's windows to implement INCR and waiting for # acknowledgement that the client has finished copying. if __name__ == '__main__': main() python-xlib-0.33/examples/record_demo.py000077500000000000000000000073501435211557500204060ustar00rootroot00000000000000#!/usr/bin/python # # examples/record_demo.py -- demonstrate record extension # # Copyright (C) 2006 Alex Badea # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA ''' Simple demo for the RECORD extension Not very much unlike the xmacrorec2 program in the xmacro package. ''' # Python 2/3 compatibility. from __future__ import print_function import sys import os # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import X, XK, display from Xlib.ext import record from Xlib.protocol import rq local_dpy = display.Display() record_dpy = display.Display() def lookup_keysym(keysym): for name in dir(XK): if name[:3] == "XK_" and getattr(XK, name) == keysym: return name[3:] return "[%d]" % keysym def record_callback(reply): if reply.category != record.FromServer: return if reply.client_swapped: print("* received swapped protocol data, cowardly ignored") return if not len(reply.data) or reply.data[0] < 2: # not an event return data = reply.data while len(data): event, data = rq.EventField(None).parse_binary_value(data, record_dpy.display, None, None) if event.type in [X.KeyPress, X.KeyRelease]: pr = event.type == X.KeyPress and "Press" or "Release" keysym = local_dpy.keycode_to_keysym(event.detail, 0) if not keysym: print("KeyCode%s" % pr, event.detail) else: print("KeyStr%s" % pr, lookup_keysym(keysym)) if event.type == X.KeyPress and keysym == XK.XK_Escape: local_dpy.record_disable_context(ctx) local_dpy.flush() return elif event.type == X.ButtonPress: print("ButtonPress", event.detail) elif event.type == X.ButtonRelease: print("ButtonRelease", event.detail) elif event.type == X.MotionNotify: print("MotionNotify", event.root_x, event.root_y) # Check if the extension is present if not record_dpy.has_extension("RECORD"): print("RECORD extension not found") sys.exit(1) r = record_dpy.record_get_version(0, 0) print("RECORD extension version %d.%d" % (r.major_version, r.minor_version)) # Create a recording context; we only want key and mouse events ctx = record_dpy.record_create_context( 0, [record.AllClients], [{ 'core_requests': (0, 0), 'core_replies': (0, 0), 'ext_requests': (0, 0, 0, 0), 'ext_replies': (0, 0, 0, 0), 'delivered_events': (0, 0), 'device_events': (X.KeyPress, X.MotionNotify), 'errors': (0, 0), 'client_started': False, 'client_died': False, }]) # Enable the context; this only returns after a call to record_disable_context, # while calling the callback function in the meantime record_dpy.record_enable_context(ctx, record_callback) # Finally free the context record_dpy.record_free_context(ctx) python-xlib-0.33/examples/run_examples.py000066400000000000000000000063361435211557500206260ustar00rootroot00000000000000#!/usr/bin/env python # # examples/run_examples.py -- run some examples. # # Copyright (C) 2016 Svetlana Filicheva # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys import os import subprocess import unittest examples_folder = os.path.abspath(os.path.dirname(__file__)) + "/" def run_example(path): """ Returns returncode of example """ cmd = "{0} {1}".format(sys.executable, path) proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) res = proc.communicate() if proc.returncode: print(res[1].decode()) return proc.returncode class TestExamples(unittest.TestCase): """ Run some of examples """ # TODO # def test_eventthread(self): # """ Run eventthread.py -- Tests multithreaded event handling """ # self.assertEqual(run_example(examples_folder + "eventthread.py"), 0) def test_get_selection(self): """ Run get_selection.py -- demonstrate getting selections """ self.assertEqual(run_example(examples_folder + "get_selection.py PRIMARY"), 0) self.assertEqual(run_example(examples_folder + "get_selection.py SECONDARY"), 0) self.assertEqual(run_example(examples_folder + "get_selection.py CLIPBOARD"), 0) def test_profilex(self): """ Run profilex.py -- program to generate profiling data """ self.assertEqual(run_example(examples_folder + "profilex.py " + examples_folder + "profilex_output"), 0) subprocess.call(["rm", examples_folder + "profilex_output"]) # TODO # def test_record_demo(self): # """ Run record_demo.py -- demonstrate record extension """ # self.assertEqual(run_example(examples_folder + "record_demo.py"), 0) def test_security(self): """ Run security.py -- demonstrate the SECURITY extension """ self.assertEqual(run_example(examples_folder + "security.py --generate"), 0) self.assertEqual(run_example(examples_folder + "security.py --revoke"), 0) def test_xfixes(self): """ Run xfixes.py -- demonstrate the XFIXES extension """ self.assertEqual(run_example(examples_folder + "xfixes.py"), 0) def test_xlsatoms(self): """ Run xlsatoms.py -- show list atoms on X server """ self.assertEqual(run_example(examples_folder + "xlsatoms.py"), 0) def test_xres(self): """ Run xres.py -- demonstrate the X-Resource extension """ self.assertEqual(run_example(examples_folder + "xres.py"), 0) if __name__ == '__main__': unittest.main() python-xlib-0.33/examples/security.py000077500000000000000000000053621435211557500177740ustar00rootroot00000000000000#!/usr/bin/python # # examples/security.py -- demonstrate the SECURITY extension # # Copyright (C) 2011 Outpost Embedded, LLC # Forest Bond # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys, os from optparse import OptionParser # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib.display import Display from Xlib.ext import security def main(argv): parser = OptionParser() parser.add_option('--generate', action='store_true', default=False) parser.add_option('--proto', default='MIT-MAGIC-COOKIE-1') parser.add_option('--trusted', action='store_true', default=False) parser.add_option('--untrusted', action='store_true', default=False) parser.add_option('--revoke', action='store_true', default=False) opts, args = parser.parse_args(argv[1:]) if opts.trusted and opts.untrusted: parser.error('--trusted and --untrusted cannot be combined') if not any((opts.generate, opts.revoke)): parser.error('specify --generate or --revoke') display = Display() if not display.has_extension('SECURITY'): if display.query_extension('SECURITY') is None: print('SECURITY extension not supported', file=sys.stderr) return 1 security_version = display.security_query_version() print('SECURITY version %s.%s' % ( security_version.major_version, security_version.minor_version, ), file=sys.stderr) if opts.generate: kwargs = {} if opts.trusted: kwargs['trust_level'] = security.SecurityClientTrusted elif opts.untrusted: kwargs['trust_level'] = security.SecurityClientUntrusted reply = display.security_generate_authorization(opts.proto, **kwargs) print(reply.authid) elif opts.revoke: for arg in args: authid = int(arg, 10) display.security_revoke_authorization(authid) if __name__ == '__main__': sys.exit(main(sys.argv)) python-xlib-0.33/examples/shapewin.py000077500000000000000000000155031435211557500177410ustar00rootroot00000000000000#!/usr/bin/python # # examples/shapewin.py -- demonstrate shape extension # # Copyright (C) 2002 Peter Liljenberg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys import os # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import X, display, Xutil from Xlib.ext import shape # Application window (only one) class Window(object): def __init__(self, display): self.d = display # Check for extension if not self.d.has_extension('SHAPE'): sys.stderr.write('%s: server does not have SHAPE extension\n' % sys.argv[1]) sys.exit(1) # print(version) r = self.d.shape_query_version() print('SHAPE version %d.%d' % (r.major_version, r.minor_version)) # Find which screen to open the window on self.screen = self.d.screen() # background pattern bgsize = 20 bgpm = self.screen.root.create_pixmap(bgsize, bgsize, self.screen.root_depth) bggc = self.screen.root.create_gc(foreground = self.screen.black_pixel, background = self.screen.black_pixel) bgpm.fill_rectangle(bggc, 0, 0, bgsize, bgsize) bggc.change(foreground = self.screen.white_pixel) bgpm.arc(bggc, -bgsize // 2, 0, bgsize, bgsize, 0, 360 * 64) bgpm.arc(bggc, bgsize // 2, 0, bgsize, bgsize, 0, 360 * 64) bgpm.arc(bggc, 0, -bgsize // 2, bgsize, bgsize, 0, 360 * 64) bgpm.arc(bggc, 0, bgsize // 2, bgsize, bgsize, 0, 360 * 64) # Actual window self.window = self.screen.root.create_window( 100, 100, 400, 300, 0, self.screen.root_depth, X.InputOutput, X.CopyFromParent, # special attribute values background_pixmap = bgpm, event_mask = (X.StructureNotifyMask | X.ButtonPressMask | X.ButtonReleaseMask), colormap = X.CopyFromParent, ) # Set some WM info self.WM_DELETE_WINDOW = self.d.intern_atom('WM_DELETE_WINDOW') self.WM_PROTOCOLS = self.d.intern_atom('WM_PROTOCOLS') self.window.set_wm_name('Xlib example: shapewin.py') self.window.set_wm_icon_name('shapewin.py') self.window.set_wm_class('shapewin', 'XlibExample') self.window.set_wm_protocols([self.WM_DELETE_WINDOW]) self.window.set_wm_hints(flags = Xutil.StateHint, initial_state = Xutil.NormalState) self.window.set_wm_normal_hints(flags = (Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), min_width = 50, min_height = 50) # The add and subtract shapes self.add_size = 60 self.add_pm = self.window.create_pixmap(self.add_size, self.add_size, 1) gc = self.add_pm.create_gc(foreground = 0, background = 0) self.add_pm.fill_rectangle(gc, 0, 0, self.add_size, self.add_size) gc.change(foreground = 1) self.add_pm.fill_arc(gc, 0, 0, self.add_size, self.add_size, 0, 360 * 64) gc.free() self.sub_size = 59 self.sub_pm = self.window.create_pixmap(self.sub_size, self.sub_size, 1) gc = self.sub_pm.create_gc(foreground = 0, background = 0) self.sub_pm.fill_rectangle(gc, 0, 0, self.sub_size, self.sub_size) gc.change(foreground = 1) self.sub_pm.fill_poly(gc, X.Convex, X.CoordModeOrigin, [(self.sub_size // 2, 0), (self.sub_size, self.sub_size // 2), (self.sub_size // 2, self.sub_size), (0, self.sub_size // 2)]) gc.free() # Set initial mask self.window.shape_mask(shape.SO.Set, shape.SK.Bounding, 0, 0, self.add_pm) self.window.shape_mask(shape.SO.Union, shape.SK.Bounding, 400 - self.add_size, 0, self.add_pm) self.window.shape_mask(shape.SO.Union, shape.SK.Bounding, 0, 300 - self.add_size, self.add_pm) self.window.shape_mask(shape.SO.Union, shape.SK.Bounding, 400 - self.add_size, 300 - self.add_size, self.add_pm) # Tell X server to send us mask events self.window.shape_select_input(1) # Map the window, making it visible self.window.map() # Main loop, handling events def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Button released, add or subtract elif e.type == X.ButtonRelease: if e.detail == 1: self.window.shape_mask(shape.SO.Union, shape.SK.Bounding, e.event_x - self.add_size // 2, e.event_y - self.add_size // 2, self.add_pm) elif e.detail == 3: self.window.shape_mask(shape.SO.Subtract, shape.SK.Bounding, e.event_x - self.sub_size // 2, e.event_y - self.sub_size // 2, self.sub_pm) # Shape has changed elif e.type == self.d.extension_event.ShapeNotify: print('Shape change') # Somebody wants to tell us something elif e.type == X.ClientMessage: if e.client_type == self.WM_PROTOCOLS: fmt, data = e.data if fmt == 32 and data[0] == self.WM_DELETE_WINDOW: sys.exit(0) if __name__ == '__main__': Window(display.Display()).loop() python-xlib-0.33/examples/threadtest.py000077500000000000000000000030321435211557500202640ustar00rootroot00000000000000#!/usr/bin/python # Python 2/3 compatibility. from __future__ import print_function import sys import os # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import display, X, threaded import time import thread def redraw(win, gc): # win.clear_area() win.fill_rectangle(gc, 20, 20, 60, 60) def blink(display, win, gc, cols): while 1: time.sleep(2) print('Changing color', cols[0]) gc.change(foreground = cols[0]) cols = (cols[1], cols[0]) redraw(win, gc) display.flush() def main(): d = display.Display() root = d.screen().root colormap = d.screen().default_colormap red = colormap.alloc_named_color("red").pixel blue = colormap.alloc_named_color("blue").pixel background = colormap.alloc_named_color("white").pixel window = root.create_window(100, 100, 100, 100, 1, X.CopyFromParent, X.InputOutput, X.CopyFromParent, background_pixel = background, event_mask = X.StructureNotifyMask | X.ExposureMask) window.map() gc = window.create_gc(foreground = red) thread.start_new_thread(blink, (d, window, gc, (blue, red))) while 1: event = d.next_event() if event.type == X.Expose: if event.count == 0: redraw(window, gc) elif event.type == X.DestroyNotify: sys.exit(0) if __name__ == "__main__": main() python-xlib-0.33/examples/xdamage.py000066400000000000000000000110361435211557500175230ustar00rootroot00000000000000#!/usr/bin/python # # examples/xdamage.py -- demonstrate damage extension # # Copyright (C) 2019 Mohit Garg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys import os # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import display, X, threaded,Xutil import time try: import thread except ModuleNotFoundError: import _thread as thread from Xlib.ext import damage from PIL import Image, ImageTk import traceback def redraw(win, gc): # win.clear_area() win.fill_rectangle(gc, 0, 0, 60, 60) def blink(display, win, gc, cols): while 1: time.sleep(2) print('Changing color', cols[0]) gc.change(foreground = cols[0]) cols = (cols[1], cols[0]) redraw(win, gc) display.flush() def get_image_from_win(win, pt_w, pt_h, pt_x=0, pt_y=0): try: raw = win.get_image(pt_x, pt_y, pt_w, pt_h, X.ZPixmap, 0xffffffff) image = Image.frombytes("RGB", (pt_w, pt_h), raw.data, "raw", "BGRX") return image except Exception: traceback.print_exc() def check_ext(disp): # Check for extension if not disp.has_extension('DAMAGE'): sys.stderr.write('server does not have the DAMAGE extension\n') sys.stderr.write("\n".join(disp.list_extensions())) if disp.query_extension('DAMAGE') is None: sys.exit(1) else: r = disp.damage_query_version() print('DAMAGE version {}.{}'.format(r.major_version, r.minor_version)) def main(): d = display.Display() root = d.screen().root check_ext(d) colormap = d.screen().default_colormap red = colormap.alloc_named_color("red").pixel blue = colormap.alloc_named_color("blue").pixel background = colormap.alloc_named_color("white").pixel window1 = root.create_window(100, 100, 250, 100, 1, X.CopyFromParent, X.InputOutput, X.CopyFromParent, background_pixel = background, event_mask = X.StructureNotifyMask | X.ExposureMask) window1.set_wm_name('Changing Window') window1.map() gc = window1.create_gc(foreground = red) thread.start_new_thread(blink, (d, window1, gc, (blue, red))) window1.damage_create(damage.DamageReportRawRectangles) window1.set_wm_normal_hints( flags=(Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), min_width=50, min_height=50 ) window2 = root.create_window(100, 250, 250, 100, 1, X.CopyFromParent, X.InputOutput, X.CopyFromParent, background_pixel = background, event_mask = X.StructureNotifyMask | X.ExposureMask) window2.set_wm_normal_hints( flags=(Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), min_width=50, min_height=50 ) window2.set_wm_name('Tracking Window') window2.map() while 1: event = d.next_event() if event.type == X.Expose: if event.count == 0: redraw(window1, gc) elif event.type == d.extension_event.DamageNotify: image = get_image_from_win(window1, event.area.width, event.area.height, event.area.x, event.area.y) bgpm = window2.create_pixmap(image.width, image.height, d.screen().root_depth) bggc = window2.create_gc(foreground=0, background=0) bgpm.put_pil_image(bggc, 0, 0, image) window2.copy_area(bggc, bgpm, 0, 0, image.width, image.height, 0, 0) # bggc.free() elif event.type == X.DestroyNotify: sys.exit(0) if __name__ == "__main__": main() python-xlib-0.33/examples/xfixes-cursor-notify.py000077500000000000000000000045051435211557500222520ustar00rootroot00000000000000#!/usr/bin/python3 # # examples/xfixes-cursor-notify.py -- demonstrate the XFIXES extension # CursorNotify event. # # Copyright (C) 2022 # Dan Isla # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys from Xlib.display import Display from Xlib.ext import xfixes def main(): display = Display() if not display.has_extension('XFIXES'): if display.query_extension('XFIXES') is None: print('XFIXES extension not supported') return 1 xfixes_version = display.xfixes_query_version() print('Found XFIXES version {}.{}'.format( xfixes_version.major_version, xfixes_version.minor_version )) screen = display.screen() display.xfixes_select_cursor_input(screen.root, xfixes.XFixesDisplayCursorNotifyMask) cursor_cache = {} while True: e = display.next_event() print(e) if (e.type, e.sub_code) == display.extension_event.DisplayCursorNotify: print("DisplayCursorNotify: cursor_serial={}".format(e.cursor_serial)) image = display.xfixes_get_cursor_image(screen.root) cached = False if cursor_cache.get(image.cursor_serial): cached = True else: cursor_cache[image.cursor_serial] = image.cursor_image print("Cursor position={},{}, size={}x{}, xyhot={},{}, cursor_serial={}, cached={}".format( image.x, image.y, image.width,image.height, image.xhot, image.yhot, image.cursor_serial, cached )) if __name__ == "__main__": sys.exit(main()) python-xlib-0.33/examples/xfixes-selection-notify.py000077500000000000000000000053141435211557500227210ustar00rootroot00000000000000#!/usr/bin/python3 # # examples/xfixes-selection-notify.py -- demonstrate the XFIXES extension # SelectionNotify event. # # Copyright (C) 2019 # Tony Crisci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys import os import time # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib.display import Display from Xlib.ext import xfixes def main(argv): if len(sys.argv) != 2: sys.exit('usage: {0} SELECTION\n\n' 'SELECTION is typically PRIMARY, SECONDARY or CLIPBOARD.\n' .format(sys.argv[0])) display = Display() sel_name = sys.argv[1] sel_atom = display.get_atom(sel_name) if not display.has_extension('XFIXES'): if display.query_extension('XFIXES') is None: print('XFIXES extension not supported', file=sys.stderr) return 1 xfixes_version = display.xfixes_query_version() print('Found XFIXES version %s.%s' % ( xfixes_version.major_version, xfixes_version.minor_version, ), file=sys.stderr) screen = display.screen() mask = xfixes.XFixesSetSelectionOwnerNotifyMask | \ xfixes.XFixesSelectionWindowDestroyNotifyMask | \ xfixes.XFixesSelectionClientCloseNotifyMask display.xfixes_select_selection_input(screen.root, sel_atom, mask) while True: e = display.next_event() print(e) if (e.type, e.sub_code) == display.extension_event.SetSelectionOwnerNotify: print('SetSelectionOwner: owner=0x{0:08x}'.format(e.owner.id)) elif (e.type, e.sub_code) == display.extension_event.SelectionWindowDestroyNotify: print('SelectionWindowDestroy: owner=0x{0:08x}'.format(e.owner.id)) elif (e.type, e.sub_code) == display.extension_event.SelectionClientCloseNotify: print('SelectionClientClose: owner=0x{0:08x}'.format(e.owner.id)) if __name__ == '__main__': sys.exit(main(sys.argv)) python-xlib-0.33/examples/xfixes.py000077500000000000000000000035361435211557500174340ustar00rootroot00000000000000#!/usr/bin/python # # examples/xfixes.py -- demonstrate the XFIXES extension # # Copyright (C) 2011 Outpost Embedded, LLC # Forest Bond # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys import os import time # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib.display import Display def main(argv): display = Display() if not display.has_extension('XFIXES'): if display.query_extension('XFIXES') is None: print('XFIXES extension not supported', file=sys.stderr) return 1 xfixes_version = display.xfixes_query_version() print('Found XFIXES version %s.%s' % ( xfixes_version.major_version, xfixes_version.minor_version, ), file=sys.stderr) screen = display.screen() print('Hiding cursor ...', file=sys.stderr) screen.root.xfixes_hide_cursor() display.sync() time.sleep(5) print('Showing cursor ...', file=sys.stderr) screen.root.xfixes_show_cursor() display.sync() if __name__ == '__main__': sys.exit(main(sys.argv)) python-xlib-0.33/examples/xinerama.py000077500000000000000000000121271435211557500177260ustar00rootroot00000000000000#!/usr/bin/python # # examples/xinerama.py -- demonstrate the Xinerama extension # # Copyright (C) 2009 David H. Bronke # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys import os import pprint # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import X, display, Xutil from Xlib.ext import xinerama # Application window (only one) class Window(object): def __init__(self, display): self.d = display # Check for extension if not self.d.has_extension('XINERAMA'): sys.stderr.write('{}: server does not have the XINERAMA extension\n'.format(sys.argv[0])) ext = self.d.query_extension('XINERAMA') print(ext) sys.stderr.write("\n".join(self.d.list_extensions())) if ext is None: sys.exit(1) # print version r = self.d.xinerama_query_version() print('XINERAMA version %d.%d' % (r.major_version, r.minor_version)) # Grab the current screen self.screen = self.d.screen() self.window = self.screen.root.create_window( 50, 50, 300, 200, 2, self.screen.root_depth, X.InputOutput, X.CopyFromParent, # special attribute values background_pixel = self.screen.white_pixel, event_mask = (X.ExposureMask | X.StructureNotifyMask | X.ButtonPressMask | X.ButtonReleaseMask | X.Button1MotionMask), colormap = X.CopyFromParent, ) self.gc = self.window.create_gc( foreground = self.screen.black_pixel, background = self.screen.white_pixel, ) # Set some WM info self.WM_DELETE_WINDOW = self.d.intern_atom('WM_DELETE_WINDOW') self.WM_PROTOCOLS = self.d.intern_atom('WM_PROTOCOLS') self.window.set_wm_name('Xlib example: xinerama.py') self.window.set_wm_icon_name('xinerama.py') self.window.set_wm_class('xinerama', 'XlibExample') self.window.set_wm_protocols([self.WM_DELETE_WINDOW]) self.window.set_wm_hints(flags = Xutil.StateHint, initial_state = Xutil.NormalState) self.window.set_wm_normal_hints(flags = (Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), min_width = 20, min_height = 20) # Map the window, making it visible self.window.map() self.pp = pprint.PrettyPrinter(indent=4) print("Xinerama active:", bool(self.d.xinerama_is_active())) print("Screen info:") self.pp.pprint(self.d.xinerama_query_screens()._data) # FIXME: This doesn't work! #print("Xinerama info:") #self.pp.pprint(self.d.xinerama_get_info(self.d.screen().root_visual)._data) print("Xinerama state:") self.pp.pprint(self.window.xinerama_get_state()._data) print("Screen count:") self.pp.pprint(self.window.xinerama_get_screen_count()._data) for screennum in range(self.window.xinerama_get_screen_count().screen_count): print("Screen %d size:" % (screennum, )) self.pp.pprint(self.window.xinerama_get_screen_size(screennum)._data) def parseModes(self, mode_names, modes): lastIdx = 0 modedatas = dict() for mode in modes: modedata = dict(mode._data) modedata['name'] = mode_names[lastIdx:lastIdx + modedata['name_length']] modedatas[modedata['id']] = modedata lastIdx += modedata['name_length'] return modedatas # Main loop, handling events def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Somebody wants to tell us something elif e.type == X.ClientMessage: if e.client_type == self.WM_PROTOCOLS: fmt, data = e.data if fmt == 32 and data[0] == self.WM_DELETE_WINDOW: sys.exit(0) if __name__ == '__main__': Window(display.Display()).loop() python-xlib-0.33/examples/xinput.py000077500000000000000000000047571435211557500174630ustar00rootroot00000000000000#!/usr/bin/python # # examples/xinput.py -- demonstrate the XInput extension # # Copyright (C) 2012 Outpost Embedded, LLC # Forest Bond # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys import os # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib.display import Display from Xlib.ext import xinput def print_hierarchy_changed_event(event): print('') def print_info(info): print(' ' % ( info.deviceid, info.attachment, info.type, info.enabled, info.flags, )) def main(argv): display = Display() try: extension_info = display.query_extension('XInputExtension') xinput_major = extension_info.major_opcode version_info = display.xinput_query_version() print('Found XInput version %u.%u' % ( version_info.major_version, version_info.minor_version, )) screen = display.screen() screen.root.xinput_select_events([ (xinput.AllDevices, xinput.HierarchyChangedMask), ]) while True: event = display.next_event() if ( event.type == display.extension_event.GenericEvent and event.extension == xinput_major and event.evtype == 11 ): print_hierarchy_changed_event(event) finally: display.close() if __name__ == '__main__': sys.exit(main(sys.argv)) python-xlib-0.33/examples/xlsatoms.py000077500000000000000000000074751435211557500200060ustar00rootroot00000000000000#!/usr/bin/python # Copyright (C) 2011 Arun Balasubramanian # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA ''' xlsatoms - list atoms on X server (see man xlsatoms) sample program using python Xlib that mimics the standard xlsatoms utility additional capability is to match against regular expressions for atoms ''' # Python 2/3 compatibility. from __future__ import print_function import sys import os # Python 2/3 compatibility. from six import PY2, MAXSIZE # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import re from Xlib import display, error from optparse import OptionParser if PY2: integer_type = long else: integer_type = int parser = OptionParser() parser.add_option("-d","--display",dest="display",help="This option specifies the X server to which to connect",metavar="dpy",default=None) parser.add_option("-n","--name",dest="name",help="This option specifies the name of an atom to list. If the atom does not exist, a message will be printed on the standard error.",metavar="string",default=None) parser.add_option("-m","--match",dest="match_re",help="This option specifies a regular expression to match against name of an atom to list. If the atom does not exist, a message will be printed on the standard error.",metavar="reg-exp",default=None) parser.add_option("-f","--format",dest="format",help="This option specifies a printf-style string used to list each atom pair, printed in that order (value is an unsigned long and name is a char *). Xlsatoms will supply a newline at the end of each line. The default is %ld\\t%s.",metavar="string",default="%ld\t%s") parser.add_option("-r","--range",dest="range",help="This option specifies the range of atom values to check. If low is not given, a value of 1 assumed. If high is not given, xlsatoms will stop at the first undefined atom at or above low.",metavar="[low]-[high]",default="1-") (options, args) = parser.parse_args() low = 1 high = 1 ec = error.CatchError(error.BadAtom) d = display.Display(options.display) def print_atom(print_format,atom,value): print(print_format%(atom,value)) def list_atoms(d,re_obj,low,high): while(low <= high): try: val = d.get_atom_name(low) if (re_obj == None) : print_atom(options.format,low,val) elif re_obj.match(val) != None: print_atom(options.format,low,val) low += 1 except: sys.exit(0) if options.name != None: try: atom = d.intern_atom(options.name) val = d.get_atom_name(atom) print_atom(options.format,atom,val) except: sys.stderr.write('xlsatoms: no atom named "%s" on server "%s"'%(options.name,options.display)) sys.stderr.write("\n") sys.exit(1) sys.exit(0) rangeVals = options.range.split("-") if rangeVals[0] != "": low = integer_type(rangeVals[0]) if rangeVals[1] != "": high = integer_type(rangeVals[1]) else: high = MAXSIZE if options.match_re != None: re_obj = re.compile(options.match_re) else: re_obj = None list_atoms(d,re_obj,low,high) python-xlib-0.33/examples/xrandr.py000077500000000000000000000160661435211557500174260ustar00rootroot00000000000000#!/usr/bin/python # # examples/xrandr.py -- demonstrate the RandR extension # # Copyright (C) 2009 David H. Bronke # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function import sys import os import pprint # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import X, display, Xutil from Xlib.ext import randr # Application window (only one) class Window(object): def __init__(self, display): self.d = display # Check for extension if not self.d.has_extension('RANDR'): sys.stderr.write('{}: server does not have the RANDR extension\n'.format(sys.argv[0])) ext = self.d.query_extension('RANDR') print(ext) sys.stderr.write("\n".join(self.d.list_extensions())) if ext is None: sys.exit(1) # print(version) r = self.d.xrandr_query_version() print('RANDR version %d.%d' % (r.major_version, r.minor_version)) # Grab the current screen self.screen = self.d.screen() self.window = self.screen.root.create_window( 50, 50, 300, 200, 2, self.screen.root_depth, X.InputOutput, X.CopyFromParent, # special attribute values background_pixel = self.screen.white_pixel, event_mask = (X.ExposureMask | X.StructureNotifyMask | X.ButtonPressMask | X.ButtonReleaseMask | X.Button1MotionMask), colormap = X.CopyFromParent, ) self.gc = self.window.create_gc( foreground = self.screen.black_pixel, background = self.screen.white_pixel, ) # Set some WM info self.WM_DELETE_WINDOW = self.d.intern_atom('WM_DELETE_WINDOW') self.WM_PROTOCOLS = self.d.intern_atom('WM_PROTOCOLS') self.window.set_wm_name('Xlib example: xrandr.py') self.window.set_wm_icon_name('xrandr.py') self.window.set_wm_class('xrandr', 'XlibExample') self.window.set_wm_protocols([self.WM_DELETE_WINDOW]) self.window.set_wm_hints(flags = Xutil.StateHint, initial_state = Xutil.NormalState) self.window.set_wm_normal_hints(flags = (Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), min_width = 20, min_height = 20) # Map the window, making it visible self.window.map() # Enable all RandR events. self.window.xrandr_select_input( randr.RRScreenChangeNotifyMask | randr.RRCrtcChangeNotifyMask | randr.RROutputChangeNotifyMask | randr.RROutputPropertyNotifyMask ) self.pp = pprint.PrettyPrinter(indent=4) print("Screen info:") self.pp.pprint(self.window.xrandr_get_screen_info()._data) print("Screen size range:") self.pp.pprint(self.window.xrandr_get_screen_size_range()._data) print("Primary output:") self.pp.pprint(self.window.xrandr_get_output_primary()._data) resources = self.window.xrandr_get_screen_resources()._data print("Modes:") for mode_id, mode in self.parseModes(resources['mode_names'], resources['modes']).items(): print(" %d: %s" % (mode_id, mode['name'])) for output in resources['outputs']: print("Output %d info:" % (output, )) self.pp.pprint(self.d.xrandr_get_output_info(output, resources['config_timestamp'])._data) for crtc in resources['crtcs']: print("CRTC %d info:" % (crtc, )) self.pp.pprint(self.d.xrandr_get_crtc_info(crtc, resources['config_timestamp'])._data) print("Raw screen resources:") self.pp.pprint(resources) def parseModes(self, mode_names, modes): lastIdx = 0 modedatas = dict() for mode in modes: modedata = dict(mode._data) modedata['name'] = mode_names[lastIdx:lastIdx + modedata['name_length']] modedatas[modedata['id']] = modedata lastIdx += modedata['name_length'] return modedatas # Main loop, handling events def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Screen information has changed elif e.__class__.__name__ == randr.ScreenChangeNotify.__name__: print('Screen change') print(self.pp.pprint(e._data)) # check if we're getting one of the RandR event types with subcodes elif e.type == self.d.extension_event.CrtcChangeNotify[0]: # yes, check the subcodes # CRTC information has changed if (e.type, e.sub_code) == self.d.extension_event.CrtcChangeNotify: print('CRTC change') #e = randr.CrtcChangeNotify(display=display.display, binarydata = e._binary) print(self.pp.pprint(e._data)) # Output information has changed elif (e.type, e.sub_code) == self.d.extension_event.OutputChangeNotify: print('Output change') #e = randr.OutputChangeNotify(display=display.display, binarydata = e._binary) print(self.pp.pprint(e._data)) # Output property information has changed elif (e.type, e.sub_code) == self.d.extension_event.OutputPropertyNotify: print('Output property change') #e = randr.OutputPropertyNotify(display=display.display, binarydata = e._binary) print(self.pp.pprint(e._data)) else: print("Unrecognised subcode", e.sub_code) # Somebody wants to tell us something elif e.type == X.ClientMessage: if e.client_type == self.WM_PROTOCOLS: fmt, data = e.data if fmt == 32 and data[0] == self.WM_DELETE_WINDOW: sys.exit(0) if __name__ == '__main__': Window(display.Display()).loop() python-xlib-0.33/examples/xres.py000077500000000000000000000053051435211557500171030ustar00rootroot00000000000000#!/usr/bin/python # # examples/xres.py -- demonstrate the X-Resource extension # # Copyright (C) 2021 Aleksei Bavshin # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 # of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., # 51 Franklin Street, # Fifth Floor, # Boston, MA 02110-1301 USA import os import sys # Change path so we find Xlib sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) from Xlib.display import Display from Xlib.ext import res as XRes def check_ext(disp, extname, version): if disp.query_extension(extname) is None: raise AssertionError("Server has {} extension".format(extname)) r = disp.res_query_version() if (r.server_major, r.server_minor) < version: raise AssertionError( "Server has requested version {} of {} extension".format(version, extname) ) def query_client_id(display, wid): specs = [{"client": wid, "mask": XRes.LocalClientPIDMask}] r = display.res_query_client_ids(specs) for id in r.ids: if id.spec.client > 0 and id.spec.mask == XRes.LocalClientPIDMask: for value in id.value: return value return None def print_client_info(disp, client): print("client: {}".format(client)) resources = disp.res_query_client_resources(client) rc = [r.count for r in resources.types] print("\tresouces: {} resources of {} types".format(sum(rc), len(rc))) pb = disp.res_query_client_pixmap_bytes(client) print("\tpixmaps: {} bytes {} overflow".format(pb.bytes, pb.bytes_overflow)) pid = query_client_id(disp, client) print("\tpid: {}".format(pid)) rb = disp.res_query_resource_bytes(client, [{"resource": 0, "type": 0}]) sizes = [s.size.bytes for s in rb.sizes] print("\t{} resources consume {} bytes".format(len(sizes), sum(sizes))) def main(): display = Display() check_ext(display, XRes.extname, (1, 2)) clients = display.res_query_clients().clients print("{} clients connected to the server".format(len(clients))) for client in clients: print_client_info(display, client.resource_base) if __name__ == "__main__": main() python-xlib-0.33/requirements.txt000066400000000000000000000000141435211557500172030ustar00rootroot00000000000000six>=1.10.0 python-xlib-0.33/runtests.py000077500000000000000000000070531435211557500161750ustar00rootroot00000000000000#!/usr/bin/env python # Python 2/3 compatibility. from __future__ import print_function import os import signal import subprocess import sys import tempfile import textwrap from pkg_resources import load_entry_point class SigException(BaseException): def __init__(self, signum): super(SigException, self).__init__() self.signum = signum def xsession_sighandler(signum, frame): raise SigException(signum) def xserver_start(display, executable='Xvfb', authfile=None): pid = os.fork() if pid != 0: return pid if authfile is None: authfile = os.devnull # This will make the xserver send us a SIGUSR1 when ready. signal.signal(signal.SIGUSR1, signal.SIG_IGN) cmd = [ executable, '-auth', authfile, '-noreset', display, ] print('starting xserver: `{0}`'.format(' '.join(cmd))) os.execlp(cmd[0], *cmd) def tests_run(display, authfile=None): pid = os.fork() if pid != 0: return pid if authfile is None: authfile = os.devnull os.environ['DISPLAY'] = display os.environ['XAUTHORITY'] = authfile cmd = [ sys.executable, '-c', textwrap.dedent( ''' from pkg_resources import load_entry_point sys.exit(load_entry_point( 'nose', 'console_scripts', 'nosetests', )()) ''' ).lstrip(), '--exe', '--with-xunit', '--verbosity=3', ] has_custom_tests = False for arg in sys.argv[1:]: if not arg.startswith('-'): has_custom_tests = True cmd.append(arg) if not has_custom_tests: cmd.extend(('test/', 'examples/run_examples.py')) print('running tests: `{0}`'.format(' '.join(cmd))) sys.argv = cmd try: load_entry_point('nose', 'console_scripts', 'nosetests')() except SystemExit as err: code = err.code else: code = 0 os._exit(code) def runtests(): cleanup_funcs = [] try: if hasattr(sys, 'pypy_version_info'): server_display = ':8' else: server_display = ':9' server_display += ''.join(str(n) for n in sys.version_info[:3]) # Setup a temporary authentication file. cookie = subprocess.check_output('mcookie').strip() authfile = tempfile.NamedTemporaryFile(delete=False) cleanup_funcs.append(lambda: os.unlink(authfile.name)) authfile.close() subprocess.check_call(( 'xauth', '-f', authfile.name, 'add', server_display, '.', cookie, )) # Setup signal handler to wait for xserver to be ready. signal.signal(signal.SIGUSR1, xsession_sighandler) # Start xserver. server_pid = xserver_start(server_display, authfile=authfile.name) cleanup_funcs.append(lambda: os.waitpid(server_pid, 0)) cleanup_funcs.append(lambda: os.kill(server_pid, signal.SIGTERM)) # Give the server 3 seconds to start. signal.alarm(3) # Wait for server to be ready. try: signal.pause() except SigException as err: assert signal.SIGUSR1 == err.signum signal.alarm(0) # Run tests. tests_pid = tests_run(server_display, authfile=authfile.name) pid, status = os.waitpid(tests_pid, 0) assert pid == tests_pid sys.exit(status >> 8) except KeyboardInterrupt: sys.exit(1) finally: for func in reversed(cleanup_funcs): func() if __name__ == '__main__': runtests() python-xlib-0.33/setup.cfg000066400000000000000000000023031435211557500155430ustar00rootroot00000000000000[metadata] name = python-xlib version = attr: Xlib.__version_string__ description = Python X Library long_description = file: README.rst download_url = https://github.com/python-xlib/python-xlib/releases url = https://github.com/python-xlib/python-xlib license = LGPLv2+ author = Peter Liljenberg author_email = petli@ctrl-c.liu.se keywords = windows x x11 xlib classifiers = Development Status :: 5 - Production/Stable Environment :: X11 Applications Intended Audience :: Developers License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+) Operating System :: OS Independent Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 Programming Language :: Python :: 3.3 Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: Implementation :: CPython Topic :: Software Development :: Libraries :: Python Modules Topic :: Software Development :: Libraries Topic :: Software Development :: User Interfaces [bdist_wheel] universal = 1 # vim: list python-xlib-0.33/setup.py000066400000000000000000000011461435211557500154400ustar00rootroot00000000000000# Distutils script for python-xlib from pkg_resources import parse_requirements from setuptools import (__version__ as setuptools_version, setup) # Check setuptools is recent enough to support `setup.cfg`. setuptools_require = next(parse_requirements('setuptools>=30.3.0')) assert setuptools_version in setuptools_require, '{} is required'.format(setuptools_require) setup( install_requires=['six>=1.10.0'], setup_requires=['setuptools-scm'], packages=[ 'Xlib', 'Xlib.ext', 'Xlib.keysymdef', 'Xlib.protocol', 'Xlib.support', 'Xlib.xobject' ], ) python-xlib-0.33/test.sh000077500000000000000000000002341435211557500152410ustar00rootroot00000000000000#!/bin/bash (shopt -s globstar; for s in */**.py; do timeout 1 python2 -3 "$s"; done) 2> error.log > /dev/null grep -i failed error.log && exit 1 || exit 0 python-xlib-0.33/test/000077500000000000000000000000001435211557500147035ustar00rootroot00000000000000python-xlib-0.33/test/__init__.py000066400000000000000000000035061435211557500170200ustar00rootroot00000000000000 import unittest import binascii import difflib import struct import array import Xlib.protocol.event import Xlib.protocol.rq class CmpArray(object): def __init__(self, *args, **kws): self.array = array.array(*args, **kws) def __len__(self): return len(self.array) def __getitem__(self, key): if isinstance(key, slice): x = key.start y = key.stop return list(self.array[x:y]) else: return self.array[key] def __getattr__(self, attr): return getattr(self.array, attr) def __eq__(self, other): return self.array.tolist() == other Xlib.protocol.rq.array = CmpArray class DummyDisplay(object): def get_resource_class(self, x): return None event_classes = Xlib.protocol.event.event_class class TestCase(unittest.TestCase): def assertBinaryEqual(self, bin1, bin2): if bin1 != bin2: self.fail('binary contents differ:\n' + bindiff(bin1, bin2)) def assertBinaryEmpty(self, bin): if len(bin) != 0: self.fail('binary content not empty:\n' + ''.join(tohex(bin))) class BigEndianTest(TestCase): @classmethod def setUpClass(cls): if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 1: raise unittest.SkipTest('big-endian tests, skipping on this system') class LittleEndianTest(TestCase): @classmethod def setUpClass(cls): if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 0: raise unittest.SkipTest('little-endian tests, skipping on this system') def tohex(bin): hex = [] for i in range(0, len(bin), 16): hex.append(str(binascii.hexlify(bin[i:i+16])) + '\n') return hex def bindiff(bin1, bin2): hex1 = tohex(bin1) hex2 = tohex(bin2) return ''.join(difflib.ndiff(hex1, hex2)) python-xlib-0.33/test/gen/000077500000000000000000000000001435211557500154545ustar00rootroot00000000000000python-xlib-0.33/test/gen/.gitignore000066400000000000000000000000601435211557500174400ustar00rootroot00000000000000/genevent /genevent.c /genrequest /genrequest.c python-xlib-0.33/test/gen/eventdef000066400000000000000000000121241435211557500171770ustar00rootroot00000000000000EVENT KeyButtonPointer BYTE:u.u.type BYTE:u.u.detail CARD16:u.u.sequenceNumber CARD32:u.keyButtonPointer.time CARD32:u.keyButtonPointer.root CARD32:u.keyButtonPointer.event CARD32:u.keyButtonPointer.child INT16:u.keyButtonPointer.rootX INT16:u.keyButtonPointer.rootY INT16:u.keyButtonPointer.eventX INT16:u.keyButtonPointer.eventY CARD16:u.keyButtonPointer.state BOOL:u.keyButtonPointer.sameScreen EVENT EnterLeave BYTE:u.u.type BYTE:u.u.detail CARD16:u.u.sequenceNumber CARD32:u.enterLeave.time CARD32:u.enterLeave.root CARD32:u.enterLeave.event CARD32:u.enterLeave.child INT16:u.enterLeave.rootX INT16:u.enterLeave.rootY INT16:u.enterLeave.eventX INT16:u.enterLeave.eventY CARD16:u.enterLeave.state BYTE:u.enterLeave.mode BYTE:u.enterLeave.flags EVENT Focus BYTE:u.u.type BYTE:u.u.detail CARD16:u.u.sequenceNumber CARD32:u.focus.window BYTE:u.focus.mode EVENT Expose BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.expose.window CARD16:u.expose.x CARD16:u.expose.y CARD16:u.expose.width CARD16:u.expose.height CARD16:u.expose.count EVENT GraphicsExpose BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.graphicsExposure.drawable CARD16:u.graphicsExposure.x CARD16:u.graphicsExposure.y CARD16:u.graphicsExposure.width CARD16:u.graphicsExposure.height CARD16:u.graphicsExposure.minorEvent CARD16:u.graphicsExposure.count BYTE:u.graphicsExposure.majorEvent EVENT NoExpose BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.noExposure.drawable CARD16:u.noExposure.minorEvent BYTE:u.noExposure.majorEvent EVENT VisibilityNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.visibility.window CARD8:u.visibility.state EVENT CreateNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.createNotify.parent CARD32:u.createNotify.window INT16:u.createNotify.x INT16:u.createNotify.y CARD16:u.createNotify.width CARD16:u.createNotify.height CARD16:u.createNotify.borderWidth BOOL:u.createNotify.override EVENT DestroyNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.destroyNotify.event CARD32:u.destroyNotify.window EVENT UnmapNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.unmapNotify.event CARD32:u.unmapNotify.window BOOL:u.unmapNotify.fromConfigure EVENT MapNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.mapNotify.event CARD32:u.mapNotify.window BOOL:u.mapNotify.override EVENT MapRequest BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.mapRequest.parent CARD32:u.mapRequest.window EVENT ReparentNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.reparent.event CARD32:u.reparent.window CARD32:u.reparent.parent INT16:u.reparent.x INT16:u.reparent.y BOOL:u.reparent.override EVENT ConfigureNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.configureNotify.event CARD32:u.configureNotify.window CARD32:u.configureNotify.aboveSibling INT16:u.configureNotify.x INT16:u.configureNotify.y CARD16:u.configureNotify.width CARD16:u.configureNotify.height CARD16:u.configureNotify.borderWidth BOOL:u.configureNotify.override EVENT ConfigureRequest BYTE:u.u.type BYTE:u.u.detail CARD16:u.u.sequenceNumber CARD32:u.configureRequest.parent CARD32:u.configureRequest.window CARD32:u.configureRequest.sibling INT16:u.configureRequest.x INT16:u.configureRequest.y CARD16:u.configureRequest.width CARD16:u.configureRequest.height CARD16:u.configureRequest.borderWidth CARD16:u.configureRequest.valueMask EVENT GravityNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.gravity.event CARD32:u.gravity.window INT16:u.gravity.x INT16:u.gravity.y EVENT ResizeRequest BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.resizeRequest.window CARD16:u.resizeRequest.width CARD16:u.resizeRequest.height EVENT Circulate BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.circulate.event CARD32:u.circulate.window CARD32:u.circulate.parent BYTE:u.circulate.place EVENT PropertyNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.property.window CARD32:u.property.atom CARD32:u.property.time BYTE:u.property.state EVENT SelectionClear BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.selectionClear.time CARD32:u.selectionClear.window CARD32:u.selectionClear.atom EVENT SelectionRequest BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.selectionRequest.time CARD32:u.selectionRequest.owner CARD32:u.selectionRequest.requestor CARD32:u.selectionRequest.selection CARD32:u.selectionRequest.target CARD32:u.selectionRequest.property EVENT SelectionNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.selectionNotify.time CARD32:u.selectionNotify.requestor CARD32:u.selectionNotify.selection CARD32:u.selectionNotify.target CARD32:u.selectionNotify.property EVENT ColormapNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.colormap.window CARD32:u.colormap.colormap BOOL:u.colormap.new BYTE:u.colormap.state EVENT MappingNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD8:u.mappingNotify.request CARD8:u.mappingNotify.firstKeyCode CARD8:u.mappingNotify.count EVENT ClientMessage BYTE:u.u.type BYTE:u.u.detail CARD16:u.u.sequenceNumber CARD32:u.clientMessage.window CARD32:u.clientMessage.u.l.type python-xlib-0.33/test/gen/genprotocol.awk000066400000000000000000000042261435211557500205170ustar00rootroot00000000000000# Feed cc -E /usr/include/X11/Xproto.h into this BEGIN { in_struct = 0; types[BOOL] = types[BYTE] = 1; types[INT8] = types[CARD8] = 1; types[INT16] = types[CARD16] = 1; types[INT32] = types[CARD32] = 1; } in_struct == 1 && $1 == "}" && $2 ~ /x.*;/ { name = substr($2, 2, length($2) - 2); memlist = ""; for (i = 0; i < memcount; i++) memlist = memlist " " members[i]; # print name ", " memlist if (name ~ /Req$/) requests[substr(name, 1, length(name) - 3)] = memlist; else if (name ~ /Reply$/) replies[substr(name, 1, length(name) - 5)] = memlist; else structs[name] = memlist; delete members; in_struct = 0; } in_struct == 2 && $1 == "}" && $2 == "xEvent;" { in_struct = 0; } in_struct == 1 && $1 != "}" { fcount = split($0, f, "[ \t,;]+"); if (fcount > 0) { if (f[1] == "") i = 2; else i = 1; if (next_type == "") { type = f[i]; i++; } else { type = next_type; } if ($0 ~ /;[ \t]*$/) { next_type = ""; } else { next_type = type; } for (; i < fcount; i++) { members[memcount] = type ":" f[i]; memcount++; } } } /^typedef struct.*\{/ { if (in_struct) { print "typedef struct while in_struct!"; exit 1; } next_type = ""; in_struct = 1; memcount = 0; # hack to skip _xEvent if ($3 == "_xEvent") in_struct = 2; } /^typedef x.* x.*;/ { if (in_struct) { print "typedef xFoo xBar; while in_struct!"; exit 1; } src = substr($2, 2); dest = substr($3, 2, length($3) - 2); if (src ~ /Req$/) memlist = requests[substr(src, 1, length(src) - 3)]; else if (src ~ /Reply$/) memlist = replies[substr(src, 1, length(src) - 5)]; else memlist = structs[src]; if (dest ~ /Req$/) requests[substr(dest, 1, length(dest) - 3)] = memlist; else if (dest ~ /Reply$/) replies[substr(dest, 1, length(dest) - 5)] = memlist; else structs[dest] = memlist; } END { for (x in requests) print "REQUEST " x " " requests[x]; for (x in replies) print "REPLY " x " " replies[x]; for (x in structs) print "STRUCT " x " " structs[x]; } python-xlib-0.33/test/gen/genprottest.py000066400000000000000000000766621435211557500204250ustar00rootroot00000000000000#!/usr/bin/env python import sys import os sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../../..'))) import struct from random import randint, choice, seed from Xlib.protocol import request, structs, rq, event from Xlib import X seed(42) MINI_DEF = (('CARD8', 'reqType'), ('BYTE', 'pad'), ('CARD16', 'length')) RESOURCE_DEF = (('CARD8', 'reqType'), ('BYTE', 'pad'), ('CARD16', 'length'), ('CARD32', 'id')) def read_defs(): global request_defs, reply_defs, struct_defs global mini_request_defs, resource_request_defs global event_defs request_defs = {} mini_request_defs = {} resource_request_defs = {} reply_defs = {} struct_defs = {} event_defs = {} for line in sys.stdin.readlines(): parts = line.strip().split() fields = [] for f in parts[2:]: fields.append(f.split(':')) if parts[0] == 'REQUEST': request_defs[parts[1]] = fields elif parts[0] == 'MINIREQUEST': mini_request_defs[parts[1]] = MINI_DEF elif parts[0] == 'RESOURCEREQUEST': resource_request_defs[parts[1]] = RESOURCE_DEF elif parts[0] == 'REPLY': reply_defs[parts[1]] = fields elif parts[0] == 'STRUCT': struct_defs[parts[1]] = fields elif parts[0] == 'EVENT': event_defs[parts[1]] = fields def build(): if struct.unpack('BB', struct.pack('H', 0x0100))[0]: endian = 'be' else: endian = 'le' read_defs() build_request(endian) build_event(endian) def build_request(endian): fc = open('genrequest.c', 'w') fc.write(C_HEADER) reqlist = list(request.major_codes.items()) reqlist.sort(key=lambda x: x[0]) genfuncs = [] req_args = {} reply_args = {} for code, req in reqlist: name = req.__name__ creqname = name cdefs = request_defs.get(name) if cdefs is None: cdefs = mini_request_defs.get(name) creqname = '' if cdefs is None: cdefs = resource_request_defs.get(name) creqname = 'Resource' creqname = 'x%sReq' % creqname if cdefs is None: sys.stderr.write('missing def for request: %s\n' % name) else: vardefs = request_var_defs.get(name, [()]) if type(vardefs) is not list: vardefs = [vardefs] i = 0 for v in vardefs: if i > 0: uname = name + str(i) else: uname = name try: req_args[uname] = gen_func(fc, 'genrequest_' + uname, creqname, 'REQUEST ' + uname, req._request, cdefs, v) except: sys.stderr.write('Error in %s request\n' % uname) raise genfuncs.append('genrequest_' + uname) i = i + 1 if issubclass(req, rq.ReplyRequest): cdefs = reply_defs.get(name) if cdefs is None: sys.stderr.write('missing def for reply: %s\n' % name) else: vardefs = reply_var_defs.get(name, ()) if type(vardefs) is not list: vardefs = [vardefs] i = 0 for v in vardefs: if i > 0: uname = name + str(i) else: uname = name try: reply_args[uname] = gen_func(fc, 'genreply_' + uname, 'x%sReply' % name, 'REPLY ' + uname, req._reply, cdefs, v) except: sys.stderr.write('Error in %s reply\n' % uname) raise genfuncs.append('genreply_' + uname) i = i + 1 fc.write(''' int main(void) { ''') for gf in genfuncs: fc.write(' %s();\n' % gf) fc.write(''' return 0; } ''') fc.close() os.system('gcc -Wall -g genrequest.c -o genrequest') req_bins = {} reply_bins = {} pc = os.popen('./genrequest', 'r') for line in pc.readlines(): parts = line.strip().split() if parts[0] == 'REQUEST': req_bins[parts[1]] = parts[2] elif parts[0] == 'REPLY': reply_bins[parts[1]] = parts[2] fpy = open('../test_requests_%s.py' % endian, 'w') os.chmod('../test_requests_%s.py' % endian, 0o755) if endian == 'be': e = 'BigEndian' v = 1 else: e = 'LittleEndian' v = 0 fpy.write(PY_HEADER % { 'endname': e, 'endvalue': v }) for code, req in reqlist: name = req.__name__ fpy.write('\n\nclass Test%s(EndianTest):\n' % name) fpy.write(' def setUp(self):\n') i = 0 reqs = -1 replies = -1 while 1: if i > 0: uname = name + str(i) else: uname = name reqbin = req_bins.get(uname) replybin = reply_bins.get(uname) if reqbin is None and replybin is None: break if reqbin: reqs = i fpy.write(' self.req_args_%d = %s\n' % (i, build_args(req_args[uname]))) fpy.write(' self.req_bin_%d = %s\n\n' % (i, build_bin(reqbin))) if replybin: replies = i fpy.write(' self.reply_args_%d = %s\n' % (i, build_args(reply_args[uname]))) fpy.write(' self.reply_bin_%d = %s\n\n' % (i, build_bin(replybin))) i = i + 1 for i in range(0, reqs + 1): fpy.write(''' def testPackRequest%(n)d(self): bin = request.%(req)s._request.to_binary(*(), **self.req_args_%(n)d) self.assertBinaryEqual(bin, self.req_bin_%(n)d) def testUnpackRequest%(n)d(self): args, remain = request.%(req)s._request.parse_binary(self.req_bin_%(n)d, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_%(n)d) ''' % { 'req': req.__name__, 'n': i }) for i in range(0, replies + 1): fpy.write(''' def testPackReply%(n)d(self): bin = request.%(req)s._reply.to_binary(*(), **self.reply_args_%(n)d) self.assertBinaryEqual(bin, self.reply_bin_%(n)d) def testUnpackReply%(n)d(self): args, remain = request.%(req)s._reply.parse_binary(self.reply_bin_%(n)d, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_%(n)d) ''' % { 'req': req.__name__, 'n': i }) fpy.write(''' if __name__ == "__main__": unittest.main() ''') def build_event(endian): fc = open('genevent.c', 'w') fc.write(C_HEADER) evtlist = list(event.event_class.items()) evtlist.sort(key=lambda x: x[0]) genfuncs = [] evt_args = {} for code, evt in evtlist: # skip events that does not subclass rq.Event immediately, # since those are specializations of the more general ones we # test. if evt.__bases__ != (rq.Event, ): continue # special handling of KeymapNotify, since that # event is so different if evt == event.KeymapNotify: evt_args['KeymapNotify'] = gen_func(fc, 'genevent_KeymapNotify', 'xKeymapEvent', 'EVENT KeymapNotify', evt._fields, (('BYTE', 'type'), ), (31, )) genfuncs.append('genevent_KeymapNotify') continue name = evt.__name__ cdefs = event_defs.get(name) if cdefs is None: sys.stderr.write('missing def for event: %s\n' % name) else: vardefs = event_var_defs.get(name, [()]) if type(vardefs) is not list: vardefs = [vardefs] i = 0 for v in vardefs: if i > 0: uname = name + str(i) else: uname = name try: evt_args[uname] = gen_func(fc, 'genevent_' + uname, 'xEvent', 'EVENT ' + uname, evt._fields, cdefs, v) except: sys.stderr.write('Error in %s event\n' % uname) raise genfuncs.append('genevent_' + uname) i = i + 1 fc.write(''' int main(void) { ''') for gf in genfuncs: fc.write(' %s();\n' % gf) fc.write(''' return 0; } ''') fc.close() os.system('gcc -Wall -g genevent.c -o genevent') evt_bins = {} pc = os.popen('./genevent', 'r') for line in pc.readlines(): parts = line.strip().split() if parts[0] == 'EVENT': evt_bins[parts[1]] = parts[2] fpy = open('../test_events_%s.py' % endian, 'w') os.chmod('../test_events_%s.py' % endian, 0o755) if endian == 'be': e = 'BigEndian' v = 1 else: e = 'LittleEndian' v = 0 fpy.write(PY_HEADER % { 'endname': e, 'endvalue': v }) for code, evt in evtlist: if evt.__bases__ != (rq.Event, ): continue name = evt.__name__ fpy.write('\n\nclass Test%s(EndianTest):\n' % name) fpy.write(' def setUp(self):\n') i = 0 evts = -1 while 1: if i > 0: uname = name + str(i) else: uname = name evtbin = evt_bins.get(uname) if evtbin is None: break evts = i fpy.write(' self.evt_args_%d = %s\n' % (i, build_args(evt_args[uname]))) fpy.write(' self.evt_bin_%d = %s\n\n' % (i, build_bin(evtbin))) i = i + 1 for i in range(0, evts + 1): fpy.write(''' def testPack%(n)d(self): bin = event.%(evt)s._fields.to_binary(*(), **self.evt_args_%(n)d) self.assertBinaryEqual(bin, self.evt_bin_%(n)d) def testUnpack%(n)d(self): args, remain = event.%(evt)s._fields.parse_binary(self.evt_bin_%(n)d, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_%(n)d) ''' % { 'evt': evt.__name__, 'n': i }) fpy.write(''' if __name__ == "__main__": unittest.main() ''') def gen_func(fc, funcname, structname, outputname, pydef, cdef, vardefs): fc.write('''void %s(void) { struct { %s xstruct; ''' % (funcname, structname)) args = {} varfs = {} extra_vars = [] flags = None # structure fields etc i = 0 for f in pydef.var_fields: # # List of something # if isinstance(f, rq.List): # # List of short strings # if f.type is rq.Str: vfstrings = vardefs[i] vflen = 0 vfdata = '' for s in vfstrings: vflen = vflen + 1 + len(s) vfdata = vfdata + chr(len(s)) + s fc.write('unsigned char %s[%d];\n ' % (f.name, pad4(vflen))) varfs[f.name] = ('memcpy(data.%s, %s, %d);' % (f.name, cstring(vfdata), vflen), len(vfstrings), 0) args[f.name] = vfstrings # # List of scalars # elif isinstance(f.type, rq.ScalarObj) \ or isinstance(f.type, rq.ResourceObj): vflen = vardefs[i] if f.type.structcode == 'B': rmin = 128 rmax = 255 deflen = pad4(vflen) ctype = 'CARD8' elif f.type.structcode == 'H': rmin = 32768 rmax = 65536 deflen = vflen + vflen % 2 ctype = 'CARD16' elif f.type.structcode == 'L': rmin = 65536 rmax = 2147483646 deflen = vflen ctype = 'CARD32' else: RuntimeError('oops: %s' % f.type.structcode) def rand(x, rmin = rmin, rmax = rmax): return randint(rmin, rmax) vfdata = list(map(rand, range(0, vflen))) # # Special case for a few in-line coded lists # if structname in ('xGetKeyboardControlReply', 'xQueryKeymapReply', 'xKeymapEvent'): extra_vars.append('%s %s_def[%d] = { %s };' % (ctype, f.name, vflen, ', '.join(map(str, vfdata)))) varfs[f.name] = ('memcpy(data.xstruct.map, %s_def, sizeof(%s_def));' % (f.name, f.name), vflen, 0) else: fc.write('%s %s[%d];\n ' % (ctype, f.name, deflen)) extra_vars.append('%s %s_def[%d] = { %s };' % (ctype, f.name, vflen, ', '.join(map(str, vfdata)))) varfs[f.name] = ('memcpy(data.%s, %s_def, sizeof(%s_def));' % (f.name, f.name, f.name), vflen, 0) args[f.name] = vfdata # # Special handling of unique Host case # elif f.type is structs.Host: pydata = [{ 'family': X.FamilyInternet, 'name': [ 34, 23, 178, 12 ] }, { 'family': X.FamilyInternet, 'name': [ 130, 236, 254, 15 ] }, ] cdata = [] for p in pydata: cdata.append("{ { %d, 0, 4 }, { %d, %d, %d, %d } }" % ((p['family'], ) + tuple(p['name']))) fc.write('struct { xHostEntry e; CARD8 name[4]; } %s[2];\n ' % f.name) extra_vars.append('struct { xHostEntry e; CARD8 name[4]; } %s_def[%d] = { %s };' % (f.name, len(pydata), ', '.join(cdata))) varfs[f.name] = ('memcpy(data.%s, %s_def, sizeof(%s_def));' % (f.name, f.name, f.name), len(pydata), 0) args[f.name] = pydata # # List of structures # elif isinstance(f.type, rq.Struct): vfname, vflen = vardefs[i] vfdef = struct_defs[vfname] pydata = [] defdata = [] for si in range(0, vflen): d = [] for t, cf in vfdef: if cf[:3] != 'pad': d.append(gen_value(t)) pyd = {} for sj in range(0, len(d)): pyd[f.type.fields[sj].name] = d[sj] pydata.append(pyd) defdata.append('{ ' + ', '.join(map(str, d)) + ' }') fc.write('x%s %s[%d];\n ' % (vfname, f.name, vflen)) extra_vars.append('x%s %s_def[%d] = { %s };' % (vfname, f.name, vflen, ', '.join(defdata))) varfs[f.name] = ('memcpy(data.%s, %s_def, sizeof(%s_def));' % (f.name, f.name, f.name), vflen, 0) args[f.name] = pydata # # wide-char string # elif isinstance(f, rq.String16): vfstr = vardefs[i] vflen = len(vfstr) fc.write('unsigned char %s[%d];\n ' % (f.name, (vflen + vflen % 2) * 2)) s = '' for c in vfstr: s = s + '\0' + c varfs[f.name] = ('memcpy(data.%s, %s, %d);' % (f.name, cstring(s), vflen * 2), vflen, 0) args[f.name] = tuple(map(ord, vfstr)) # # byte-char string # elif isinstance(f, (rq.String8, rq.Binary)): vfstr = vardefs[i] vflen = len(vfstr) fc.write('unsigned char %s[%d];\n ' % (f.name, (vflen + (4 - vflen % 4) % 4))) varfs[f.name] = ('memcpy(data.%s, %s, %d);' % (f.name, cstring(vfstr), vflen), vflen, 0) args[f.name] = vfstr # # List of optional values # elif isinstance(f, rq.ValueList): vlcode = [] vlargs = {} flags = 0 for vlf, flag in f.fields: ctype, rmin, rmax, clen = structcode_defs[vlf.structcode] fc.write('%s %s_%s;\n ' % (ctype, f.name, vlf.name)) if clen < 4: fc.write('unsigned char %s_%s_pad[%d];\n ' % (f.name, vlf.name, 4 - clen)) if isinstance(vlf, rq.Set): val = choice(vlf.values) elif isinstance(vlf, rq.Bool): val = choice((0, 1)) else: val = randint(rmin, rmax) vlargs[vlf.name] = val vlcode.append('data.%s_%s = %d;' % (f.name, vlf.name, val)) flags = flags | flag # vlcode.append('data.%s_flags = %d;' % (f.name, flags)) varfs[f.name] = (' '.join(vlcode), 0, 0) args[f.name] = vlargs # # Text/font list, hardwire since they are so rare # elif isinstance(f, rq.TextElements8): if isinstance(f, rq.TextElements16): vfstr = b'\x02\x02\x10\x23\x00\x12\xff\x01\x02\x03\x04' ret = [{'delta': 2, 'string': (0x1023, 0x0012)}, 0x01020304] else: vfstr = b'\x03\x02zoo\xff\x01\x02\x03\x04\x02\x00ie' ret = [{'delta': 2, 'string': 'zoo'}, 0x01020304, { 'delta': 0, 'string': 'ie'}] fc.write('unsigned char %s[%d];\n ' % (f.name, len(vfstr))) varfs[f.name] = ('memcpy(data.%s, %s, %d);' % (f.name, cstring(vfstr), len(vfstr)), 0, 0) args[f.name] = ret # # Keyboard/modifier mappings # elif isinstance(f, rq.KeyboardMapping) \ or isinstance(f, rq.ModifierMapping): if isinstance(f, rq.KeyboardMapping): rmin = 0 rmax = 2147483646 length = 20 format = 3 ctype = 'CARD32' else: rmin = 0 rmax = 255 length = 8 format = 2 ctype = 'CARD8' pydata = [] cdata = [] for i in range(0, length): x = [] for j in range(0, format): v = randint(rmin, rmax) x.append(v) cdata.append(str(v)) pydata.append(x) fc.write('%s %s[%d];\n ' % (ctype, f.name, len(cdata))) extra_vars.append('%s %s_def[%d] = { %s };' % (ctype, f.name, len(cdata), ', '.join(cdata))) varfs[f.name] = ('memcpy(data.%s, %s_def, sizeof(%s_def));' % (f.name, f.name, f.name), length, format) args[f.name] = pydata # # property data # elif isinstance(f, rq.PropertyData): format, data = vardefs[i] length = len(data) if format == 8: ctype = 'CARD8' clen = pad4(length) cdata = cstring(data) elif format == 16: ctype = 'CARD16' clen = length + length % 2 cdata = ', '.join(map(str, data)) elif format == 32: ctype = 'CARD32' clen = length cdata = ', '.join(map(str, data)) if not isinstance(f, rq.FixedPropertyData): fc.write('%s %s[%d];\n ' % (ctype, f.name, clen)) extra_vars.append('%s %s_def[%d] = { %s };' % (ctype, f.name, length, cdata)) if not isinstance(f, rq.FixedPropertyData): varfs[f.name] = ('memcpy(data.%s, %s_def, sizeof(%s_def));' % (f.name, f.name, f.name), length, format) else: varfs[f.name] = ('assert(sizeof(%s_def) == 20); memcpy(data.xstruct.u.clientMessage.u.b.bytes, %s_def, sizeof(%s_def));' % (f.name, f.name, f.name), length, format) args[f.name] = (format, data) # # Event # elif isinstance(f, rq.EventField): ev = event.Expose(window = gen_value('CARD32'), x = gen_value('CARD16'), y = gen_value('CARD16'), width = gen_value('CARD16'), height = gen_value('CARD16'), count = gen_value('CARD16')) cdata = cstring(ev._binary) # fc.write('unsigned char %s[32];\n ' % f.name) extra_vars.append('unsigned char %s_def[32] = %s;' % (f.name, cdata)) varfs[f.name] = ('memcpy(&data.xstruct.event, %s_def, sizeof(%s_def));' % (f.name, f.name), 0, 0) args[f.name] = ev else: raise RuntimeError('oops: %s.%s' % (funcname, f.name)) i = i + 1 fc.write('\n } data;\n') for v in extra_vars: fc.write(' %s\n' % v) fc.write(''' memset(&data, 0, sizeof(data)); ''') pyi = 0 ci = 0 while ci < len(cdef): try: pyf = pydef.fields[pyi] except IndexError: pyf = None cf = cdef[ci] t, f = cf pyi = pyi + 1 ci = ci + 1 if f[:3] == 'pad' or f[:6] == 'walign': if not isinstance(pyf, rq.Pad): pyi = pyi - 1 # special case for value list mask elif (f == 'mask' or f == 'valueMask') and flags is not None: fc.write(' data.xstruct.%s = %d;\n' % (f, flags)) elif isinstance(pyf, rq.ConstantField): fc.write(' data.xstruct.%s = %d;\n' % (f, pyf.value)) elif isinstance(pyf, rq.RequestLength): assert f == 'length' fc.write(' assert(sizeof(data) % 4 == 0);\n') fc.write(' data.xstruct.length = sizeof(data) / 4;\n') elif isinstance(pyf, rq.ReplyLength): assert f == 'length' fc.write(' assert(sizeof(data) % 4 == 0);\n') fc.write(' assert(sizeof(data) >= 32);\n') fc.write(' data.xstruct.length = (sizeof(data) - 32) / 4;\n') elif isinstance(pyf, rq.LengthOf): fc.write(' data.xstruct.%s = %d;\n' % (f, varfs[pyf.name][1])) elif isinstance(pyf, rq.OddLength): fc.write(' data.xstruct.%s = %d;\n' % (f, varfs[pyf.name][1] % 2)) elif isinstance(pyf, rq.Format): fc.write(' data.xstruct.%s = %d;\n' % (f, varfs[pyf.name][2])) elif isinstance(pyf, rq.Set): val = choice(pyf.values) fc.write(' data.xstruct.%s = %d;\n' % (f, val)) args[pyf.name] = val elif t == 'xCharInfo': d = [] for ct, cf in struct_defs['CharInfo']: if cf[:3] != 'pad': d.append(gen_value(ct)) pyd = {} for sj in range(0, len(d)): pyd[pyf.type.fields[sj].name] = d[sj] fc.write('{ %s def = { %s };\n ' % (t, ', '.join(map(str, d)))) fc.write('memcpy(&data.xstruct.%s, &def, sizeof(def)); }\n ' % f) args[pyf.name] = pyd else: val = gen_value(t) fc.write(' data.xstruct.%s = %d;\n' % (f, val)) args[pyf.name] = val for code, length, format in varfs.values(): fc.write(' %s\n' % code); fc.write(''' output("%s", &data, sizeof(data)); } ''' % outputname) return args def gen_value(t): if t == 'INT8': val = randint(-128, -1) elif t == 'INT16': val = randint(-32768, -256) elif t == 'INT32': val = randint(-2147483647, -65536) elif t == 'CARD8' or t == 'BYTE': val = randint(128, 255) elif t == 'CARD16': val = randint(256, 65535) elif t == 'CARD32': val = randint(65536, 2147483646) elif t == 'BOOL': val = randint(0, 1) else: raise RuntimeError('unknown type: %s' % t) return val def pad4(l): return l + (4 - l % 4) % 4 def cstring(s): if not isinstance(s, bytes): s = s.encode('ascii') return '"' + ''.join('\\x%x' % c for c in s) + '"' def build_args(args): kwlist = [] for kw, val in sorted(args.items(), key=lambda i: i[0]): if isinstance(val, rq.Event): members = list(val._data.keys()) members.remove('send_event') kwlist.append(" '%s': event.%s(%s),\n" % ( kw, val.__class__.__name__, ', '.join('%s=%s' % (m, val._data[m]) for m in sorted(members)), )) else: kwlist.append(" '%s': %s,\n" % (kw, repr(val))) return '{\n' + ''.join(kwlist) + ' }' def build_bin(bin): bins = [] for i in range(0, len(bin), 16): bins.append(bin[i:i+16]) bins2 = [] for i in range(0, len(bins), 2): try: bins2.append("b'%s' b'%s'" % (bins[i], bins[i + 1])) except IndexError: bins2.append("b'%s'" % bins[i]) return ' \\\n '.join(bins2) request_var_defs = { 'InternAtom': ('fuzzy_prop', ), 'ChangeProperty': [((8, b''), ), ((8, b'foo'), ), ((8, b'zoom'), ), ((16, []), ), ((16, [1, 2, 3]), ), ((16, [1, 2, 3, 4]), ), ((32, []), ), ((32, [1, 2, 3]), ) ], 'OpenFont': ('foofont', ), 'QueryTextExtents': ('foo', ), 'ListFonts': ('bhazr', ), 'ListFontsWithInfo': ('bhazr2', ), 'SetFontPath': [(['foo', 'bar', 'gazonk'], ), ([], ) ], 'SetDashes': (9, ), 'SetClipRectangles': [(('Rectangle', 2), ), (('Rectangle', 0), ) ], 'PolyPoint': (('Point', 3), ), 'PolyLine': (('Point', 5), ), 'PolySegment': (('Segment', 1), ), 'PolyRectangle': (('Rectangle', 3), ), 'PolyArc': (('Arc', 3), ), 'FillPoly': (('Point', 3), ), 'PolyFillRectangle': (('Rectangle', 2), ), 'PolyFillArc': (('Arc', 1), ), 'PutImage': (b'\xe9\x10\xf2o\x7f{\xae-\xe6\x18\xce\x83', ), 'ImageText8': ('showme', ), 'ImageText16': ('showmore', ), 'AllocNamedColor': ('octarin', ), 'FreeColors': (17, ), 'StoreColors': (('ColorItem', 4), ), 'StoreNamedColor': ('blue', ), 'QueryColors': [(8, ), (0, ) ], 'LookupColor': ('octarin', ), 'QueryExtension': ('XTRA', ), 'ChangeHosts': (4, ), 'RotateProperties': (12, ), 'SetPointerMapping': (5, ), } reply_var_defs = { 'QueryTree': (7, ), 'GetAtomName': ('WM_CLASS', ), 'GetProperty': [((8, b''), ), ((8, b'foo'), ), ((8, b'zoom'), ), ((16, []), ), ((16, [1, 2, 3]), ), ((16, [1, 2, 3, 4]), ), ((32, []), ), ((32, [1, 2, 3]), ) ], 'ListProperties': (23, ), 'GetMotionEvents': (('Timecoord', 5), ), 'QueryKeymap': (32, ), 'QueryFont': (('FontProp', 1), ('CharInfo', 3)), 'ListFonts': (['fie', 'fuzzy', 'foozooom'], ), 'ListFontsWithInfo': (('FontProp', 1), 'fontfont'), 'GetFontPath': [(['path1', 'path2232'], ), ([], ) ], 'GetImage': (b'\xeb?:\xa7\xc6\x8b\xc2\x96o-S\xe6\xd6z6\x94\xd7v\xd2R.\xa2\xeaw\t\x13\x95\x85',), 'ListInstalledColormaps': (2, ), 'AllocColorCells': [(17, 3), (0, 0) ], 'AllocColorPlanes': (4, ), 'QueryColors': (('rgb', 5), ), 'ListExtensions': (['XTRA', 'XTRA-II'], ), 'GetKeyboardControl': (32, ), 'GetPointerMapping': (5, ), # '': (, ), } event_var_defs = { 'ClientMessage': [((8, b'01234567890123456789'), ), ((16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), ), ((32, [1, 2, 3, 4, 5]), ) ], } structcode_defs = { 'b': ('INT8', -128, -1, 1), 'B': ('CARD8', 128, 255, 1), 'h': ('INT16', -32768, -1, 2), 'H': ('CARD16', 32768, 65536, 2), 'l': ('INT32', -2147483647, -1, 4), 'L': ('CARD32', 65536, 2147483646, 4), } C_HEADER = r''' #include #include #include #include #include void output(char *name, void *data, int length) { unsigned char *d = (unsigned char *) data; printf("%s ", name); while (length-- > 0) { if (0 && isgraph(*d)) putchar(*d); else printf("\\x%02x", *d); d++; } putchar('\n'); } ''' PY_HEADER = r'''#!/usr/bin/env python2 import sys, os sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest from Xlib.protocol import request, event from . import %(endname)sTest as EndianTest from . import DummyDisplay dummy_display = DummyDisplay() ''' if __name__ == '__main__': build() python-xlib-0.33/test/gen/protdef000066400000000000000000000475641435211557500170620ustar00rootroot00000000000000RESOURCEREQUEST GetWindowAttributes RESOURCEREQUEST DestroyWindow RESOURCEREQUEST DestroySubWindows RESOURCEREQUEST MapWindow RESOURCEREQUEST MapSubwindows RESOURCEREQUEST UnmapWindow RESOURCEREQUEST UnmapSubwindows RESOURCEREQUEST GetGeometry RESOURCEREQUEST QueryTree RESOURCEREQUEST GetAtomName RESOURCEREQUEST ListProperties RESOURCEREQUEST GetSelectionOwner RESOURCEREQUEST UngrabPointer RESOURCEREQUEST UngrabKeyboard RESOURCEREQUEST QueryPointer RESOURCEREQUEST CloseFont RESOURCEREQUEST QueryFont RESOURCEREQUEST FreePixmap RESOURCEREQUEST FreeGC RESOURCEREQUEST FreeColormap RESOURCEREQUEST InstallColormap RESOURCEREQUEST UninstallColormap RESOURCEREQUEST ListInstalledColormaps RESOURCEREQUEST FreeCursor RESOURCEREQUEST KillClient MINIREQUEST GetFontPath MINIREQUEST GrabServer MINIREQUEST UngrabServer MINIREQUEST GetInputFocus MINIREQUEST QueryKeymap MINIREQUEST ListExtensions MINIREQUEST GetKeyboardControl MINIREQUEST GetPointerControl MINIREQUEST GetScreenSaver MINIREQUEST GetPointerMapping MINIREQUEST GetModifierMapping MINIREQUEST NoOperation REQUEST RotateProperties CARD8:reqType BYTE:pad CARD16:length CARD32:window CARD16:nAtoms INT16:nPositions REQUEST AllocColor CARD8:reqType BYTE:pad CARD16:length CARD32:cmap CARD16:red CARD16:green CARD16:blue CARD16:pad2 REQUEST PolyText CARD8:reqType CARD8:pad CARD16:length CARD32:drawable CARD32:gc INT16:x INT16:y REQUEST DeleteProperty CARD8:reqType BYTE:pad CARD16:length CARD32:window CARD32:property REQUEST ChangeProperty CARD8:reqType CARD8:mode CARD16:length CARD32:window CARD32:property CARD32:type CARD8:format BYTE:pad[3] CARD32:nUnits REQUEST CARD8:reqType CARD8:data CARD16:length REQUEST SetPointerMapping CARD8:reqType CARD8:nElts CARD16:length REQUEST CreateGlyphCursor CARD8:reqType BYTE:pad CARD16:length CARD32:cid CARD32:source CARD32:mask CARD16:sourceChar CARD16:maskChar CARD16:foreRed CARD16:foreGreen CARD16:foreBlue CARD16:backRed CARD16:backGreen CARD16:backBlue REQUEST StoreColors CARD8:reqType BYTE:pad CARD16:length CARD32:cmap REQUEST PolyText8 CARD8:reqType CARD8:pad CARD16:length CARD32:drawable CARD32:gc INT16:x INT16:y REQUEST FillPoly CARD8:reqType BYTE:pad CARD16:length CARD32:drawable CARD32:gc BYTE:shape BYTE:coordMode CARD16:pad1 REQUEST PolyLine CARD8:reqType BYTE:coordMode CARD16:length CARD32:drawable CARD32:gc REQUEST WarpPointer CARD8:reqType BYTE:pad CARD16:length CARD32:srcWid CARD32:dstWid INT16:srcX INT16:srcY CARD16:srcWidth CARD16:srcHeight INT16:dstX INT16:dstY REQUEST CirculateWindow CARD8:reqType CARD8:direction CARD16:length CARD32:window REQUEST ChangeWindowAttributes CARD8:reqType BYTE:pad CARD16:length CARD32:window CARD32:valueMask REQUEST ChangeHosts CARD8:reqType BYTE:mode CARD16:length CARD8:hostFamily BYTE:pad CARD16:hostLength REQUEST PolyText16 CARD8:reqType CARD8:pad CARD16:length CARD32:drawable CARD32:gc INT16:x INT16:y REQUEST CopyArea CARD8:reqType BYTE:pad CARD16:length CARD32:srcDrawable CARD32:dstDrawable CARD32:gc INT16:srcX INT16:srcY INT16:dstX INT16:dstY CARD16:width CARD16:height REQUEST CopyGC CARD8:reqType BYTE:pad CARD16:length CARD32:srcGC CARD32:dstGC CARD32:mask REQUEST SetFontPath CARD8:reqType BYTE:pad CARD16:length CARD16:nFonts BYTE:pad1 BYTE:pad2 REQUEST OpenFont CARD8:reqType BYTE:pad CARD16:length CARD32:fid CARD16:nbytes BYTE:pad1 BYTE:pad2 REQUEST UngrabButton CARD8:reqType CARD8:button CARD16:length CARD32:grabWindow CARD16:modifiers CARD16:pad REQUEST ConfigureWindow CARD8:reqType CARD8:pad CARD16:length CARD32:window CARD16:mask CARD16:pad2 REQUEST ReparentWindow CARD8:reqType BYTE:pad CARD16:length CARD32:window CARD32:parent INT16:x INT16:y REQUEST ForceScreenSaver CARD8:reqType BYTE:mode CARD16:length REQUEST ChangeMode CARD8:reqType BYTE:mode CARD16:length REQUEST ChangePointerControl CARD8:reqType BYTE:pad CARD16:length INT16:accelNum INT16:accelDenum INT16:threshold BOOL:doAccel BOOL:doThresh REQUEST Bell CARD8:reqType INT8:percent CARD16:length REQUEST ChangeKeyboardControl CARD8:reqType BYTE:pad CARD16:length CARD32:mask REQUEST AllocNamedColor CARD8:reqType BYTE:pad CARD16:length CARD32:cmap CARD16:nbytes BYTE:pad1 BYTE:pad2 REQUEST GetImage CARD8:reqType CARD8:format CARD16:length CARD32:drawable INT16:x INT16:y CARD16:width CARD16:height CARD32:planeMask REQUEST PolyFillArc CARD8:reqType BYTE:pad CARD16:length CARD32:drawable CARD32:gc REQUEST CreatePixmap CARD8:reqType CARD8:depth CARD16:length CARD32:pid CARD32:drawable CARD16:width CARD16:height REQUEST QueryTextExtents CARD8:reqType BOOL:oddLength CARD16:length CARD32:fid REQUEST GrabKeyboard CARD8:reqType BOOL:ownerEvents CARD16:length CARD32:grabWindow CARD32:time BYTE:pointerMode BYTE:keyboardMode CARD16:pad REQUEST QueryColors CARD8:reqType BYTE:pad CARD16:length CARD32:cmap REQUEST CopyColormapAndFree CARD8:reqType BYTE:pad CARD16:length CARD32:mid CARD32:srcCmap REQUEST ImageText16 CARD8:reqType BYTE:nChars CARD16:length CARD32:drawable CARD32:gc INT16:x INT16:y REQUEST PolyRectangle CARD8:reqType BYTE:pad CARD16:length CARD32:drawable CARD32:gc REQUEST PolySegment CARD8:reqType BYTE:pad CARD16:length CARD32:drawable CARD32:gc REQUEST TranslateCoords CARD8:reqType BYTE:pad CARD16:length CARD32:srcWid CARD32:dstWid INT16:srcX INT16:srcY REQUEST GrabButton CARD8:reqType BOOL:ownerEvents CARD16:length CARD32:grabWindow CARD16:eventMask BYTE:pointerMode BYTE:keyboardMode CARD32:confineTo CARD32:cursor CARD8:button BYTE:pad CARD16:modifiers REQUEST SetSelectionOwner CARD8:reqType BYTE:pad CARD16:length CARD32:window CARD32:selection CARD32:time REQUEST SetAccessControl CARD8:reqType BYTE:mode CARD16:length REQUEST ChangeKeyboardMapping CARD8:reqType CARD8:keyCodes CARD16:length CARD8:firstKeyCode CARD8:keySymsPerKeyCode CARD16:pad1 REQUEST QueryExtension CARD8:reqType BYTE:pad CARD16:length CARD16:nbytes BYTE:pad1 BYTE:pad2 REQUEST AllocColorPlanes CARD8:reqType BOOL:contiguous CARD16:length CARD32:cmap CARD16:colors CARD16:red CARD16:green CARD16:blue REQUEST AllocColorCells CARD8:reqType BOOL:contiguous CARD16:length CARD32:cmap CARD16:colors CARD16:planes REQUEST ImageText8 CARD8:reqType BYTE:nChars CARD16:length CARD32:drawable CARD32:gc INT16:x INT16:y REQUEST ImageText CARD8:reqType BYTE:nChars CARD16:length CARD32:drawable CARD32:gc INT16:x INT16:y REQUEST PolyPoint CARD8:reqType BYTE:coordMode CARD16:length CARD32:drawable CARD32:gc REQUEST ChangeSaveSet CARD8:reqType BYTE:mode CARD16:length CARD32:window REQUEST QueryBestSize CARD8:reqType CARD8:class CARD16:length CARD32:drawable CARD16:width CARD16:height REQUEST LookupColor CARD8:reqType BYTE:pad CARD16:length CARD32:cmap CARD16:nbytes BYTE:pad1 BYTE:pad2 REQUEST PolyArc CARD8:reqType BYTE:pad CARD16:length CARD32:drawable CARD32:gc REQUEST SetDashes CARD8:reqType BYTE:pad CARD16:length CARD32:gc CARD16:dashOffset CARD16:nDashes REQUEST ChangeActivePointerGrab CARD8:reqType BYTE:pad CARD16:length CARD32:cursor CARD32:time CARD16:eventMask CARD16:pad2 REQUEST GrabPointer CARD8:reqType BOOL:ownerEvents CARD16:length CARD32:grabWindow CARD16:eventMask BYTE:pointerMode BYTE:keyboardMode CARD32:confineTo CARD32:cursor CARD32:time REQUEST ConvertSelection CARD8:reqType BYTE:pad CARD16:length CARD32:requestor CARD32:selection CARD32:target CARD32:property CARD32:time REQUEST CreateWindow CARD8:reqType CARD8:depth CARD16:length CARD32:wid CARD32:parent INT16:x INT16:y CARD16:width CARD16:height CARD16:borderWidth CARD16:class CARD32:visual CARD32:mask REQUEST PolyFillRectangle CARD8:reqType BYTE:pad CARD16:length CARD32:drawable CARD32:gc REQUEST SetClipRectangles CARD8:reqType BYTE:ordering CARD16:length CARD32:gc INT16:xOrigin INT16:yOrigin REQUEST ListFontsWithInfo CARD8:reqType BYTE:pad CARD16:length CARD16:maxNames CARD16:nbytes REQUEST GetMotionEvents CARD8:reqType BYTE:pad CARD16:length CARD32:window CARD32:start CARD32:stop REQUEST Resource CARD8:reqType BYTE:pad CARD16:length CARD32:id REQUEST StoreNamedColor CARD8:reqType CARD8:flags CARD16:length CARD32:cmap CARD32:pixel CARD16:nbytes BYTE:pad1 BYTE:pad2 REQUEST CopyPlane CARD8:reqType BYTE:pad CARD16:length CARD32:srcDrawable CARD32:dstDrawable CARD32:gc INT16:srcX INT16:srcY INT16:dstX INT16:dstY CARD16:width CARD16:height CARD32:bitPlane REQUEST ListFonts CARD8:reqType BYTE:pad CARD16:length CARD16:maxNames CARD16:nbytes REQUEST UngrabKey CARD8:reqType CARD8:key CARD16:length CARD32:grabWindow CARD16:modifiers CARD16:pad REQUEST GetProperty CARD8:reqType BOOL:delete CARD16:length CARD32:window CARD32:property CARD32:type CARD32:longOffset CARD32:longLength REQUEST RecolorCursor CARD8:reqType BYTE:pad CARD16:length CARD32:cursor CARD16:foreRed CARD16:foreGreen CARD16:foreBlue CARD16:backRed CARD16:backGreen CARD16:backBlue REQUEST CreateCursor CARD8:reqType BYTE:pad CARD16:length CARD32:cid CARD32:source CARD32:mask CARD16:foreRed CARD16:foreGreen CARD16:foreBlue CARD16:backRed CARD16:backGreen CARD16:backBlue CARD16:x CARD16:y REQUEST ChangeGC CARD8:reqType BYTE:pad CARD16:length CARD32:gc CARD32:mask REQUEST CreateGC CARD8:reqType BYTE:pad CARD16:length CARD32:gc CARD32:drawable CARD32:mask REQUEST SetInputFocus CARD8:reqType CARD8:revertTo CARD16:length CARD32:focus CARD32:time REQUEST GrabKey CARD8:reqType BOOL:ownerEvents CARD16:length CARD32:grabWindow CARD16:modifiers CARD8:key BYTE:pointerMode BYTE:keyboardMode BYTE:pad1 BYTE:pad2 BYTE:pad3 REQUEST ListHosts CARD8:reqType BYTE:pad CARD16:length REQUEST SetScreenSaver CARD8:reqType BYTE:pad CARD16:length INT16:timeout INT16:interval BYTE:preferBlank BYTE:allowExpose CARD16:pad2 REQUEST SetModifierMapping CARD8:reqType CARD8:numKeyPerModifier CARD16:length REQUEST InternAtom CARD8:reqType BOOL:onlyIfExists CARD16:length CARD16:nbytes CARD16:pad REQUEST SetCloseDownMode CARD8:reqType BYTE:mode CARD16:length REQUEST GetKeyboardMapping CARD8:reqType BYTE:pad CARD16:length CARD8:firstKeyCode CARD8:count CARD16:pad1 REQUEST FreeColors CARD8:reqType BYTE:pad CARD16:length CARD32:cmap CARD32:planeMask REQUEST CreateColormap CARD8:reqType BYTE:alloc CARD16:length CARD32:mid CARD32:window CARD32:visual REQUEST PutImage CARD8:reqType CARD8:format CARD16:length CARD32:drawable CARD32:gc CARD16:width CARD16:height INT16:dstX INT16:dstY CARD8:leftPad CARD8:depth CARD16:pad REQUEST ClearArea CARD8:reqType BOOL:exposures CARD16:length CARD32:window INT16:x INT16:y CARD16:width CARD16:height REQUEST AllowEvents CARD8:reqType CARD8:mode CARD16:length CARD32:time REQUEST SendEvent CARD8:reqType BOOL:propagate CARD16:length CARD32:destination CARD32:eventMask REPLY AllocColor BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:red CARD16:green CARD16:blue CARD16:pad2 CARD32:pixel CARD32:pad3 CARD32:pad4 CARD32:pad5 REPLY ListProperties BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nProperties CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY QueryTree BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD32:root CARD32:parent CARD16:nChildren CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 REPLY GetKeyboardControl BYTE:type BOOL:globalAutoRepeat CARD16:sequenceNumber CARD32:length CARD32:ledMask CARD8:keyClickPercent CARD8:bellPercent CARD16:bellPitch CARD16:bellDuration CARD16:pad REPLY SetPointerMapping BYTE:type CARD8:success CARD16:sequenceNumber CARD32:length CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY SetMapping BYTE:type CARD8:success CARD16:sequenceNumber CARD32:length CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetGeometry BYTE:type CARD8:depth CARD16:sequenceNumber CARD32:length CARD32:root INT16:x INT16:y CARD16:width CARD16:height CARD16:borderWidth CARD16:pad1 CARD32:pad2 CARD32:pad3 REPLY QueryPointer BYTE:type BOOL:sameScreen CARD16:sequenceNumber CARD32:length CARD32:root CARD32:child INT16:rootX INT16:rootY INT16:winX INT16:winY CARD16:mask CARD16:pad1 CARD32:pad REPLY AllocNamedColor BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD32:pixel CARD16:exactRed CARD16:exactGreen CARD16:exactBlue CARD16:screenRed CARD16:screenGreen CARD16:screenBlue CARD32:pad2 CARD32:pad3 REPLY GetImage BYTE:type CARD8:depth CARD16:sequenceNumber CARD32:length CARD32:visual CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY QueryTextExtents BYTE:type CARD8:drawDirection CARD16:sequenceNumber CARD32:length INT16:fontAscent INT16:fontDescent INT16:overallAscent INT16:overallDescent INT32:overallWidth INT32:overallLeft INT32:overallRight CARD32:pad REPLY GrabKeyboard BYTE:type BYTE:status CARD16:sequenceNumber CARD32:length CARD32:pad1 CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY GetPointerControl BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:accelNumerator CARD16:accelDenominator CARD16:threshold CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY GetModifierMapping BYTE:type CARD8:numKeyPerModifier CARD16:sequenceNumber CARD32:length CARD32:pad1 CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY ListExtensions BYTE:type CARD8:nExtensions CARD16:sequenceNumber CARD32:length CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY QueryColors BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nColors CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY TranslateCoords BYTE:type BOOL:sameScreen CARD16:sequenceNumber CARD32:length CARD32:child INT16:dstX INT16:dstY CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 REPLY QueryExtension BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length BOOL:present CARD8:major_opcode CARD8:first_event CARD8:first_error CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY AllocColorPlanes BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nPixels CARD16:pad2 CARD32:redMask CARD32:greenMask CARD32:blueMask CARD32:pad3 CARD32:pad4 REPLY AllocColorCells BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nPixels CARD16:nMasks CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetFontPath BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nPaths CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetAtomName BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nameLength CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetPointerMapping BYTE:type CARD8:nElts CARD16:sequenceNumber CARD32:length CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY QueryBestSize BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:width CARD16:height CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY LookupColor BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:exactRed CARD16:exactGreen CARD16:exactBlue CARD16:screenRed CARD16:screenGreen CARD16:screenBlue CARD32:pad3 CARD32:pad4 CARD32:pad5 REPLY QueryKeymap BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length REPLY GrabPointer BYTE:type BYTE:status CARD16:sequenceNumber CARD32:length CARD32:pad1 CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY ListFontsWithInfo BYTE:type CARD8:nameLength CARD16:sequenceNumber CARD32:length xCharInfo:minBounds CARD32:walign1 xCharInfo:maxBounds CARD32:walign2 CARD16:minCharOrByte2 CARD16:maxCharOrByte2 CARD16:defaultChar CARD16:nFontProps CARD8:drawDirection CARD8:minByte1 CARD8:maxByte1 BOOL:allCharsExist INT16:fontAscent INT16:fontDescent CARD32:nReplies REPLY QueryFont BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length xCharInfo:minBounds CARD32:walign1 xCharInfo:maxBounds CARD32:walign2 CARD16:minCharOrByte2 CARD16:maxCharOrByte2 CARD16:defaultChar CARD16:nFontProps CARD8:drawDirection CARD8:minByte1 CARD8:maxByte1 BOOL:allCharsExist INT16:fontAscent INT16:fontDescent CARD32:nCharInfos REPLY GetMotionEvents BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD32:nEvents CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY GetWindowAttributes BYTE:type CARD8:backingStore CARD16:sequenceNumber CARD32:length CARD32:visualID CARD16:class CARD8:bitGravity CARD8:winGravity CARD32:backingBitPlanes CARD32:backingPixel BOOL:saveUnder BOOL:mapInstalled CARD8:mapState BOOL:override CARD32:colormap CARD32:allEventMasks CARD32:yourEventMask CARD16:doNotPropagateMask CARD16:pad REPLY GetScreenSaver BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:timeout CARD16:interval BOOL:preferBlanking BOOL:allowExposures CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY ListFonts BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nFonts CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetProperty BYTE:type CARD8:format CARD16:sequenceNumber CARD32:length CARD32:propertyType CARD32:bytesAfter CARD32:nItems CARD32:pad1 CARD32:pad2 CARD32:pad3 REPLY Generic BYTE:type BYTE:data1 CARD16:sequenceNumber CARD32:length CARD32:data00 CARD32:data01 CARD32:data02 CARD32:data03 CARD32:data04 CARD32:data05 REPLY ListHosts BYTE:type BOOL:enabled CARD16:sequenceNumber CARD32:length CARD16:nHosts CARD16:pad1 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY SetModifierMapping BYTE:type CARD8:success CARD16:sequenceNumber CARD32:length CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetSelectionOwner BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD32:owner CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY InternAtom BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD32:atom CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY GetKeyboardMapping BYTE:type CARD8:keySymsPerKeyCode CARD16:sequenceNumber CARD32:length CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY ListInstalledColormaps BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nColormaps CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetInputFocus BYTE:type CARD8:revertTo CARD16:sequenceNumber CARD32:length CARD32:focus CARD32:pad1 CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 STRUCT Depth CARD8:depth CARD8:pad1 CARD16:nVisuals CARD32:pad2 STRUCT WindowRoot CARD32:windowId CARD32:defaultColormap CARD32:whitePixel CARD32:blackPixel CARD32:currentInputMask CARD16:pixWidth CARD16:pixHeight CARD16:mmWidth CARD16:mmHeight CARD16:minInstalledMaps CARD16:maxInstalledMaps CARD32:rootVisualID CARD8:backingStore BOOL:saveUnders CARD8:rootDepth CARD8:nDepths STRUCT TextElt CARD8:len INT8:delta STRUCT rgb CARD16:red CARD16:green CARD16:blue CARD16:pad STRUCT FontProp CARD32:name CARD32:value STRUCT HostEntry CARD8:family BYTE:pad CARD16:length STRUCT ConnSetupPrefix CARD8:success BYTE:lengthReason CARD16:majorVersion CARD16:minorVersion CARD16:length STRUCT Arc INT16:x INT16:y CARD16:width CARD16:height INT16:angle1 INT16:angle2 STRUCT Point INT16:x INT16:y STRUCT VisualType CARD32:visualID CARD8:class CARD8:bitsPerRGB CARD16:colormapEntries CARD32:redMask CARD32:greenMask CARD32:blueMask CARD32:pad STRUCT Error BYTE:type BYTE:errorCode CARD16:sequenceNumber CARD32:resourceID CARD16:minorCode CARD8:majorCode BYTE:pad1 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 STRUCT PixmapFormat CARD8:depth CARD8:bitsPerPixel CARD8:scanLinePad CARD8:pad1 CARD32:pad2 STRUCT CharInfo INT16:leftSideBearing INT16:rightSideBearing INT16:characterWidth INT16:ascent INT16:descent CARD16:attributes STRUCT Segment INT16:x1 INT16:y1 INT16:x2 INT16:y2 STRUCT ColorItem CARD32:pixel CARD16:red CARD16:green CARD16:blue CARD8:flags CARD8:pad STRUCT Timecoord CARD32:time INT16:x INT16:y STRUCT ConnSetup CARD32:release CARD32:ridBase CARD32:ridMask CARD32:motionBufferSize CARD16:nbytesVendor CARD16:maxRequestSize CARD8:numRoots CARD8:numFormats CARD8:imageByteOrder CARD8:bitmapBitOrder CARD8:bitmapScanlineUnit CARD8:bitmapScanlinePad CARD8:minKeyCode CARD8:maxKeyCode CARD32:pad2 STRUCT Rectangle INT16:x INT16:y CARD16:width CARD16:height STRUCT ConnClientPrefix CARD8:byteOrder BYTE:pad CARD16:majorVersion CARD16:minorVersion CARD16:nbytesAuthProto CARD16:nbytesAuthString CARD16:pad2 STRUCT KeymapEvent BYTE:type BYTE:map[31] python-xlib-0.33/test/test_bytesview.py000066400000000000000000000015221435211557500203350ustar00rootroot00000000000000 import unittest # Python 2/3 compatibility. from six import indexbytes, text_type from Xlib.protocol.display import bytesview class BytesViewTest(unittest.TestCase): def test(self): with self.assertRaises(TypeError): bytesview(text_type('foobar')) data = b'0123456789ABCDEF' view = bytesview(data) self.assertEqual(len(view), 16) self.assertEqual(view[:], data) self.assertIsInstance(view[:], bytes) self.assertEqual(view[5:-6], b'56789') self.assertEqual(indexbytes(view, 7), ord('7')) view = bytesview(view, 5) self.assertEqual(view[:], b'56789ABCDEF') self.assertEqual(indexbytes(view, 4), ord('9')) view = bytesview(view, 0, 5) self.assertEqual(view[:], b'56789') self.assertEqual(indexbytes(view, 1), ord('6')) python-xlib-0.33/test/test_events_be.py000077500000000000000000000524631435211557500203030ustar00rootroot00000000000000#!/usr/bin/env python2 import sys, os sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest from Xlib.protocol import request, event from . import BigEndianTest as EndianTest from . import DummyDisplay dummy_display = DummyDisplay() class TestKeymapNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'data': [248, 202, 136, 187, 201, 200, 244, 146, 187, 195, 178, 236, 157, 185, 166, 196, 164, 146, 143, 170, 206, 201, 240, 159, 247, 205, 231, 197, 254, 240, 148], 'type': 138, } self.evt_bin_0 = b'\x8a\xf8\xca\x88' b'\xbb\xc9\xc8\xf4' \ b'\x92\xbb\xc3\xb2' b'\xec\x9d\xb9\xa6' \ b'\xc4\xa4\x92\x8f' b'\xaa\xce\xc9\xf0' \ b'\x9f\xf7\xcd\xe7' b'\xc5\xfe\xf0\x94' def testPack0(self): bin = event.KeymapNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.KeymapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestExpose(EndianTest): def setUp(self): self.evt_args_0 = { 'count': 15258, 'height': 6241, 'sequence_number': 48394, 'type': 238, 'width': 1951, 'window': 692245859, 'x': 39820, 'y': 16664, } self.evt_bin_0 = b'\xee\x00\xbd\x0a' b'\x29\x42\xd5\x63' \ b'\x9b\x8c\x41\x18' b'\x07\x9f\x18\x61' \ b'\x3b\x9a\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.Expose._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.Expose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestGraphicsExpose(EndianTest): def setUp(self): self.evt_args_0 = { 'count': 49818, 'drawable': 1443779242, 'height': 2892, 'major_event': 172, 'minor_event': 50267, 'sequence_number': 50375, 'type': 133, 'width': 38020, 'x': 54088, 'y': 17918, } self.evt_bin_0 = b'\x85\x00\xc4\xc7' b'\x56\x0e\x52\xaa' \ b'\xd3\x48\x45\xfe' b'\x94\x84\x0b\x4c' \ b'\xc4\x5b\xc2\x9a' b'\xac\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.GraphicsExpose._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.GraphicsExpose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestNoExpose(EndianTest): def setUp(self): self.evt_args_0 = { 'major_event': 199, 'minor_event': 29237, 'sequence_number': 34266, 'type': 248, 'window': 1399171519, } self.evt_bin_0 = b'\xf8\x00\x85\xda' b'\x53\x65\xa9\xbf' \ b'\x72\x35\xc7\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.NoExpose._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.NoExpose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestVisibilityNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 38616, 'state': 253, 'type': 174, 'window': 936121409, } self.evt_bin_0 = b'\xae\x00\x96\xd8' b'\x37\xcc\x14\x41' \ b'\xfd\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.VisibilityNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.VisibilityNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestCreateNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'border_width': 56468, 'height': 7111, 'override': 0, 'parent': 747306217, 'sequence_number': 31058, 'type': 151, 'width': 44173, 'window': 876986399, 'x': -21847, 'y': -22248, } self.evt_bin_0 = b'\x97\x00\x79\x52' b'\x2c\x8a\xfc\xe9' \ b'\x34\x45\xc0\x1f' b'\xaa\xa9\xa9\x18' \ b'\xac\x8d\x1b\xc7' b'\xdc\x94\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.CreateNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.CreateNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestDestroyNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'event': 1489718405, 'sequence_number': 27233, 'type': 212, 'window': 1064077163, } self.evt_bin_0 = b'\xd4\x00\x6a\x61' b'\x58\xcb\x4c\x85' \ b'\x3f\x6c\x87\x6b' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.DestroyNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.DestroyNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestUnmapNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'event': 2029853215, 'from_configure': 0, 'sequence_number': 43679, 'type': 201, 'window': 860030193, } self.evt_bin_0 = b'\xc9\x00\xaa\x9f' b'\x78\xfd\x1a\x1f' \ b'\x33\x43\x04\xf1' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.UnmapNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.UnmapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestMapNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'event': 675485985, 'override': 1, 'sequence_number': 6027, 'type': 244, 'window': 542087937, } self.evt_bin_0 = b'\xf4\x00\x17\x8b' b'\x28\x43\x19\x21' \ b'\x20\x4f\x9b\x01' b'\x01\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.MapNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.MapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestMapRequest(EndianTest): def setUp(self): self.evt_args_0 = { 'parent': 1659099581, 'sequence_number': 63838, 'type': 157, 'window': 868024861, } self.evt_bin_0 = b'\x9d\x00\xf9\x5e' b'\x62\xe3\xd9\xbd' \ b'\x33\xbd\x02\x1d' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.MapRequest._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.MapRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestReparentNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'event': 1867017989, 'override': 0, 'parent': 992152190, 'sequence_number': 43356, 'type': 128, 'window': 1165276406, 'x': -19227, 'y': -30992, } self.evt_bin_0 = b'\x80\x00\xa9\x5c' b'\x6f\x48\x6f\x05' \ b'\x45\x74\xb4\xf6' b'\x3b\x23\x0a\x7e' \ b'\xb4\xe5\x86\xf0' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ReparentNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ReparentNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestConfigureNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'above_sibling': 1343120585, 'border_width': 17757, 'event': 1624514845, 'height': 13596, 'override': 0, 'sequence_number': 41060, 'type': 220, 'width': 3638, 'window': 1070571314, 'x': -18284, 'y': -7865, } self.evt_bin_0 = b'\xdc\x00\xa0\x64' b'\x60\xd4\x21\x1d' \ b'\x3f\xcf\x9f\x32' b'\x50\x0e\x64\xc9' \ b'\xb8\x94\xe1\x47' b'\x0e\x36\x35\x1c' \ b'\x45\x5d\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ConfigureNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ConfigureNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestConfigureRequest(EndianTest): def setUp(self): self.evt_args_0 = { 'border_width': 52639, 'height': 40159, 'parent': 1499546058, 'sequence_number': 57983, 'sibling': 260826075, 'stack_mode': 240, 'type': 201, 'value_mask': 15938, 'width': 41545, 'window': 1040976198, 'x': -31823, 'y': -880, } self.evt_bin_0 = b'\xc9\xf0\xe2\x7f' b'\x59\x61\x41\xca' \ b'\x3e\x0c\x09\x46' b'\x0f\x8b\xe3\xdb' \ b'\x83\xb1\xfc\x90' b'\xa2\x49\x9c\xdf' \ b'\xcd\x9f\x3e\x42' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ConfigureRequest._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ConfigureRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestGravityNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'event': 1182983311, 'sequence_number': 20621, 'type': 168, 'window': 29431224, 'x': -14672, 'y': -19399, } self.evt_bin_0 = b'\xa8\x00\x50\x8d' b'\x46\x82\xe4\x8f' \ b'\x01\xc1\x15\xb8' b'\xc6\xb0\xb4\x39' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.GravityNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.GravityNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestResizeRequest(EndianTest): def setUp(self): self.evt_args_0 = { 'height': 60085, 'sequence_number': 14981, 'type': 151, 'width': 55398, 'window': 2130921516, } self.evt_bin_0 = b'\x97\x00\x3a\x85' b'\x7f\x03\x48\x2c' \ b'\xd8\x66\xea\xb5' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ResizeRequest._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ResizeRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestPropertyNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'atom': 252322161, 'sequence_number': 30497, 'state': 167, 'time': 1391011497, 'type': 157, 'window': 2033863003, } self.evt_bin_0 = b'\x9d\x00\x77\x21' b'\x79\x3a\x49\x5b' \ b'\x0f\x0a\x21\x71' b'\x52\xe9\x26\xa9' \ b'\xa7\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.PropertyNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.PropertyNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestSelectionClear(EndianTest): def setUp(self): self.evt_args_0 = { 'atom': 1092859866, 'sequence_number': 61378, 'time': 1538959461, 'type': 255, 'window': 626833463, } self.evt_bin_0 = b'\xff\x00\xef\xc2' b'\x5b\xba\xa8\x65' \ b'\x25\x5c\xb8\x37' b'\x41\x23\xb7\xda' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.SelectionClear._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.SelectionClear._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestSelectionRequest(EndianTest): def setUp(self): self.evt_args_0 = { 'owner': 1036225485, 'property': 981007010, 'requestor': 2105124856, 'selection': 1014149797, 'sequence_number': 27485, 'target': 523473665, 'time': 1792621552, 'type': 197, } self.evt_bin_0 = b'\xc5\x00\x6b\x5d' b'\x6a\xd9\x3b\xf0' \ b'\x3d\xc3\x8b\xcd' b'\x7d\x79\xa7\xf8' \ b'\x3c\x72\xb2\xa5' b'\x1f\x33\x93\x01' \ b'\x3a\x78\xfa\xa2' b'\x00\x00\x00\x00' def testPack0(self): bin = event.SelectionRequest._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.SelectionRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestSelectionNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'property': 1602716574, 'requestor': 1979762314, 'selection': 1287219120, 'sequence_number': 25394, 'target': 1091504539, 'time': 409398186, 'type': 165, } self.evt_bin_0 = b'\xa5\x00\x63\x32' b'\x18\x66\xeb\xaa' \ b'\x76\x00\xc6\x8a' b'\x4c\xb9\x67\xb0' \ b'\x41\x0f\x09\x9b' b'\x5f\x87\x83\x9e' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.SelectionNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.SelectionNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestColormapNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'colormap': 593302316, 'new': 1, 'sequence_number': 56880, 'state': 215, 'type': 162, 'window': 149981547, } self.evt_bin_0 = b'\xa2\x00\xde\x30' b'\x08\xf0\x89\x6b' \ b'\x23\x5d\x13\x2c' b'\x01\xd7\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ColormapNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ColormapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestClientMessage(EndianTest): def setUp(self): self.evt_args_0 = { 'client_type': 607457628, 'data': (8, b'01234567890123456789'), 'sequence_number': 54031, 'type': 196, 'window': 5574388, } self.evt_bin_0 = b'\xc4\x08\xd3\x0f' b'\x00\x55\x0e\xf4' \ b'\x24\x35\x11\x5c' b'\x30\x31\x32\x33' \ b'\x34\x35\x36\x37' b'\x38\x39\x30\x31' \ b'\x32\x33\x34\x35' b'\x36\x37\x38\x39' self.evt_args_1 = { 'client_type': 1245441508, 'data': (16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 'sequence_number': 55140, 'type': 204, 'window': 1260504694, } self.evt_bin_1 = b'\xcc\x10\xd7\x64' b'\x4b\x21\xc6\x76' \ b'\x4a\x3b\xed\xe4' b'\x00\x01\x00\x02' \ b'\x00\x03\x00\x04' b'\x00\x05\x00\x06' \ b'\x00\x07\x00\x08' b'\x00\x09\x00\x0a' self.evt_args_2 = { 'client_type': 959018764, 'data': (32, [1, 2, 3, 4, 5]), 'sequence_number': 56961, 'type': 253, 'window': 319171761, } self.evt_bin_2 = b'\xfd\x20\xde\x81' b'\x13\x06\x2c\xb1' \ b'\x39\x29\x77\x0c' b'\x00\x00\x00\x01' \ b'\x00\x00\x00\x02' b'\x00\x00\x00\x03' \ b'\x00\x00\x00\x04' b'\x00\x00\x00\x05' def testPack0(self): bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) def testPack1(self): bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_1) self.assertBinaryEqual(bin, self.evt_bin_1) def testUnpack1(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_1) def testPack2(self): bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_2) self.assertBinaryEqual(bin, self.evt_bin_2) def testUnpack2(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_2, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_2) class TestMappingNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'count': 244, 'first_keycode': 224, 'request': 213, 'sequence_number': 22874, 'type': 251, } self.evt_bin_0 = b'\xfb\x00\x59\x5a' b'\xd5\xe0\xf4\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.MappingNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.MappingNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) if __name__ == "__main__": unittest.main() python-xlib-0.33/test/test_events_le.py000077500000000000000000000524661435211557500203200ustar00rootroot00000000000000#!/usr/bin/env python2 import sys, os sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest from Xlib.protocol import request, event from . import LittleEndianTest as EndianTest from . import DummyDisplay dummy_display = DummyDisplay() class TestKeymapNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'data': [248, 202, 136, 187, 201, 200, 244, 146, 187, 195, 178, 236, 157, 185, 166, 196, 164, 146, 143, 170, 206, 201, 240, 159, 247, 205, 231, 197, 254, 240, 148], 'type': 138, } self.evt_bin_0 = b'\x8a\xf8\xca\x88' b'\xbb\xc9\xc8\xf4' \ b'\x92\xbb\xc3\xb2' b'\xec\x9d\xb9\xa6' \ b'\xc4\xa4\x92\x8f' b'\xaa\xce\xc9\xf0' \ b'\x9f\xf7\xcd\xe7' b'\xc5\xfe\xf0\x94' def testPack0(self): bin = event.KeymapNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.KeymapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestExpose(EndianTest): def setUp(self): self.evt_args_0 = { 'count': 15258, 'height': 6241, 'sequence_number': 48394, 'type': 238, 'width': 1951, 'window': 692245859, 'x': 39820, 'y': 16664, } self.evt_bin_0 = b'\xee\x00\x0a\xbd' b'\x63\xd5\x42\x29' \ b'\x8c\x9b\x18\x41' b'\x9f\x07\x61\x18' \ b'\x9a\x3b\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.Expose._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.Expose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestGraphicsExpose(EndianTest): def setUp(self): self.evt_args_0 = { 'count': 49818, 'drawable': 1443779242, 'height': 2892, 'major_event': 172, 'minor_event': 50267, 'sequence_number': 50375, 'type': 133, 'width': 38020, 'x': 54088, 'y': 17918, } self.evt_bin_0 = b'\x85\x00\xc7\xc4' b'\xaa\x52\x0e\x56' \ b'\x48\xd3\xfe\x45' b'\x84\x94\x4c\x0b' \ b'\x5b\xc4\x9a\xc2' b'\xac\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.GraphicsExpose._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.GraphicsExpose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestNoExpose(EndianTest): def setUp(self): self.evt_args_0 = { 'major_event': 199, 'minor_event': 29237, 'sequence_number': 34266, 'type': 248, 'window': 1399171519, } self.evt_bin_0 = b'\xf8\x00\xda\x85' b'\xbf\xa9\x65\x53' \ b'\x35\x72\xc7\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.NoExpose._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.NoExpose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestVisibilityNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 38616, 'state': 253, 'type': 174, 'window': 936121409, } self.evt_bin_0 = b'\xae\x00\xd8\x96' b'\x41\x14\xcc\x37' \ b'\xfd\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.VisibilityNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.VisibilityNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestCreateNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'border_width': 56468, 'height': 7111, 'override': 0, 'parent': 747306217, 'sequence_number': 31058, 'type': 151, 'width': 44173, 'window': 876986399, 'x': -21847, 'y': -22248, } self.evt_bin_0 = b'\x97\x00\x52\x79' b'\xe9\xfc\x8a\x2c' \ b'\x1f\xc0\x45\x34' b'\xa9\xaa\x18\xa9' \ b'\x8d\xac\xc7\x1b' b'\x94\xdc\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.CreateNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.CreateNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestDestroyNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'event': 1489718405, 'sequence_number': 27233, 'type': 212, 'window': 1064077163, } self.evt_bin_0 = b'\xd4\x00\x61\x6a' b'\x85\x4c\xcb\x58' \ b'\x6b\x87\x6c\x3f' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.DestroyNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.DestroyNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestUnmapNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'event': 2029853215, 'from_configure': 0, 'sequence_number': 43679, 'type': 201, 'window': 860030193, } self.evt_bin_0 = b'\xc9\x00\x9f\xaa' b'\x1f\x1a\xfd\x78' \ b'\xf1\x04\x43\x33' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.UnmapNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.UnmapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestMapNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'event': 675485985, 'override': 1, 'sequence_number': 6027, 'type': 244, 'window': 542087937, } self.evt_bin_0 = b'\xf4\x00\x8b\x17' b'\x21\x19\x43\x28' \ b'\x01\x9b\x4f\x20' b'\x01\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.MapNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.MapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestMapRequest(EndianTest): def setUp(self): self.evt_args_0 = { 'parent': 1659099581, 'sequence_number': 63838, 'type': 157, 'window': 868024861, } self.evt_bin_0 = b'\x9d\x00\x5e\xf9' b'\xbd\xd9\xe3\x62' \ b'\x1d\x02\xbd\x33' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.MapRequest._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.MapRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestReparentNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'event': 1867017989, 'override': 0, 'parent': 992152190, 'sequence_number': 43356, 'type': 128, 'window': 1165276406, 'x': -19227, 'y': -30992, } self.evt_bin_0 = b'\x80\x00\x5c\xa9' b'\x05\x6f\x48\x6f' \ b'\xf6\xb4\x74\x45' b'\x7e\x0a\x23\x3b' \ b'\xe5\xb4\xf0\x86' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ReparentNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ReparentNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestConfigureNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'above_sibling': 1343120585, 'border_width': 17757, 'event': 1624514845, 'height': 13596, 'override': 0, 'sequence_number': 41060, 'type': 220, 'width': 3638, 'window': 1070571314, 'x': -18284, 'y': -7865, } self.evt_bin_0 = b'\xdc\x00\x64\xa0' b'\x1d\x21\xd4\x60' \ b'\x32\x9f\xcf\x3f' b'\xc9\x64\x0e\x50' \ b'\x94\xb8\x47\xe1' b'\x36\x0e\x1c\x35' \ b'\x5d\x45\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ConfigureNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ConfigureNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestConfigureRequest(EndianTest): def setUp(self): self.evt_args_0 = { 'border_width': 52639, 'height': 40159, 'parent': 1499546058, 'sequence_number': 57983, 'sibling': 260826075, 'stack_mode': 240, 'type': 201, 'value_mask': 15938, 'width': 41545, 'window': 1040976198, 'x': -31823, 'y': -880, } self.evt_bin_0 = b'\xc9\xf0\x7f\xe2' b'\xca\x41\x61\x59' \ b'\x46\x09\x0c\x3e' b'\xdb\xe3\x8b\x0f' \ b'\xb1\x83\x90\xfc' b'\x49\xa2\xdf\x9c' \ b'\x9f\xcd\x42\x3e' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ConfigureRequest._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ConfigureRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestGravityNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'event': 1182983311, 'sequence_number': 20621, 'type': 168, 'window': 29431224, 'x': -14672, 'y': -19399, } self.evt_bin_0 = b'\xa8\x00\x8d\x50' b'\x8f\xe4\x82\x46' \ b'\xb8\x15\xc1\x01' b'\xb0\xc6\x39\xb4' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.GravityNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.GravityNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestResizeRequest(EndianTest): def setUp(self): self.evt_args_0 = { 'height': 60085, 'sequence_number': 14981, 'type': 151, 'width': 55398, 'window': 2130921516, } self.evt_bin_0 = b'\x97\x00\x85\x3a' b'\x2c\x48\x03\x7f' \ b'\x66\xd8\xb5\xea' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ResizeRequest._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ResizeRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestPropertyNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'atom': 252322161, 'sequence_number': 30497, 'state': 167, 'time': 1391011497, 'type': 157, 'window': 2033863003, } self.evt_bin_0 = b'\x9d\x00\x21\x77' b'\x5b\x49\x3a\x79' \ b'\x71\x21\x0a\x0f' b'\xa9\x26\xe9\x52' \ b'\xa7\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.PropertyNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.PropertyNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestSelectionClear(EndianTest): def setUp(self): self.evt_args_0 = { 'atom': 1092859866, 'sequence_number': 61378, 'time': 1538959461, 'type': 255, 'window': 626833463, } self.evt_bin_0 = b'\xff\x00\xc2\xef' b'\x65\xa8\xba\x5b' \ b'\x37\xb8\x5c\x25' b'\xda\xb7\x23\x41' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.SelectionClear._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.SelectionClear._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestSelectionRequest(EndianTest): def setUp(self): self.evt_args_0 = { 'owner': 1036225485, 'property': 981007010, 'requestor': 2105124856, 'selection': 1014149797, 'sequence_number': 27485, 'target': 523473665, 'time': 1792621552, 'type': 197, } self.evt_bin_0 = b'\xc5\x00\x5d\x6b' b'\xf0\x3b\xd9\x6a' \ b'\xcd\x8b\xc3\x3d' b'\xf8\xa7\x79\x7d' \ b'\xa5\xb2\x72\x3c' b'\x01\x93\x33\x1f' \ b'\xa2\xfa\x78\x3a' b'\x00\x00\x00\x00' def testPack0(self): bin = event.SelectionRequest._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.SelectionRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestSelectionNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'property': 1602716574, 'requestor': 1979762314, 'selection': 1287219120, 'sequence_number': 25394, 'target': 1091504539, 'time': 409398186, 'type': 165, } self.evt_bin_0 = b'\xa5\x00\x32\x63' b'\xaa\xeb\x66\x18' \ b'\x8a\xc6\x00\x76' b'\xb0\x67\xb9\x4c' \ b'\x9b\x09\x0f\x41' b'\x9e\x83\x87\x5f' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.SelectionNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.SelectionNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestColormapNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'colormap': 593302316, 'new': 1, 'sequence_number': 56880, 'state': 215, 'type': 162, 'window': 149981547, } self.evt_bin_0 = b'\xa2\x00\x30\xde' b'\x6b\x89\xf0\x08' \ b'\x2c\x13\x5d\x23' b'\x01\xd7\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ColormapNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ColormapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) class TestClientMessage(EndianTest): def setUp(self): self.evt_args_0 = { 'client_type': 607457628, 'data': (8, b'01234567890123456789'), 'sequence_number': 54031, 'type': 196, 'window': 5574388, } self.evt_bin_0 = b'\xc4\x08\x0f\xd3' b'\xf4\x0e\x55\x00' \ b'\x5c\x11\x35\x24' b'\x30\x31\x32\x33' \ b'\x34\x35\x36\x37' b'\x38\x39\x30\x31' \ b'\x32\x33\x34\x35' b'\x36\x37\x38\x39' self.evt_args_1 = { 'client_type': 1245441508, 'data': (16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 'sequence_number': 55140, 'type': 204, 'window': 1260504694, } self.evt_bin_1 = b'\xcc\x10\x64\xd7' b'\x76\xc6\x21\x4b' \ b'\xe4\xed\x3b\x4a' b'\x01\x00\x02\x00' \ b'\x03\x00\x04\x00' b'\x05\x00\x06\x00' \ b'\x07\x00\x08\x00' b'\x09\x00\x0a\x00' self.evt_args_2 = { 'client_type': 959018764, 'data': (32, [1, 2, 3, 4, 5]), 'sequence_number': 56961, 'type': 253, 'window': 319171761, } self.evt_bin_2 = b'\xfd\x20\x81\xde' b'\xb1\x2c\x06\x13' \ b'\x0c\x77\x29\x39' b'\x01\x00\x00\x00' \ b'\x02\x00\x00\x00' b'\x03\x00\x00\x00' \ b'\x04\x00\x00\x00' b'\x05\x00\x00\x00' def testPack0(self): bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) def testPack1(self): bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_1) self.assertBinaryEqual(bin, self.evt_bin_1) def testUnpack1(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_1) def testPack2(self): bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_2) self.assertBinaryEqual(bin, self.evt_bin_2) def testUnpack2(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_2, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_2) class TestMappingNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'count': 244, 'first_keycode': 224, 'request': 213, 'sequence_number': 22874, 'type': 251, } self.evt_bin_0 = b'\xfb\x00\x5a\x59' b'\xd5\xe0\xf4\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.MappingNotify._fields.to_binary(*(), **self.evt_args_0) self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.MappingNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.evt_args_0) if __name__ == "__main__": unittest.main() python-xlib-0.33/test/test_manual.py000066400000000000000000000031711435211557500175730ustar00rootroot00000000000000#!/usr/bin/env python import sys, os sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import unittest from Xlib.protocol import rq class Custom(rq.Card32): def check_value(self, value): return int(value) def parse_value(self, value, display): return str(value) CustomObj = Custom(None) class TestNestedStruct(unittest.TestCase): def setUp(self): self.s1 = rq.Struct(rq.Card32('a1'), rq.Card32('a2')) self.s2 = rq.Struct(rq.Object('b1', self.s1), rq.Object('b2', self.s1)) self.s3 = rq.Struct(rq.Object('c1', self.s2), rq.Object('c2', self.s2)) def testToBinary1(self): self.s1.to_binary(1, 2) def testToBinary2(self): self.s2.to_binary((1, 2), (3, 4)) def testToBinary3(self): self.s3.to_binary(((1, 2), (3, 4)), ((5, 6), (7, 8))) class TestNestedStructWithFancyValue(unittest.TestCase): def setUp(self): self.s1 = rq.Struct(Custom('a1'), Custom('a2')) self.s2 = rq.Struct(rq.Object('b1', self.s1), rq.Object('b2', self.s1)) self.s3 = rq.Struct(rq.Object('c1', self.s2), rq.Object('c2', self.s2)) def testToBinary1(self): self.s1.to_binary('1', '2') def testToBinary2(self): self.s2.to_binary(('1', '2'), ('3', '4')) def testToBinary3(self): self.s3.to_binary((('1', '2'), ('3', '4')), (('5', '6'), ('7', '8'))) class TestListWithFancyValue(unittest.TestCase): def setUp(self): self.s1 = rq.Struct(rq.LengthOf('l', 4), rq.List('l', CustomObj)) def testToBinary1(self): self.s1.to_binary(['1', '2', '3']) if __name__ == '__main__': unittest.main() python-xlib-0.33/test/test_rdb.py000066400000000000000000000071711435211557500170710ustar00rootroot00000000000000#!/usr/bin/env python import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import Xlib.rdb import unittest resources = """ ! Single component single: name Single: class ?: wild ! name vs class vs ? p.first.second: n.n p.first.Second: n.c p.first.?: n.w p.First.second: c.n p.First.Second: c.c p.First.?: c.w p.?.second: w.n p.?.Second: w.c p.?.?: w.w ! Tight over loose bindings b.tight.match: tight b.tight*match: bad b.loose*match: loose ! skip matches s.*end: default s.foo*end: default foo s.foo.bar.end: bar foo ! Multiple skip matches ss.*mid*end: default ss.foo*mid*end: default foo ss.foo*mid.bar*end: bar foo ! First component unbound *fie.fum: skipfirst fie.fum: matchtwo feh.fie.fum: matchfirst """ queries = ( # Single component ('single', 'Single', 'name'), ('noname', 'Single', 'class'), ('noname', 'Noclass', 'wild'), # Name vs class vs ? ('p.first.second', 'P.First.Second', 'n.n'), ('p.first.noname', 'P.First.Second', 'n.c'), ('p.first.noname', 'P.First.Noclass', 'n.w'), ('p.noname.second', 'P.First.Second', 'c.n'), ('p.noname.noname', 'P.First.Second', 'c.c'), ('p.noname.noname', 'P.First.Noclass', 'c.w'), ('p.noname.second', 'P.Noclass.Second', 'w.n'), ('p.noname.noname', 'P.Noclass.Second', 'w.c'), ('p.noname.noname', 'P.Noclass.Noclass', 'w.w'), # Tight over loose bindings ('b.tight.match', 'B.Tight.Match', 'tight'), ('b.loose.match', 'B.Loose.Match', 'loose'), # skip matches ('s.bar.end', 'S.Bar.End', 'default'), ('s.foo.bar.end', 'S.Foo.Bar.End', 'bar foo'), ('s.foo.gazonk.end', 'S.Foo.Gazonk.End', 'default foo'), # Multiple skip matches ('ss.x.mid.x.end', 'Ss.X.Mid.X.End', 'default'), ('ss.foo.x.mid.x.end', 'Ss.Foo.X.Mid.X.End', 'default foo'), ('ss.foo.x.mid.bar.x.end', 'Ss.Foo.X.Mid.Bar.X.End', 'bar foo'), ('ss.foo.mid.x.mid.bar.x.end', 'Ss.Foo.Mid.X.Mid.Bar.X.End', 'default foo'), ('ss.foo.x.mid.x.mid.bar.x.end', 'Ss.Foo.X.Mid.X.Mid.Bar.X.End', 'default foo'), # First component unbound ('fie.fum', 'Fie.Fum', 'matchtwo'), ('noname.fie.fum', 'Noclass.Fie.Fum', 'skipfirst'), ('feh.fie.fum', 'Feh.Fie.Fum', 'matchfirst'), ) resource_set1 = ( ('foo.bar', 1,), ('foo.bar.gazonk', 2), ('*bar*gazonk', 3), ) resource_set2 = ( ('foo.bar', 10,), # Changing the value of an item ('foo.bar.whee', 11), # Adding entries to existing component ('foo.bar*whoho', 12), ('foo.fie', 13), # Copy new resources ('foo.fie*fum', 14), ('*foo.bar', 15), ) class TestRDB(unittest.TestCase): def testParseAndQuery(self): # Test string parsing and querying db = Xlib.rdb.ResourceDB(string = resources) for name, cls, value in queries: try: v = db[name, cls] except KeyError: raise AssertionError('Value not found for %s/%s:\n expected %s' % (name, cls, value)) if v != value: raise AssertionError('Value mismatch for %s/%s:\n expected %s, got %s' % (name, cls, value, v)) def testUpdate(self): # Test update. An update should have the same result as # inserting all the resource entries in the manually db1 = Xlib.rdb.ResourceDB() db2 = Xlib.rdb.ResourceDB() db3 = Xlib.rdb.ResourceDB() db1.insert_resources(resource_set1) db2.insert_resources(resource_set2) db1.update(db2) db3.insert_resources(resource_set1) db3.insert_resources(resource_set2) assert db1.db == db3.db if __name__ == '__main__': unittest.main() python-xlib-0.33/test/test_requests_be.py000077500000000000000000004455741435211557500206630ustar00rootroot00000000000000#!/usr/bin/env python2 import sys, os sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest from Xlib.protocol import request, event from . import BigEndianTest as EndianTest from . import DummyDisplay dummy_display = DummyDisplay() class TestCreateWindow(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'cursor': 64054583, 'override_redirect': 0, 'bit_gravity': 3, 'event_mask': 1268138548, 'border_pixel': 1592533117, 'background_pixel': 239147199, 'save_under': 0, 'colormap': 68318329, 'do_not_propagate_mask': 906135756, 'backing_store': 0, 'win_gravity': 2, 'backing_planes': 299720948, 'border_pixmap': 53775720, 'backing_pixel': 1581625428, 'background_pixmap': 1373224142}, 'border_width': 13287, 'depth': 151, 'height': 37037, 'parent': 499701004, 'visual': 1395681732, 'wid': 469587013, 'width': 1995, 'window_class': 2, 'x': -16209, 'y': -13042, } self.req_bin_0 = b'\x01\x97\x00\x17' b'\x1b\xfd\x54\x45' \ b'\x1d\xc8\xd5\x0c' b'\xc0\xaf\xcd\x0e' \ b'\x07\xcb\x90\xad' b'\x33\xe7\x00\x02' \ b'\x53\x30\x69\xc4' b'\x00\x00\x7f\xff' \ b'\x51\xd9\xbc\xce' b'\x0e\x41\x18\xbf' \ b'\x03\x34\x8d\x68' b'\x5e\xec\x20\x7d' \ b'\x03\x00\x00\x00' b'\x02\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x11\xdd\x60\xf4' \ b'\x5e\x45\xb0\x54' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x4b\x96\x42\x34' \ b'\x36\x02\x88\xcc' b'\x04\x12\x74\x79' \ b'\x03\xd1\x65\x37' def testPackRequest0(self): bin = request.CreateWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestChangeWindowAttributes(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'cursor': 596789700, 'override_redirect': 0, 'bit_gravity': 6, 'event_mask': 1499308477, 'border_pixel': 473458160, 'background_pixel': 1170318459, 'save_under': 0, 'colormap': 730747963, 'do_not_propagate_mask': 907623048, 'backing_store': 1, 'win_gravity': 8, 'backing_planes': 1738304197, 'border_pixmap': 900977490, 'backing_pixel': 1866873765, 'background_pixmap': 1506149446}, 'window': 333955224, } self.req_bin_0 = b'\x02\x00\x00\x12' b'\x13\xe7\xc0\x98' \ b'\x00\x00\x7f\xff' b'\x59\xc6\x04\x46' \ b'\x45\xc1\xa4\x7b' b'\x35\xb3\xd3\x52' \ b'\x1c\x38\x65\xf0' b'\x06\x00\x00\x00' \ b'\x08\x00\x00\x00' b'\x01\x00\x00\x00' \ b'\x67\x9c\x6a\xc5' b'\x6f\x46\x3b\xa5' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x59\x5d\xa1\xbd' b'\x36\x19\x3a\x88' \ b'\x2b\x8e\x54\x3b' b'\x23\x92\x49\xc4' def testPackRequest0(self): bin = request.ChangeWindowAttributes._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetWindowAttributes(EndianTest): def setUp(self): self.req_args_0 = { 'window': 462448317, } self.req_bin_0 = b'\x03\x00\x00\x02' b'\x1b\x90\x66\xbd' self.reply_args_0 = { 'all_event_masks': 1980679760, 'backing_bit_planes': 1820045833, 'backing_pixel': 738704824, 'backing_store': 214, 'bit_gravity': 152, 'colormap': 2089815718, 'do_not_propagate_mask': 5420, 'map_is_installed': 0, 'map_state': 245, 'override_redirect': 0, 'save_under': 1, 'sequence_number': 6954, 'visual': 199235720, 'win_class': 25154, 'win_gravity': 219, 'your_event_mask': 812961929, } self.reply_bin_0 = b'\x01\xd6\x1b\x2a' b'\x00\x00\x00\x03' \ b'\x0b\xe0\x18\x88' b'\x62\x42\x98\xdb' \ b'\x6c\x7b\xb2\x09' b'\x2c\x07\xbd\xb8' \ b'\x01\x00\xf5\x00' b'\x7c\x90\x0e\xa6' \ b'\x76\x0e\xc6\x50' b'\x30\x74\xd0\x89' \ b'\x15\x2c\x00\x00' def testPackRequest0(self): bin = request.GetWindowAttributes._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetWindowAttributes._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetWindowAttributes._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestDestroyWindow(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1185563768, } self.req_bin_0 = b'\x04\x00\x00\x02' b'\x46\xaa\x44\x78' def testPackRequest0(self): bin = request.DestroyWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.DestroyWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestDestroySubWindows(EndianTest): def setUp(self): self.req_args_0 = { 'window': 629661088, } self.req_bin_0 = b'\x05\x00\x00\x02' b'\x25\x87\xdd\xa0' def testPackRequest0(self): bin = request.DestroySubWindows._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.DestroySubWindows._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestChangeSaveSet(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 1, 'window': 1239919839, } self.req_bin_0 = b'\x06\x01\x00\x02' b'\x49\xe7\xac\xdf' def testPackRequest0(self): bin = request.ChangeSaveSet._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeSaveSet._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestReparentWindow(EndianTest): def setUp(self): self.req_args_0 = { 'parent': 1513122040, 'window': 413002134, 'x': -30489, 'y': -31267, } self.req_bin_0 = b'\x07\x00\x00\x04' b'\x18\x9d\xe9\x96' \ b'\x5a\x30\x68\xf8' b'\x88\xe7\x85\xdd' def testPackRequest0(self): bin = request.ReparentWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ReparentWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestMapWindow(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1420117708, } self.req_bin_0 = b'\x08\x00\x00\x02' b'\x54\xa5\x46\xcc' def testPackRequest0(self): bin = request.MapWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.MapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestMapSubwindows(EndianTest): def setUp(self): self.req_args_0 = { 'window': 489473351, } self.req_bin_0 = b'\x09\x00\x00\x02' b'\x1d\x2c\xc5\x47' def testPackRequest0(self): bin = request.MapSubwindows._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.MapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestUnmapWindow(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1660217157, } self.req_bin_0 = b'\x0a\x00\x00\x02' b'\x62\xf4\xe7\x45' def testPackRequest0(self): bin = request.UnmapWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UnmapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestUnmapSubwindows(EndianTest): def setUp(self): self.req_args_0 = { 'window': 621521446, } self.req_bin_0 = b'\x0b\x00\x00\x02' b'\x25\x0b\xaa\x26' def testPackRequest0(self): bin = request.UnmapSubwindows._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UnmapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestConfigureWindow(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'width': 39387, 'stack_mode': 2, 'height': 57679, 'sibling': 973756745, 'y': -17512, 'x': -27539, 'border_width': -14551}, 'window': 349362548, } self.req_bin_0 = b'\x0c\x00\x00\x0a' b'\x14\xd2\xd9\x74' \ b'\x00\x7f\x00\x00' b'\x94\x6d\x00\x00' \ b'\xbb\x98\x00\x00' b'\x99\xdb\x00\x00' \ b'\xe1\x4f\x00\x00' b'\xc7\x29\x00\x00' \ b'\x3a\x0a\x59\x49' b'\x02\x00\x00\x00' def testPackRequest0(self): bin = request.ConfigureWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ConfigureWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCirculateWindow(EndianTest): def setUp(self): self.req_args_0 = { 'direction': 1, 'window': 763003561, } self.req_bin_0 = b'\x0d\x01\x00\x02' b'\x2d\x7a\x82\xa9' def testPackRequest0(self): bin = request.CirculateWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CirculateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetGeometry(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 449978455, } self.req_bin_0 = b'\x0e\x00\x00\x02' b'\x1a\xd2\x20\x57' self.reply_args_0 = { 'border_width': 41869, 'depth': 196, 'height': 40176, 'root': 2011515940, 'sequence_number': 46250, 'width': 4935, 'x': -10370, 'y': -11534, } self.reply_bin_0 = b'\x01\xc4\xb4\xaa' b'\x00\x00\x00\x00' \ b'\x77\xe5\x4c\x24' b'\xd7\x7e\xd2\xf2' \ b'\x13\x47\x9c\xf0' b'\xa3\x8d\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetGeometry._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetGeometry._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetGeometry._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetGeometry._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestQueryTree(EndianTest): def setUp(self): self.req_args_0 = { 'window': 367582976, } self.req_bin_0 = b'\x0f\x00\x00\x02' b'\x15\xe8\xdf\x00' self.reply_args_0 = { 'children': [1147122179, 1565853418, 525792997, 350969719, 992761785, 814939899, 579774073], 'parent': 1374454548, 'root': 1987327953, 'sequence_number': 65105, } self.reply_bin_0 = b'\x01\x00\xfe\x51' b'\x00\x00\x00\x07' \ b'\x76\x74\x37\xd1' b'\x51\xec\x83\x14' \ b'\x00\x07\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x44\x5f\xb2\x03' b'\x5d\x55\x06\xea' \ b'\x1f\x56\xf6\xe5' b'\x14\xeb\x5f\x77' \ b'\x3b\x2c\x57\xb9' b'\x30\x92\xfe\xfb' \ b'\x22\x8e\xa6\x79' def testPackRequest0(self): bin = request.QueryTree._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryTree._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryTree._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryTree._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestInternAtom(EndianTest): def setUp(self): self.req_args_0 = { 'name': 'fuzzy_prop', 'only_if_exists': 0, } self.req_bin_0 = b'\x10\x00\x00\x05' b'\x00\x0a\x00\x00' \ b'\x66\x75\x7a\x7a' b'\x79\x5f\x70\x72' \ b'\x6f\x70\x00\x00' self.reply_args_0 = { 'atom': 696457407, 'sequence_number': 45122, } self.reply_bin_0 = b'\x01\x00\xb0\x42' b'\x00\x00\x00\x00' \ b'\x29\x83\x18\xbf' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.InternAtom._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.InternAtom._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.InternAtom._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.InternAtom._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestGetAtomName(EndianTest): def setUp(self): self.req_args_0 = { 'atom': 1810076242, } self.req_bin_0 = b'\x11\x00\x00\x02' b'\x6b\xe3\x92\x52' self.reply_args_0 = { 'name': 'WM_CLASS', 'sequence_number': 50608, } self.reply_bin_0 = b'\x01\x00\xc5\xb0' b'\x00\x00\x00\x02' \ b'\x00\x08\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x57\x4d\x5f\x43' b'\x4c\x41\x53\x53' def testPackRequest0(self): bin = request.GetAtomName._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetAtomName._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetAtomName._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetAtomName._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestChangeProperty(EndianTest): def setUp(self): self.req_args_0 = { 'data': (8, b''), 'mode': 0, 'property': 1764873173, 'type': 69000273, 'window': 491942524, } self.req_bin_0 = b'\x12\x00\x00\x06' b'\x1d\x52\x72\x7c' \ b'\x69\x31\xd3\xd5' b'\x04\x1c\xdc\x51' \ b'\x08\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_1 = { 'data': (8, b'foo'), 'mode': 1, 'property': 575034703, 'type': 142204480, 'window': 861560365, } self.req_bin_1 = b'\x12\x01\x00\x07' b'\x33\x5a\x5e\x2d' \ b'\x22\x46\x55\x4f' b'\x08\x79\xde\x40' \ b'\x08\x00\x00\x00' b'\x00\x00\x00\x03' \ b'\x66\x6f\x6f\x00' self.req_args_2 = { 'data': (8, b'zoom'), 'mode': 0, 'property': 2024948722, 'type': 1218075423, 'window': 1961010416, } self.req_bin_2 = b'\x12\x00\x00\x07' b'\x74\xe2\xa4\xf0' \ b'\x78\xb2\x43\xf2' b'\x48\x9a\x5b\x1f' \ b'\x08\x00\x00\x00' b'\x00\x00\x00\x04' \ b'\x7a\x6f\x6f\x6d' self.req_args_3 = { 'data': (16, []), 'mode': 2, 'property': 456677559, 'type': 1407609354, 'window': 675831147, } self.req_bin_3 = b'\x12\x02\x00\x06' b'\x28\x48\x5d\x6b' \ b'\x1b\x38\x58\xb7' b'\x53\xe6\x6a\x0a' \ b'\x10\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_4 = { 'data': (16, [1, 2, 3]), 'mode': 1, 'property': 1899908134, 'type': 1964041522, 'window': 849678568, } self.req_bin_4 = b'\x12\x01\x00\x08' b'\x32\xa5\x10\xe8' \ b'\x71\x3e\x4c\x26' b'\x75\x10\xe5\x32' \ b'\x10\x00\x00\x00' b'\x00\x00\x00\x03' \ b'\x00\x01\x00\x02' b'\x00\x03\x00\x00' self.req_args_5 = { 'data': (16, [1, 2, 3, 4]), 'mode': 2, 'property': 306879937, 'type': 568891375, 'window': 985442388, } self.req_bin_5 = b'\x12\x02\x00\x08' b'\x3a\xbc\xa8\x54' \ b'\x12\x4a\x9d\xc1' b'\x21\xe8\x97\xef' \ b'\x10\x00\x00\x00' b'\x00\x00\x00\x04' \ b'\x00\x01\x00\x02' b'\x00\x03\x00\x04' self.req_args_6 = { 'data': (32, []), 'mode': 0, 'property': 1599917196, 'type': 1205594429, 'window': 529694076, } self.req_bin_6 = b'\x12\x00\x00\x06' b'\x1f\x92\x7d\x7c' \ b'\x5f\x5c\xcc\x8c' b'\x47\xdb\xe9\x3d' \ b'\x20\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_7 = { 'data': (32, [1, 2, 3]), 'mode': 2, 'property': 1604265475, 'type': 1255454396, 'window': 564298846, } self.req_bin_7 = b'\x12\x02\x00\x09' b'\x21\xa2\x84\x5e' \ b'\x5f\x9f\x26\x03' b'\x4a\xd4\xb6\xbc' \ b'\x20\x00\x00\x00' b'\x00\x00\x00\x03' \ b'\x00\x00\x00\x01' b'\x00\x00\x00\x02' \ b'\x00\x00\x00\x03' def testPackRequest0(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_1) self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_1) def testPackRequest2(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_2) self.assertBinaryEqual(bin, self.req_bin_2) def testUnpackRequest2(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_2, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_2) def testPackRequest3(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_3) self.assertBinaryEqual(bin, self.req_bin_3) def testUnpackRequest3(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_3, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_3) def testPackRequest4(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_4) self.assertBinaryEqual(bin, self.req_bin_4) def testUnpackRequest4(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_4, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_4) def testPackRequest5(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_5) self.assertBinaryEqual(bin, self.req_bin_5) def testUnpackRequest5(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_5, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_5) def testPackRequest6(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_6) self.assertBinaryEqual(bin, self.req_bin_6) def testUnpackRequest6(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_6, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_6) def testPackRequest7(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_7) self.assertBinaryEqual(bin, self.req_bin_7) def testUnpackRequest7(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_7, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_7) class TestDeleteProperty(EndianTest): def setUp(self): self.req_args_0 = { 'property': 1928125498, 'window': 920120163, } self.req_bin_0 = b'\x13\x00\x00\x03' b'\x36\xd7\xeb\x63' \ b'\x72\xec\xdc\x3a' def testPackRequest0(self): bin = request.DeleteProperty._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.DeleteProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetProperty(EndianTest): def setUp(self): self.req_args_0 = { 'delete': 1, 'long_length': 297130690, 'long_offset': 2142261240, 'property': 471053276, 'type': 2141806322, 'window': 777446987, } self.req_bin_0 = b'\x14\x01\x00\x06' b'\x2e\x56\xe6\x4b' \ b'\x1c\x13\xb3\xdc' b'\x7f\xa9\x5e\xf2' \ b'\x7f\xb0\x4f\xf8' b'\x11\xb5\xda\xc2' self.reply_args_0 = { 'bytes_after': 195292012, 'property_type': 1059882735, 'sequence_number': 33648, 'value': (8, b''), } self.reply_bin_0 = b'\x01\x08\x83\x70' b'\x00\x00\x00\x00' \ b'\x3f\x2c\x86\xef' b'\x0b\xa3\xeb\x6c' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_1 = { 'bytes_after': 1849269963, 'property_type': 101247178, 'sequence_number': 49786, 'value': (8, b'foo'), } self.reply_bin_1 = b'\x01\x08\xc2\x7a' b'\x00\x00\x00\x01' \ b'\x06\x08\xe8\xca' b'\x6e\x39\x9e\xcb' \ b'\x00\x00\x00\x03' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x66\x6f\x6f\x00' self.reply_args_2 = { 'bytes_after': 1347495650, 'property_type': 328289775, 'sequence_number': 7441, 'value': (8, b'zoom'), } self.reply_bin_2 = b'\x01\x08\x1d\x11' b'\x00\x00\x00\x01' \ b'\x13\x91\x4d\xef' b'\x50\x51\x26\xe2' \ b'\x00\x00\x00\x04' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x7a\x6f\x6f\x6d' self.reply_args_3 = { 'bytes_after': 1461387818, 'property_type': 1701043014, 'sequence_number': 10740, 'value': (16, []), } self.reply_bin_3 = b'\x01\x10\x29\xf4' b'\x00\x00\x00\x00' \ b'\x65\x63\xdb\x46' b'\x57\x1b\x02\x2a' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_4 = { 'bytes_after': 136490248, 'property_type': 1280844186, 'sequence_number': 27922, 'value': (16, [1, 2, 3]), } self.reply_bin_4 = b'\x01\x10\x6d\x12' b'\x00\x00\x00\x02' \ b'\x4c\x58\x21\x9a' b'\x08\x22\xad\x08' \ b'\x00\x00\x00\x03' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x01\x00\x02' b'\x00\x03\x00\x00' self.reply_args_5 = { 'bytes_after': 1279726180, 'property_type': 819586705, 'sequence_number': 25472, 'value': (16, [1, 2, 3, 4]), } self.reply_bin_5 = b'\x01\x10\x63\x80' b'\x00\x00\x00\x02' \ b'\x30\xd9\xe6\x91' b'\x4c\x47\x12\x64' \ b'\x00\x00\x00\x04' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x01\x00\x02' b'\x00\x03\x00\x04' self.reply_args_6 = { 'bytes_after': 539973238, 'property_type': 1136329940, 'sequence_number': 30930, 'value': (32, []), } self.reply_bin_6 = b'\x01\x20\x78\xd2' b'\x00\x00\x00\x00' \ b'\x43\xbb\x04\xd4' b'\x20\x2f\x56\x76' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_7 = { 'bytes_after': 1848575862, 'property_type': 1188109101, 'sequence_number': 63896, 'value': (32, [1, 2, 3]), } self.reply_bin_7 = b'\x01\x20\xf9\x98' b'\x00\x00\x00\x03' \ b'\x46\xd1\x1b\x2d' b'\x6e\x2f\x07\x76' \ b'\x00\x00\x00\x03' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x01' b'\x00\x00\x00\x02' \ b'\x00\x00\x00\x03' def testPackRequest0(self): bin = request.GetProperty._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) def testPackReply1(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_1) self.assertBinaryEqual(bin, self.reply_bin_1) def testUnpackReply1(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_1) def testPackReply2(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_2) self.assertBinaryEqual(bin, self.reply_bin_2) def testUnpackReply2(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_2, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_2) def testPackReply3(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_3) self.assertBinaryEqual(bin, self.reply_bin_3) def testUnpackReply3(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_3, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_3) def testPackReply4(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_4) self.assertBinaryEqual(bin, self.reply_bin_4) def testUnpackReply4(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_4, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_4) def testPackReply5(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_5) self.assertBinaryEqual(bin, self.reply_bin_5) def testUnpackReply5(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_5, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_5) def testPackReply6(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_6) self.assertBinaryEqual(bin, self.reply_bin_6) def testUnpackReply6(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_6, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_6) def testPackReply7(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_7) self.assertBinaryEqual(bin, self.reply_bin_7) def testUnpackReply7(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_7, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_7) class TestListProperties(EndianTest): def setUp(self): self.req_args_0 = { 'window': 2023920407, } self.req_bin_0 = b'\x15\x00\x00\x02' b'\x78\xa2\x93\x17' self.reply_args_0 = { 'atoms': [24720840, 1460963027, 1547803868, 246063525, 1464027403, 1900134270, 1153200538, 1612563336, 573068260, 1650618737, 1376520521, 730586807, 239622004, 630352260, 933716813, 339706725, 974429777, 7034796, 2048369638, 1550746425, 1880945398, 1545568005, 565689201], 'sequence_number': 63949, } self.reply_bin_0 = b'\x01\x00\xf9\xcd' b'\x00\x00\x00\x17' \ b'\x00\x17\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x01\x79\x35\xc8' b'\x57\x14\x86\xd3' \ b'\x5c\x41\x9c\xdc' b'\x0e\xaa\xa1\xa5' \ b'\x57\x43\x49\x0b' b'\x71\x41\xbf\x7e' \ b'\x44\xbc\x71\x9a' b'\x60\x1d\xc3\x88' \ b'\x22\x28\x53\xe4' b'\x62\x62\x71\x71' \ b'\x52\x0c\x09\x49' b'\x2b\x8b\xde\xb7' \ b'\x0e\x48\x57\x74' b'\x25\x92\x69\x84' \ b'\x37\xa7\x63\x4d' b'\x14\x3f\x83\x65' \ b'\x3a\x14\x9e\x51' b'\x00\x6b\x57\xac' \ b'\x7a\x17\xa3\xe6' b'\x5c\x6e\x83\x39' \ b'\x70\x1c\xf2\xf6' b'\x5c\x1f\x7f\x05' \ b'\x21\xb7\xbb\x71' def testPackRequest0(self): bin = request.ListProperties._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListProperties._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListProperties._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListProperties._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestSetSelectionOwner(EndianTest): def setUp(self): self.req_args_0 = { 'selection': 1636366903, 'time': 383717530, 'window': 1075066031, } self.req_bin_0 = b'\x16\x00\x00\x04' b'\x40\x14\x34\xaf' \ b'\x61\x88\xfa\x37' b'\x16\xdf\x10\x9a' def testPackRequest0(self): bin = request.SetSelectionOwner._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetSelectionOwner(EndianTest): def setUp(self): self.req_args_0 = { 'selection': 1090303630, } self.req_bin_0 = b'\x17\x00\x00\x02' b'\x40\xfc\xb6\x8e' self.reply_args_0 = { 'owner': 228581038, 'sequence_number': 60065, } self.reply_bin_0 = b'\x01\x00\xea\xa1' b'\x00\x00\x00\x00' \ b'\x0d\x9f\xde\xae' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetSelectionOwner._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetSelectionOwner._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetSelectionOwner._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestConvertSelection(EndianTest): def setUp(self): self.req_args_0 = { 'property': 1807536699, 'requestor': 1869489931, 'selection': 1342887479, 'target': 640970836, 'time': 1372199123, } self.req_bin_0 = b'\x18\x00\x00\x06' b'\x6f\x6e\x27\x0b' \ b'\x50\x0a\xd6\x37' b'\x26\x34\x70\x54' \ b'\x6b\xbc\xd2\x3b' b'\x51\xca\x18\xd3' def testPackRequest0(self): bin = request.ConvertSelection._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ConvertSelection._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestSendEvent(EndianTest): def setUp(self): self.req_args_0 = { 'destination': 1158373169, 'event': event.Expose(count=50227, height=24760, sequence_number=0, type=12, width=10272, window=1090263274, x=40165, y=13291), 'event_mask': 2047690655, 'propagate': 0, } self.req_bin_0 = b'\x19\x00\x00\x0b' b'\x45\x0b\x5f\x31' \ b'\x7a\x0d\x47\x9f' b'\x0c\x00\x00\x00' \ b'\x40\xfc\x18\xea' b'\x9c\xe5\x33\xeb' \ b'\x28\x20\x60\xb8' b'\xc4\x33\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SendEvent._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SendEvent._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGrabPointer(EndianTest): def setUp(self): self.req_args_0 = { 'confine_to': 240299645, 'cursor': 1995289624, 'event_mask': 21499, 'grab_window': 1286289242, 'keyboard_mode': 0, 'owner_events': 0, 'pointer_mode': 1, 'time': 779560794, } self.req_bin_0 = b'\x1a\x00\x00\x06' b'\x4c\xab\x37\x5a' \ b'\x53\xfb\x01\x00' b'\x0e\x52\xae\x7d' \ b'\x76\xed\xb4\x18' b'\x2e\x77\x27\x5a' self.reply_args_0 = { 'sequence_number': 15948, 'status': 206, } self.reply_bin_0 = b'\x01\xce\x3e\x4c' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GrabPointer._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GrabPointer._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GrabPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestUngrabPointer(EndianTest): def setUp(self): self.req_args_0 = { 'time': 124458893, } self.req_bin_0 = b'\x1b\x00\x00\x02' b'\x07\x6b\x17\x8d' def testPackRequest0(self): bin = request.UngrabPointer._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGrabButton(EndianTest): def setUp(self): self.req_args_0 = { 'button': 145, 'confine_to': 1571825127, 'cursor': 1043722096, 'event_mask': 37438, 'grab_window': 1885576796, 'keyboard_mode': 0, 'modifiers': 64349, 'owner_events': 0, 'pointer_mode': 0, } self.req_bin_0 = b'\x1c\x00\x00\x06' b'\x70\x63\x9e\x5c' \ b'\x92\x3e\x00\x00' b'\x5d\xb0\x25\xe7' \ b'\x3e\x35\xef\x70' b'\x91\x00\xfb\x5d' def testPackRequest0(self): bin = request.GrabButton._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestUngrabButton(EndianTest): def setUp(self): self.req_args_0 = { 'button': 160, 'grab_window': 275784110, 'modifiers': 43493, } self.req_bin_0 = b'\x1d\xa0\x00\x03' b'\x10\x70\x21\xae' \ b'\xa9\xe5\x00\x00' def testPackRequest0(self): bin = request.UngrabButton._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestChangeActivePointerGrab(EndianTest): def setUp(self): self.req_args_0 = { 'cursor': 1020726671, 'event_mask': 36287, 'time': 2033407590, } self.req_bin_0 = b'\x1e\x00\x00\x04' b'\x3c\xd7\x0d\x8f' \ b'\x79\x33\x56\x66' b'\x8d\xbf\x00\x00' def testPackRequest0(self): bin = request.ChangeActivePointerGrab._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeActivePointerGrab._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGrabKeyboard(EndianTest): def setUp(self): self.req_args_0 = { 'grab_window': 569270305, 'keyboard_mode': 0, 'owner_events': 0, 'pointer_mode': 1, 'time': 1133236353, } self.req_bin_0 = b'\x1f\x00\x00\x04' b'\x21\xee\x60\x21' \ b'\x43\x8b\xd0\x81' b'\x01\x00\x00\x00' self.reply_args_0 = { 'sequence_number': 46979, 'status': 179, } self.reply_bin_0 = b'\x01\xb3\xb7\x83' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GrabKeyboard._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GrabKeyboard._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GrabKeyboard._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestUngrabKeyboard(EndianTest): def setUp(self): self.req_args_0 = { 'time': 669471181, } self.req_bin_0 = b'\x20\x00\x00\x02' b'\x27\xe7\x51\xcd' def testPackRequest0(self): bin = request.UngrabKeyboard._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGrabKey(EndianTest): def setUp(self): self.req_args_0 = { 'grab_window': 2137132511, 'key': 223, 'keyboard_mode': 1, 'modifiers': 44275, 'owner_events': 1, 'pointer_mode': 1, } self.req_bin_0 = b'\x21\x01\x00\x04' b'\x7f\x62\x0d\xdf' \ b'\xac\xf3\xdf\x01' b'\x01\x00\x00\x00' def testPackRequest0(self): bin = request.GrabKey._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestUngrabKey(EndianTest): def setUp(self): self.req_args_0 = { 'grab_window': 532438798, 'key': 158, 'modifiers': 14981, } self.req_bin_0 = b'\x22\x9e\x00\x03' b'\x1f\xbc\x5f\x0e' \ b'\x3a\x85\x00\x00' def testPackRequest0(self): bin = request.UngrabKey._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestAllowEvents(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 1, 'time': 726098765, } self.req_bin_0 = b'\x23\x01\x00\x02' b'\x2b\x47\x63\x4d' def testPackRequest0(self): bin = request.AllowEvents._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllowEvents._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGrabServer(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x24\x00\x00\x01' def testPackRequest0(self): bin = request.GrabServer._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestUngrabServer(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x25\x00\x00\x01' def testPackRequest0(self): bin = request.UngrabServer._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestQueryPointer(EndianTest): def setUp(self): self.req_args_0 = { 'window': 45236268, } self.req_bin_0 = b'\x26\x00\x00\x02' b'\x02\xb2\x40\x2c' self.reply_args_0 = { 'child': 15507755, 'mask': 15259, 'root': 472978779, 'root_x': -30442, 'root_y': -9574, 'same_screen': 0, 'sequence_number': 38820, 'win_x': -12089, 'win_y': -30839, } self.reply_bin_0 = b'\x01\x00\x97\xa4' b'\x00\x00\x00\x00' \ b'\x1c\x31\x15\x5b' b'\x00\xec\xa1\x2b' \ b'\x89\x16\xda\x9a' b'\xd0\xc7\x87\x89' \ b'\x3b\x9b\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryPointer._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryPointer._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestGetMotionEvents(EndianTest): def setUp(self): self.req_args_0 = { 'start': 1944440211, 'stop': 67524349, 'window': 144806627, } self.req_bin_0 = b'\x27\x00\x00\x04' b'\x08\xa1\x92\xe3' \ b'\x73\xe5\xcd\x93' b'\x04\x06\x56\xfd' self.reply_args_0 = { 'events': [{'y': -30447, 'x': -21941, 'time': 1846118496}, {'y': -23643, 'x': -24970, 'time': 1104207400}, {'y': -25748, 'x': -16862, 'time': 1436684371}, {'y': -9066, 'x': -28433, 'time': 1158061593}, {'y': -14057, 'x': -3855, 'time': 2009067067}], 'sequence_number': 38018, } self.reply_bin_0 = b'\x01\x00\x94\x82' b'\x00\x00\x00\x0a' \ b'\x00\x00\x00\x05' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x6e\x09\x88\x60' b'\xaa\x4b\x89\x11' \ b'\x41\xd0\xde\x28' b'\x9e\x76\xa3\xa5' \ b'\x55\xa2\x10\x53' b'\xbe\x22\x9b\x6c' \ b'\x45\x06\x9e\x19' b'\x90\xef\xdc\x96' \ b'\x77\xbf\xee\x3b' b'\xf0\xf1\xc9\x17' def testPackRequest0(self): bin = request.GetMotionEvents._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetMotionEvents._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetMotionEvents._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetMotionEvents._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestTranslateCoords(EndianTest): def setUp(self): self.req_args_0 = { 'dst_wid': 521898132, 'src_wid': 1015118844, 'src_x': -7058, 'src_y': -17270, } self.req_bin_0 = b'\x28\x00\x00\x04' b'\x3c\x81\x7b\xfc' \ b'\x1f\x1b\x88\x94' b'\xe4\x6e\xbc\x8a' self.reply_args_0 = { 'child': 202628650, 'same_screen': 1, 'sequence_number': 12734, 'x': -29592, 'y': -11175, } self.reply_bin_0 = b'\x01\x01\x31\xbe' b'\x00\x00\x00\x00' \ b'\x0c\x13\xde\x2a' b'\x8c\x68\xd4\x59' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.TranslateCoords._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.TranslateCoords._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.TranslateCoords._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.TranslateCoords._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestWarpPointer(EndianTest): def setUp(self): self.req_args_0 = { 'dst_window': 760913775, 'dst_x': -8878, 'dst_y': -30993, 'src_height': 56868, 'src_width': 30862, 'src_window': 925740905, 'src_x': -18889, 'src_y': -19298, } self.req_bin_0 = b'\x29\x00\x00\x06' b'\x37\x2d\xaf\x69' \ b'\x2d\x5a\x9f\x6f' b'\xb6\x37\xb4\x9e' \ b'\x78\x8e\xde\x24' b'\xdd\x52\x86\xef' def testPackRequest0(self): bin = request.WarpPointer._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.WarpPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestSetInputFocus(EndianTest): def setUp(self): self.req_args_0 = { 'focus': 1403350503, 'revert_to': 2, 'time': 2113544232, } self.req_bin_0 = b'\x2a\x02\x00\x03' b'\x53\xa5\x6d\xe7' \ b'\x7d\xfa\x20\x28' def testPackRequest0(self): bin = request.SetInputFocus._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetInputFocus(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x2b\x00\x00\x01' self.reply_args_0 = { 'focus': 864688157, 'revert_to': 153, 'sequence_number': 4228, } self.reply_bin_0 = b'\x01\x99\x10\x84' b'\x00\x00\x00\x00' \ b'\x33\x8a\x18\x1d' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetInputFocus._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetInputFocus._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetInputFocus._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestQueryKeymap(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x2c\x00\x00\x01' self.reply_args_0 = { 'map': [214, 155, 191, 177, 176, 242, 163, 236, 174, 199, 246, 191, 147, 241, 153, 140, 131, 151, 188, 170, 232, 252, 251, 182, 230, 143, 170, 225, 128, 227, 195, 244], 'sequence_number': 18950, } self.reply_bin_0 = b'\x01\x00\x4a\x06' b'\x00\x00\x00\x02' \ b'\xd6\x9b\xbf\xb1' b'\xb0\xf2\xa3\xec' \ b'\xae\xc7\xf6\xbf' b'\x93\xf1\x99\x8c' \ b'\x83\x97\xbc\xaa' b'\xe8\xfc\xfb\xb6' \ b'\xe6\x8f\xaa\xe1' b'\x80\xe3\xc3\xf4' def testPackRequest0(self): bin = request.QueryKeymap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryKeymap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryKeymap._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryKeymap._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestOpenFont(EndianTest): def setUp(self): self.req_args_0 = { 'fid': 908467189, 'name': 'foofont', } self.req_bin_0 = b'\x2d\x00\x00\x05' b'\x36\x26\x1b\xf5' \ b'\x00\x07\x00\x00' b'\x66\x6f\x6f\x66' \ b'\x6f\x6e\x74\x00' def testPackRequest0(self): bin = request.OpenFont._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.OpenFont._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCloseFont(EndianTest): def setUp(self): self.req_args_0 = { 'font': 1495984396, } self.req_bin_0 = b'\x2e\x00\x00\x02' b'\x59\x2a\xe9\x0c' def testPackRequest0(self): bin = request.CloseFont._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CloseFont._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestQueryFont(EndianTest): def setUp(self): self.req_args_0 = { 'font': 2055889505, } self.req_bin_0 = b'\x2f\x00\x00\x02' b'\x7a\x8a\x62\x61' self.reply_args_0 = { 'all_chars_exist': 0, 'char_infos': [{'descent': -16821, 'right_side_bearing': -14557, 'character_width': -11080, 'left_side_bearing': -7099, 'attributes': 10400, 'ascent': -9228}, {'descent': -30852, 'right_side_bearing': -23046, 'character_width': -25635, 'left_side_bearing': -26546, 'attributes': 38213, 'ascent': -1026}, {'descent': -22492, 'right_side_bearing': -15002, 'character_width': -30771, 'left_side_bearing': -8660, 'attributes': 4002, 'ascent': -8259}], 'default_char': 39252, 'draw_direction': 145, 'font_ascent': -1914, 'font_descent': -3596, 'max_bounds': {'descent': -30143, 'right_side_bearing': -30905, 'character_width': -1286, 'left_side_bearing': -27610, 'attributes': 56049, 'ascent': -16128}, 'max_byte1': 231, 'max_char_or_byte2': 4746, 'min_bounds': {'descent': -4827, 'right_side_bearing': -17145, 'character_width': -16291, 'left_side_bearing': -13626, 'attributes': 35063, 'ascent': -2642}, 'min_byte1': 188, 'min_char_or_byte2': 12434, 'properties': [{'name': 1568813755, 'value': 2137719486}], 'sequence_number': 3542, } self.reply_bin_0 = b'\x01\x00\x0d\xd6' b'\x00\x00\x00\x12' \ b'\xca\xc6\xbd\x07' b'\xc0\x5d\xf5\xae' \ b'\xed\x25\x88\xf7' b'\x00\x00\x00\x00' \ b'\x94\x26\x87\x47' b'\xfa\xfa\xc1\x00' \ b'\x8a\x41\xda\xf1' b'\x00\x00\x00\x00' \ b'\x30\x92\x12\x8a' b'\x99\x54\x00\x01' \ b'\x91\xbc\xe7\x00' b'\xf8\x86\xf1\xf4' \ b'\x00\x00\x00\x03' b'\x5d\x82\x32\xbb' \ b'\x7f\x6b\x02\xbe' b'\xe4\x45\xc7\x23' \ b'\xd4\xb8\xdb\xf4' b'\xbe\x4b\x28\xa0' \ b'\x98\x4e\xa5\xfa' b'\x9b\xdd\xfb\xfe' \ b'\x87\x7c\x95\x45' b'\xde\x2c\xc5\x66' \ b'\x87\xcd\xdf\xbd' b'\xa8\x24\x0f\xa2' def testPackRequest0(self): bin = request.QueryFont._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryFont._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryFont._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryFont._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestQueryTextExtents(EndianTest): def setUp(self): self.req_args_0 = { 'font': 1223434172, 'string': (102, 111, 111), } self.req_bin_0 = b'\x30\x01\x00\x04' b'\x48\xec\x1f\xbc' \ b'\x00\x66\x00\x6f' b'\x00\x6f\x00\x00' self.reply_args_0 = { 'draw_direction': 191, 'font_ascent': -13287, 'font_descent': -31466, 'overall_ascent': -12473, 'overall_descent': -30082, 'overall_left': -735785526, 'overall_right': -894056953, 'overall_width': -1247205006, 'sequence_number': 38196, } self.reply_bin_0 = b'\x01\xbf\x95\x34' b'\x00\x00\x00\x00' \ b'\xcc\x19\x85\x16' b'\xcf\x47\x8a\x7e' \ b'\xb5\xa9\x29\x72' b'\xd4\x24\xcd\xca' \ b'\xca\xb5\xc6\x07' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryTextExtents._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryTextExtents._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryTextExtents._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryTextExtents._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestListFonts(EndianTest): def setUp(self): self.req_args_0 = { 'max_names': 37298, 'pattern': 'bhazr', } self.req_bin_0 = b'\x31\x00\x00\x04' b'\x91\xb2\x00\x05' \ b'\x62\x68\x61\x7a' b'\x72\x00\x00\x00' self.reply_args_0 = { 'fonts': ['fie', 'fuzzy', 'foozooom'], 'sequence_number': 34517, } self.reply_bin_0 = b'\x01\x00\x86\xd5' b'\x00\x00\x00\x05' \ b'\x00\x03\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x03\x66\x69\x65' b'\x05\x66\x75\x7a' \ b'\x7a\x79\x08\x66' b'\x6f\x6f\x7a\x6f' \ b'\x6f\x6f\x6d\x00' def testPackRequest0(self): bin = request.ListFonts._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListFonts._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListFonts._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListFonts._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestListFontsWithInfo(EndianTest): def setUp(self): self.req_args_0 = { 'max_names': 20989, 'pattern': 'bhazr2', } self.req_bin_0 = b'\x32\x00\x00\x04' b'\x51\xfd\x00\x06' \ b'\x62\x68\x61\x7a' b'\x72\x32\x00\x00' self.reply_args_0 = { 'all_chars_exist': 0, 'default_char': 61580, 'draw_direction': 146, 'font_ascent': -30368, 'font_descent': -15151, 'max_bounds': {'descent': -17786, 'right_side_bearing': -10759, 'character_width': -11617, 'left_side_bearing': -28480, 'attributes': 20976, 'ascent': -22938}, 'max_byte1': 245, 'max_char_or_byte2': 49530, 'min_bounds': {'descent': -24065, 'right_side_bearing': -9300, 'character_width': -22473, 'left_side_bearing': -10823, 'attributes': 26194, 'ascent': -24947}, 'min_byte1': 130, 'min_char_or_byte2': 61140, 'name': 'fontfont', 'properties': [{'name': 2007331946, 'value': 560055601}], 'replies_hint': 457810933, 'sequence_number': 13642, } self.reply_bin_0 = b'\x01\x08\x35\x4a' b'\x00\x00\x00\x0b' \ b'\xd5\xb9\xdb\xac' b'\xa8\x37\x9e\x8d' \ b'\xa1\xff\x66\x52' b'\x00\x00\x00\x00' \ b'\x90\xc0\xd5\xf9' b'\xd2\x9f\xa6\x66' \ b'\xba\x86\x51\xf0' b'\x00\x00\x00\x00' \ b'\xee\xd4\xc1\x7a' b'\xf0\x8c\x00\x01' \ b'\x92\x82\xf5\x00' b'\x89\x60\xc4\xd1' \ b'\x1b\x49\xa3\xf5' b'\x77\xa5\x74\x6a' \ b'\x21\x61\xc5\x31' b'\x66\x6f\x6e\x74' \ b'\x66\x6f\x6e\x74' def testPackRequest0(self): bin = request.ListFontsWithInfo._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListFontsWithInfo._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListFontsWithInfo._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListFontsWithInfo._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestSetFontPath(EndianTest): def setUp(self): self.req_args_0 = { 'path': ['foo', 'bar', 'gazonk'], } self.req_bin_0 = b'\x33\x00\x00\x06' b'\x00\x03\x00\x00' \ b'\x03\x66\x6f\x6f' b'\x03\x62\x61\x72' \ b'\x06\x67\x61\x7a' b'\x6f\x6e\x6b\x00' self.req_args_1 = { 'path': [], } self.req_bin_1 = b'\x33\x00\x00\x02' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SetFontPath._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.SetFontPath._request.to_binary(*(), **self.req_args_1) self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.SetFontPath._request.parse_binary(self.req_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_1) class TestGetFontPath(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x34\x00\x00\x01' self.reply_args_0 = { 'paths': ['path1', 'path2232'], 'sequence_number': 33409, } self.reply_bin_0 = b'\x01\x00\x82\x81' b'\x00\x00\x00\x04' \ b'\x00\x02\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x05\x70\x61\x74' b'\x68\x31\x08\x70' \ b'\x61\x74\x68\x32' b'\x32\x33\x32\x00' self.reply_args_1 = { 'paths': [], 'sequence_number': 17636, } self.reply_bin_1 = b'\x01\x00\x44\xe4' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetFontPath._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetFontPath._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) def testPackReply1(self): bin = request.GetFontPath._reply.to_binary(*(), **self.reply_args_1) self.assertBinaryEqual(bin, self.reply_bin_1) def testUnpackReply1(self): args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_1) class TestCreatePixmap(EndianTest): def setUp(self): self.req_args_0 = { 'depth': 161, 'drawable': 749556300, 'height': 4764, 'pid': 2004224799, 'width': 57984, } self.req_bin_0 = b'\x35\xa1\x00\x04' b'\x77\x76\x0b\x1f' \ b'\x2c\xad\x52\x4c' b'\xe2\x80\x12\x9c' def testPackRequest0(self): bin = request.CreatePixmap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreatePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestFreePixmap(EndianTest): def setUp(self): self.req_args_0 = { 'pixmap': 1888284001, } self.req_bin_0 = b'\x36\x00\x00\x02' b'\x70\x8c\xed\x61' def testPackRequest0(self): bin = request.FreePixmap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCreateGC(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'stipple': 1424681955, 'background': 338824284, 'subwindow_mode': 0, 'fill_style': 0, 'font': 568001783, 'graphics_exposures': 0, 'tile': 2000996399, 'tile_stipple_x_origin': -25980, 'dashes': 215, 'function': 7, 'foreground': 612071305, 'clip_x_origin': -22581, 'cap_style': 2, 'tile_stipple_y_origin': -23968, 'join_style': 2, 'line_width': 61484, 'dash_offset': 46571, 'clip_y_origin': -14920, 'arc_mode': 0, 'line_style': 2, 'plane_mask': 793618921, 'clip_mask': 605132525, 'fill_rule': 1}, 'cid': 1476454377, 'drawable': 1362081172, } self.req_bin_0 = b'\x37\x00\x00\x1b' b'\x58\x00\xe7\xe9' \ b'\x51\x2f\xb5\x94' b'\x00\x7f\xff\xff' \ b'\x07\x00\x00\x00' b'\x2f\x4d\xa9\xe9' \ b'\x24\x7b\x77\x89' b'\x14\x32\x0c\x5c' \ b'\xf0\x2c\x00\x00' b'\x02\x00\x00\x00' \ b'\x02\x00\x00\x00' b'\x02\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x01\x00\x00\x00' \ b'\x77\x44\xc8\x2f' b'\x54\xea\xeb\xe3' \ b'\x9a\x84\x00\x00' b'\xa2\x60\x00\x00' \ b'\x21\xdb\x04\xf7' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\xa7\xcb\x00\x00' \ b'\xc5\xb8\x00\x00' b'\x24\x11\x96\xed' \ b'\xb5\xeb\x00\x00' b'\xd7\x00\x00\x00' \ b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.CreateGC._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateGC._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestChangeGC(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'stipple': 1656031462, 'background': 539344312, 'subwindow_mode': 1, 'fill_style': 0, 'font': 347060191, 'graphics_exposures': 1, 'tile': 716372747, 'tile_stipple_x_origin': -24195, 'dashes': 137, 'function': 8, 'foreground': 1049179696, 'clip_x_origin': -32135, 'cap_style': 3, 'tile_stipple_y_origin': -15601, 'join_style': 1, 'line_width': 36097, 'dash_offset': 42536, 'clip_y_origin': -25437, 'arc_mode': 1, 'line_style': 0, 'plane_mask': 1085423224, 'clip_mask': 161650480, 'fill_rule': 0}, 'gc': 1250995304, } self.req_bin_0 = b'\x38\x00\x00\x1a' b'\x4a\x90\xac\x68' \ b'\x00\x7f\xff\xff' b'\x08\x00\x00\x00' \ b'\x40\xb2\x3e\x78' b'\x3e\x89\x36\x30' \ b'\x20\x25\xbd\xb8' b'\x8d\x01\x00\x00' \ b'\x00\x00\x00\x00' b'\x03\x00\x00\x00' \ b'\x01\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x2a\xb2\xfb\x0b' \ b'\x62\xb5\x08\xe6' b'\xa1\x7d\x00\x00' \ b'\xc3\x0f\x00\x00' b'\x14\xaf\xb7\xdf' \ b'\x01\x00\x00\x00' b'\x01\x00\x00\x00' \ b'\x82\x79\x00\x00' b'\x9c\xa3\x00\x00' \ b'\x09\xa2\x97\x30' b'\xa6\x28\x00\x00' \ b'\x89\x00\x00\x00' b'\x01\x00\x00\x00' def testPackRequest0(self): bin = request.ChangeGC._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeGC._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCopyGC(EndianTest): def setUp(self): self.req_args_0 = { 'dst_gc': 318094523, 'mask': 923025483, 'src_gc': 1186604145, } self.req_bin_0 = b'\x39\x00\x00\x04' b'\x46\xba\x24\x71' \ b'\x12\xf5\xbc\xbb' b'\x37\x04\x40\x4b' def testPackRequest0(self): bin = request.CopyGC._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyGC._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestSetDashes(EndianTest): def setUp(self): self.req_args_0 = { 'dash_offset': 51381, 'dashes': [160, 138, 206, 221, 138, 219, 181, 191, 154], 'gc': 759584613, } self.req_bin_0 = b'\x3a\x00\x00\x06' b'\x2d\x46\x57\x65' \ b'\xc8\xb5\x00\x09' b'\xa0\x8a\xce\xdd' \ b'\x8a\xdb\xb5\xbf' b'\x9a\x00\x00\x00' def testPackRequest0(self): bin = request.SetDashes._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetDashes._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestSetClipRectangles(EndianTest): def setUp(self): self.req_args_0 = { 'gc': 1856792138, 'ordering': 1, 'rectangles': [{'y': -3797, 'x': -14422, 'height': 26888, 'width': 57581}, {'y': -12431, 'x': -858, 'height': 10384, 'width': 49373}], 'x_origin': -27444, 'y_origin': -780, } self.req_bin_0 = b'\x3b\x01\x00\x07' b'\x6e\xac\x66\x4a' \ b'\x94\xcc\xfc\xf4' b'\xc7\xaa\xf1\x2b' \ b'\xe0\xed\x69\x08' b'\xfc\xa6\xcf\x71' \ b'\xc0\xdd\x28\x90' self.req_args_1 = { 'gc': 1892892424, 'ordering': 1, 'rectangles': [], 'x_origin': -19258, 'y_origin': -31956, } self.req_bin_1 = b'\x3b\x01\x00\x03' b'\x70\xd3\x3f\x08' \ b'\xb4\xc6\x83\x2c' def testPackRequest0(self): bin = request.SetClipRectangles._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.SetClipRectangles._request.to_binary(*(), **self.req_args_1) self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_1) class TestFreeGC(EndianTest): def setUp(self): self.req_args_0 = { 'gc': 385239625, } self.req_bin_0 = b'\x3c\x00\x00\x02' b'\x16\xf6\x4a\x49' def testPackRequest0(self): bin = request.FreeGC._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeGC._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestClearArea(EndianTest): def setUp(self): self.req_args_0 = { 'exposures': 1, 'height': 44159, 'width': 52831, 'window': 1680227732, 'x': -2268, 'y': -19277, } self.req_bin_0 = b'\x3d\x01\x00\x04' b'\x64\x26\x3d\x94' \ b'\xf7\x24\xb4\xb3' b'\xce\x5f\xac\x7f' def testPackRequest0(self): bin = request.ClearArea._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ClearArea._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCopyArea(EndianTest): def setUp(self): self.req_args_0 = { 'dst_drawable': 1578589574, 'dst_x': -27552, 'dst_y': -6968, 'gc': 1741136437, 'height': 7340, 'src_drawable': 1855628899, 'src_x': -24637, 'src_y': -24026, 'width': 46214, } self.req_bin_0 = b'\x3e\x00\x00\x07' b'\x6e\x9a\xa6\x63' \ b'\x5e\x17\x5d\x86' b'\x67\xc7\xa2\x35' \ b'\x9f\xc3\xa2\x26' b'\x94\x60\xe4\xc8' \ b'\xb4\x86\x1c\xac' def testPackRequest0(self): bin = request.CopyArea._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyArea._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCopyPlane(EndianTest): def setUp(self): self.req_args_0 = { 'bit_plane': 988559210, 'dst_drawable': 1873029448, 'dst_x': -25480, 'dst_y': -26229, 'gc': 83225989, 'height': 60447, 'src_drawable': 821567629, 'src_x': -4634, 'src_y': -17345, 'width': 53771, } self.req_bin_0 = b'\x3f\x00\x00\x08' b'\x30\xf8\x20\x8d' \ b'\x6f\xa4\x29\x48' b'\x04\xf5\xed\x85' \ b'\xed\xe6\xbc\x3f' b'\x9c\x78\x99\x8b' \ b'\xd2\x0b\xec\x1f' b'\x3a\xec\x37\x6a' def testPackRequest0(self): bin = request.CopyPlane._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyPlane._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyPoint(EndianTest): def setUp(self): self.req_args_0 = { 'coord_mode': 0, 'drawable': 50884525, 'gc': 1417476013, 'points': [{'y': -22768, 'x': -21311}, {'y': -6707, 'x': -5881}, {'y': -25311, 'x': -4217}], } self.req_bin_0 = b'\x40\x00\x00\x06' b'\x03\x08\x6f\xad' \ b'\x54\x7c\xf7\xad' b'\xac\xc1\xa7\x10' \ b'\xe9\x07\xe5\xcd' b'\xef\x87\x9d\x21' def testPackRequest0(self): bin = request.PolyPoint._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyPoint._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyLine(EndianTest): def setUp(self): self.req_args_0 = { 'coord_mode': 1, 'drawable': 1459319574, 'gc': 2107068434, 'points': [{'y': -19712, 'x': -26440}, {'y': -23639, 'x': -22012}, {'y': -30494, 'x': -4445}, {'y': -7428, 'x': -1085}, {'y': -21262, 'x': -23622}], } self.req_bin_0 = b'\x41\x01\x00\x08' b'\x56\xfb\x73\x16' \ b'\x7d\x97\x50\x12' b'\x98\xb8\xb3\x00' \ b'\xaa\x04\xa3\xa9' b'\xee\xa3\x88\xe2' \ b'\xfb\xc3\xe2\xfc' b'\xa3\xba\xac\xf2' def testPackRequest0(self): bin = request.PolyLine._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyLine._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolySegment(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 59337240, 'gc': 247760051, 'segments': [{'y1': -15198, 'x2': -21917, 'x1': -5123, 'y2': -1992}], } self.req_bin_0 = b'\x42\x00\x00\x05' b'\x03\x89\x6a\x18' \ b'\x0e\xc4\x84\xb3' b'\xeb\xfd\xc4\xa2' \ b'\xaa\x63\xf8\x38' def testPackRequest0(self): bin = request.PolySegment._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolySegment._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyRectangle(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 742422946, 'gc': 1564604140, 'rectangles': [{'y': -970, 'x': -4030, 'height': 11958, 'width': 17374}, {'y': -1228, 'x': -13744, 'height': 17653, 'width': 64713}, {'y': -29216, 'x': -31515, 'height': 28735, 'width': 39352}], } self.req_bin_0 = b'\x43\x00\x00\x09' b'\x2c\x40\x79\xa2' \ b'\x5d\x41\xf6\xec' b'\xf0\x42\xfc\x36' \ b'\x43\xde\x2e\xb6' b'\xca\x50\xfb\x34' \ b'\xfc\xc9\x44\xf5' b'\x84\xe5\x8d\xe0' \ b'\x99\xb8\x70\x3f' def testPackRequest0(self): bin = request.PolyRectangle._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyArc(EndianTest): def setUp(self): self.req_args_0 = { 'arcs': [{'height': 39984, 'width': 28855, 'angle1': -517, 'angle2': -16010, 'y': -22490, 'x': -6999}, {'height': 38043, 'width': 59205, 'angle1': -26540, 'angle2': -24422, 'y': -20146, 'x': -28979}, {'height': 366, 'width': 28833, 'angle1': -15732, 'angle2': -2439, 'y': -9543, 'x': -31314}], 'drawable': 1732034432, 'gc': 1156382390, } self.req_bin_0 = b'\x44\x00\x00\x0c' b'\x67\x3c\xbf\x80' \ b'\x44\xec\xfe\xb6' b'\xe4\xa9\xa8\x26' \ b'\x70\xb7\x9c\x30' b'\xfd\xfb\xc1\x76' \ b'\x8e\xcd\xb1\x4e' b'\xe7\x45\x94\x9b' \ b'\x98\x54\xa0\x9a' b'\x85\xae\xda\xb9' \ b'\x70\xa1\x01\x6e' b'\xc2\x8c\xf6\x79' def testPackRequest0(self): bin = request.PolyArc._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyArc._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestFillPoly(EndianTest): def setUp(self): self.req_args_0 = { 'coord_mode': 0, 'drawable': 423195261, 'gc': 782225195, 'points': [{'y': -9194, 'x': -10262}, {'y': -8456, 'x': -1958}, {'y': -10793, 'x': -8617}], 'shape': 1, } self.req_bin_0 = b'\x45\x00\x00\x07' b'\x19\x39\x72\x7d' \ b'\x2e\x9f\xcf\x2b' b'\x01\x00\x00\x00' \ b'\xd7\xea\xdc\x16' b'\xf8\x5a\xde\xf8' \ b'\xde\x57\xd5\xd7' def testPackRequest0(self): bin = request.FillPoly._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FillPoly._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyFillRectangle(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 267696363, 'gc': 1545726032, 'rectangles': [{'y': -11003, 'x': -1676, 'height': 21895, 'width': 60599}, {'y': -22482, 'x': -12349, 'height': 55831, 'width': 43731}], } self.req_bin_0 = b'\x46\x00\x00\x07' b'\x0f\xf4\xb8\xeb' \ b'\x5c\x21\xe8\x50' b'\xf9\x74\xd5\x05' \ b'\xec\xb7\x55\x87' b'\xcf\xc3\xa8\x2e' \ b'\xaa\xd3\xda\x17' def testPackRequest0(self): bin = request.PolyFillRectangle._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyFillRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyFillArc(EndianTest): def setUp(self): self.req_args_0 = { 'arcs': [{'height': 20525, 'width': 33490, 'angle1': -10916, 'angle2': -19386, 'y': -22928, 'x': -3276}], 'drawable': 700537986, 'gc': 864213787, } self.req_bin_0 = b'\x47\x00\x00\x06' b'\x29\xc1\x5c\x82' \ b'\x33\x82\xdb\x1b' b'\xf3\x34\xa6\x70' \ b'\x82\xd2\x50\x2d' b'\xd5\x5c\xb4\x46' def testPackRequest0(self): bin = request.PolyFillArc._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyFillArc._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPutImage(EndianTest): def setUp(self): self.req_args_0 = { 'data': b'\xe9\x10\xf2o\x7f{\xae-\xe6\x18\xce\x83', 'depth': 172, 'drawable': 634980240, 'dst_x': -18991, 'dst_y': -10980, 'format': 2, 'gc': 1190657277, 'height': 12828, 'left_pad': 225, 'width': 8597, } self.req_bin_0 = b'\x48\x02\x00\x09' b'\x25\xd9\x07\x90' \ b'\x46\xf7\xfc\xfd' b'\x21\x95\x32\x1c' \ b'\xb5\xd1\xd5\x1c' b'\xe1\xac\x00\x00' \ b'\xe9\x10\xf2\x6f' b'\x7f\x7b\xae\x2d' \ b'\xe6\x18\xce\x83' def testPackRequest0(self): bin = request.PutImage._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PutImage._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetImage(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 872105322, 'format': 2, 'height': 20170, 'plane_mask': 616208054, 'width': 282, 'x': -14814, 'y': -5449, } self.req_bin_0 = b'\x49\x02\x00\x05' b'\x33\xfb\x45\x6a' \ b'\xc6\x22\xea\xb7' b'\x01\x1a\x4e\xca' \ b'\x24\xba\x96\xb6' self.reply_args_0 = { 'data': b'\xeb?:\xa7\xc6\x8b\xc2\x96o-S\xe6\xd6z6\x94\xd7v\xd2R.\xa2\xeaw\t\x13\x95\x85', 'depth': 181, 'sequence_number': 28429, 'visual': 1687469773, } self.reply_bin_0 = b'\x01\xb5\x6f\x0d' b'\x00\x00\x00\x07' \ b'\x64\x94\xbe\xcd' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\xeb\x3f\x3a\xa7' b'\xc6\x8b\xc2\x96' \ b'\x6f\x2d\x53\xe6' b'\xd6\x7a\x36\x94' \ b'\xd7\x76\xd2\x52' b'\x2e\xa2\xea\x77' \ b'\x09\x13\x95\x85' def testPackRequest0(self): bin = request.GetImage._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetImage._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetImage._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetImage._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestPolyText8(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 1245573363, 'gc': 1302861330, 'items': [{'string': 'zoo', 'delta': 2}, 16909060, {'string': 'ie', 'delta': 0}], 'x': -11315, 'y': -22209, } self.req_bin_0 = b'\x4a\x00\x00\x08' b'\x4a\x3d\xf0\xf3' \ b'\x4d\xa8\x16\x12' b'\xd3\xcd\xa9\x3f' \ b'\x03\x02\x7a\x6f' b'\x6f\xff\x01\x02' \ b'\x03\x04\x02\x00' b'\x69\x65\x00\x00' def testPackRequest0(self): bin = request.PolyText8._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyText8._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyText16(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 998620068, 'gc': 948793778, 'items': [{'string': (4131, 18), 'delta': 2}, 16909060], 'x': -18280, 'y': -10630, } self.req_bin_0 = b'\x4b\x00\x00\x07' b'\x3b\x85\xbb\xa4' \ b'\x38\x8d\x71\xb2' b'\xb8\x98\xd6\x7a' \ b'\x02\x02\x10\x23' b'\x00\x12\xff\x01' \ b'\x02\x03\x04\x00' def testPackRequest0(self): bin = request.PolyText16._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyText16._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestImageText8(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 458985805, 'gc': 1097803335, 'string': 'showme', 'x': -17263, 'y': -6759, } self.req_bin_0 = b'\x4c\x06\x00\x06' b'\x1b\x5b\x91\x4d' \ b'\x41\x6f\x26\x47' b'\xbc\x91\xe5\x99' \ b'\x73\x68\x6f\x77' b'\x6d\x65\x00\x00' def testPackRequest0(self): bin = request.ImageText8._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ImageText8._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestImageText16(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 1935336610, 'gc': 2061289059, 'string': (115, 104, 111, 119, 109, 111, 114, 101), 'x': -6684, 'y': -8653, } self.req_bin_0 = b'\x4d\x08\x00\x08' b'\x73\x5a\xe4\xa2' \ b'\x7a\xdc\xc6\x63' b'\xe5\xe4\xde\x33' \ b'\x00\x73\x00\x68' b'\x00\x6f\x00\x77' \ b'\x00\x6d\x00\x6f' b'\x00\x72\x00\x65' def testPackRequest0(self): bin = request.ImageText16._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ImageText16._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCreateColormap(EndianTest): def setUp(self): self.req_args_0 = { 'alloc': 0, 'mid': 1414936748, 'visual': 609492200, 'window': 182162564, } self.req_bin_0 = b'\x4e\x00\x00\x04' b'\x54\x56\x38\xac' \ b'\x0a\xdb\x94\x84' b'\x24\x54\x1c\xe8' def testPackRequest0(self): bin = request.CreateColormap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestFreeColormap(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 1106990292, } self.req_bin_0 = b'\x4f\x00\x00\x02' b'\x41\xfb\x54\xd4' def testPackRequest0(self): bin = request.FreeColormap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCopyColormapAndFree(EndianTest): def setUp(self): self.req_args_0 = { 'mid': 1425680795, 'src_cmap': 1359295675, } self.req_bin_0 = b'\x50\x00\x00\x03' b'\x54\xfa\x29\x9b' \ b'\x51\x05\x34\xbb' def testPackRequest0(self): bin = request.CopyColormapAndFree._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyColormapAndFree._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestInstallColormap(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 1329917990, } self.req_bin_0 = b'\x51\x00\x00\x02' b'\x4f\x44\xf0\x26' def testPackRequest0(self): bin = request.InstallColormap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.InstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestUninstallColormap(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 719876845, } self.req_bin_0 = b'\x52\x00\x00\x02' b'\x2a\xe8\x72\xed' def testPackRequest0(self): bin = request.UninstallColormap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UninstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestListInstalledColormaps(EndianTest): def setUp(self): self.req_args_0 = { 'window': 200613013, } self.req_bin_0 = b'\x53\x00\x00\x02' b'\x0b\xf5\x1c\x95' self.reply_args_0 = { 'cmaps': [1757616530, 2044469232], 'sequence_number': 49482, } self.reply_bin_0 = b'\x01\x00\xc1\x4a' b'\x00\x00\x00\x02' \ b'\x00\x02\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x68\xc3\x19\x92' b'\x79\xdc\x1f\xf0' def testPackRequest0(self): bin = request.ListInstalledColormaps._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListInstalledColormaps._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListInstalledColormaps._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListInstalledColormaps._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestAllocColor(EndianTest): def setUp(self): self.req_args_0 = { 'blue': 14978, 'cmap': 504442007, 'green': 20599, 'red': 44348, } self.req_bin_0 = b'\x54\x00\x00\x04' b'\x1e\x11\x2c\x97' \ b'\xad\x3c\x50\x77' b'\x3a\x82\x00\x00' self.reply_args_0 = { 'blue': 1856, 'green': 9912, 'pixel': 99308744, 'red': 13306, 'sequence_number': 53114, } self.reply_bin_0 = b'\x01\x00\xcf\x7a' b'\x00\x00\x00\x00' \ b'\x33\xfa\x26\xb8' b'\x07\x40\x00\x00' \ b'\x05\xeb\x54\xc8' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.AllocColor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocColor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocColor._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestAllocNamedColor(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 525860889, 'name': 'octarin', } self.req_bin_0 = b'\x55\x00\x00\x05' b'\x1f\x58\x00\x19' \ b'\x00\x07\x00\x00' b'\x6f\x63\x74\x61' \ b'\x72\x69\x6e\x00' self.reply_args_0 = { 'exact_blue': 50619, 'exact_green': 55944, 'exact_red': 40316, 'pixel': 1020413057, 'screen_blue': 27416, 'screen_green': 30102, 'screen_red': 5028, 'sequence_number': 64739, } self.reply_bin_0 = b'\x01\x00\xfc\xe3' b'\x00\x00\x00\x00' \ b'\x3c\xd2\x44\x81' b'\x9d\x7c\xda\x88' \ b'\xc5\xbb\x13\xa4' b'\x75\x96\x6b\x18' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.AllocNamedColor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocNamedColor._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocNamedColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestAllocColorCells(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 1542701632, 'colors': 45892, 'contiguous': 0, 'planes': 25420, } self.req_bin_0 = b'\x56\x00\x00\x03' b'\x5b\xf3\xc2\x40' \ b'\xb3\x44\x63\x4c' self.reply_args_0 = { 'masks': [1726878301, 2057281944, 1494524694], 'pixels': [1061732426, 858313521, 524018138, 316972578, 1408939380, 1476723430, 11972931, 1917037904, 1612749468, 1847847580, 1653727126, 1901587588, 228960010, 1671710636, 913060041, 470023299, 377779303], 'sequence_number': 34200, } self.reply_bin_0 = b'\x01\x00\x85\x98' b'\x00\x00\x00\x14' \ b'\x00\x11\x00\x03' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x3f\x48\xc0\x4a' b'\x33\x28\xd3\x31' \ b'\x1f\x3b\xe1\xda' b'\x12\xe4\x9e\x22' \ b'\x53\xfa\xb5\x74' b'\x58\x05\x02\xe6' \ b'\x00\xb6\xb1\x43' b'\x72\x43\xad\x50' \ b'\x60\x20\x9a\x9c' b'\x6e\x23\xea\x9c' \ b'\x62\x91\xdf\x96' b'\x71\x57\xec\x84' \ b'\x0d\xa5\xa7\x0a' b'\x63\xa4\x47\xac' \ b'\x36\x6c\x30\xc9' b'\x1c\x03\xfc\x83' \ b'\x16\x84\x74\x67' b'\x66\xee\x12\x5d' \ b'\x7a\x9f\xa1\x98' b'\x59\x14\xa3\x16' self.reply_args_1 = { 'masks': [], 'pixels': [], 'sequence_number': 30700, } self.reply_bin_1 = b'\x01\x00\x77\xec' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.AllocColorCells._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocColorCells._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocColorCells._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) def testPackReply1(self): bin = request.AllocColorCells._reply.to_binary(*(), **self.reply_args_1) self.assertBinaryEqual(bin, self.reply_bin_1) def testUnpackReply1(self): args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_1) class TestAllocColorPlanes(EndianTest): def setUp(self): self.req_args_0 = { 'blue': 8209, 'cmap': 1197085372, 'colors': 16587, 'contiguous': 0, 'green': 55852, 'red': 60383, } self.req_bin_0 = b'\x57\x00\x00\x04' b'\x47\x5a\x12\xbc' \ b'\x40\xcb\xeb\xdf' b'\xda\x2c\x20\x11' self.reply_args_0 = { 'blue_mask': 1200348460, 'green_mask': 2121548418, 'pixels': [980309855, 286409072, 1721094583, 997879295], 'red_mask': 1140662566, 'sequence_number': 44006, } self.reply_bin_0 = b'\x01\x00\xab\xe6' b'\x00\x00\x00\x04' \ b'\x00\x04\x00\x00' b'\x43\xfd\x21\x26' \ b'\x7e\x74\x42\x82' b'\x47\x8b\xdd\x2c' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x3a\x6e\x57\x5f' b'\x11\x12\x41\x70' \ b'\x66\x95\xd1\xb7' b'\x3b\x7a\x6d\xff' def testPackRequest0(self): bin = request.AllocColorPlanes._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocColorPlanes._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocColorPlanes._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocColorPlanes._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestFreeColors(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 341854532, 'pixels': [1278789650, 681457705, 2040260049, 1621952585, 1914388136, 950484730, 1315726377, 1750278681, 1544694596, 1915664535, 1084068385, 916484334, 1783699241, 1947521244, 1176611597, 957657715, 1926805276], 'plane_mask': 1597053435, } self.req_bin_0 = b'\x58\x00\x00\x14' b'\x14\x60\x49\x44' \ b'\x5f\x31\x19\xfb' b'\x4c\x38\xc8\x12' \ b'\x28\x9e\x38\x29' b'\x79\x9b\xe5\xd1' \ b'\x60\xad\x08\x49' b'\x72\x1b\x3e\xa8' \ b'\x38\xa7\x3e\xfa' b'\x4e\x6c\x64\x29' \ b'\x68\x53\x22\x19' b'\x5c\x12\x2b\x44' \ b'\x72\x2e\xb8\x97' b'\x40\x9d\x92\x21' \ b'\x36\xa0\x70\xee' b'\x6a\x51\x17\x29' \ b'\x74\x14\xd0\xdc' b'\x46\x21\xab\x0d' \ b'\x39\x14\xb2\x73' b'\x72\xd8\xb7\x1c' def testPackRequest0(self): bin = request.FreeColors._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeColors._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestStoreColors(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 686636594, 'items': [{'blue': 17242, 'flags': 191, 'green': 29751, 'pixel': 1850111768, 'red': 31364}, {'blue': 50444, 'flags': 252, 'green': 18429, 'pixel': 1803657350, 'red': 42045}, {'blue': 29083, 'flags': 147, 'green': 18252, 'pixel': 1345997556, 'red': 15935}, {'blue': 18063, 'flags': 213, 'green': 15623, 'pixel': 1532391469, 'red': 18981}], } self.req_bin_0 = b'\x59\x00\x00\x0e' b'\x28\xed\x3e\x32' \ b'\x6e\x46\x77\x18' b'\x7a\x84\x74\x37' \ b'\x43\x5a\xbf\x00' b'\x6b\x81\xa0\x86' \ b'\xa4\x3d\x47\xfd' b'\xc5\x0c\xfc\x00' \ b'\x50\x3a\x4a\xf4' b'\x3e\x3f\x47\x4c' \ b'\x71\x9b\x93\x00' b'\x5b\x56\x70\x2d' \ b'\x4a\x25\x3d\x07' b'\x46\x8f\xd5\x00' def testPackRequest0(self): bin = request.StoreColors._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.StoreColors._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestStoreNamedColor(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 297221571, 'flags': 148, 'name': 'blue', 'pixel': 323971915, } self.req_bin_0 = b'\x5a\x94\x00\x05' b'\x11\xb7\x3d\xc3' \ b'\x13\x4f\x6b\x4b' b'\x00\x04\x00\x00' \ b'\x62\x6c\x75\x65' def testPackRequest0(self): bin = request.StoreNamedColor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.StoreNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestQueryColors(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 875378525, 'pixels': [496695788, 822627561, 1490311416, 328212337, 1517089095, 459525846, 137995944, 890987562], } self.req_bin_0 = b'\x5b\x00\x00\x0a' b'\x34\x2d\x37\x5d' \ b'\x1d\x9a\xf9\xec' b'\x31\x08\x4c\xe9' \ b'\x58\xd4\x58\xf8' b'\x13\x90\x1f\x71' \ b'\x5a\x6c\xf1\x47' b'\x1b\x63\xce\xd6' \ b'\x08\x39\xa6\xa8' b'\x35\x1b\x64\x2a' self.reply_args_0 = { 'colors': [{'blue': 27504, 'green': 30790, 'red': 35816}, {'blue': 54840, 'green': 13811, 'red': 4336}, {'blue': 59555, 'green': 25780, 'red': 27790}, {'blue': 62257, 'green': 38534, 'red': 50705}, {'blue': 56402, 'green': 1536, 'red': 45837}], 'sequence_number': 57970, } self.reply_bin_0 = b'\x01\x00\xe2\x72' b'\x00\x00\x00\x0a' \ b'\x00\x05\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x8b\xe8\x78\x46' b'\x6b\x70\x00\x00' \ b'\x10\xf0\x35\xf3' b'\xd6\x38\x00\x00' \ b'\x6c\x8e\x64\xb4' b'\xe8\xa3\x00\x00' \ b'\xc6\x11\x96\x86' b'\xf3\x31\x00\x00' \ b'\xb3\x0d\x06\x00' b'\xdc\x52\x00\x00' self.req_args_1 = { 'cmap': 710627905, 'pixels': [], } self.req_bin_1 = b'\x5b\x00\x00\x02' b'\x2a\x5b\x52\x41' def testPackRequest0(self): bin = request.QueryColors._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryColors._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.QueryColors._request.to_binary(*(), **self.req_args_1) self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.QueryColors._request.parse_binary(self.req_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_1) def testPackReply0(self): bin = request.QueryColors._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryColors._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestLookupColor(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 1644167361, 'name': 'octarin', } self.req_bin_0 = b'\x5c\x00\x00\x05' b'\x62\x00\x00\xc1' \ b'\x00\x07\x00\x00' b'\x6f\x63\x74\x61' \ b'\x72\x69\x6e\x00' self.reply_args_0 = { 'exact_blue': 642, 'exact_green': 31515, 'exact_red': 25184, 'screen_blue': 19825, 'screen_green': 23308, 'screen_red': 62039, 'sequence_number': 37984, } self.reply_bin_0 = b'\x01\x00\x94\x60' b'\x00\x00\x00\x00' \ b'\x62\x60\x7b\x1b' b'\x02\x82\xf2\x57' \ b'\x5b\x0c\x4d\x71' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.LookupColor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.LookupColor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.LookupColor._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.LookupColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestCreateCursor(EndianTest): def setUp(self): self.req_args_0 = { 'back_blue': 49245, 'back_green': 35528, 'back_red': 27716, 'cid': 1618141054, 'fore_blue': 55026, 'fore_green': 62740, 'fore_red': 58690, 'mask': 1832831050, 'source': 837555484, 'x': 48400, 'y': 36047, } self.req_bin_0 = b'\x5d\x00\x00\x08' b'\x60\x72\xdf\x7e' \ b'\x31\xec\x15\x1c' b'\x6d\x3e\xc8\x4a' \ b'\xe5\x42\xf5\x14' b'\xd6\xf2\x6c\x44' \ b'\x8a\xc8\xc0\x5d' b'\xbd\x10\x8c\xcf' def testPackRequest0(self): bin = request.CreateCursor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCreateGlyphCursor(EndianTest): def setUp(self): self.req_args_0 = { 'back_blue': 25740, 'back_green': 2158, 'back_red': 32083, 'cid': 1717769345, 'fore_blue': 28818, 'fore_green': 18143, 'fore_red': 14636, 'mask': 1928100723, 'mask_char': 32252, 'source': 1295540602, 'source_char': 14709, } self.req_bin_0 = b'\x5e\x00\x00\x08' b'\x66\x63\x14\x81' \ b'\x4d\x38\x61\x7a' b'\x72\xec\x7b\x73' \ b'\x39\x75\x7d\xfc' b'\x39\x2c\x46\xdf' \ b'\x70\x92\x7d\x53' b'\x08\x6e\x64\x8c' def testPackRequest0(self): bin = request.CreateGlyphCursor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateGlyphCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestFreeCursor(EndianTest): def setUp(self): self.req_args_0 = { 'cursor': 721898231, } self.req_bin_0 = b'\x5f\x00\x00\x02' b'\x2b\x07\x4a\xf7' def testPackRequest0(self): bin = request.FreeCursor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestRecolorCursor(EndianTest): def setUp(self): self.req_args_0 = { 'back_blue': 55339, 'back_green': 11072, 'back_red': 47715, 'cursor': 1436460699, 'fore_blue': 26753, 'fore_green': 52563, 'fore_red': 44764, } self.req_bin_0 = b'\x60\x00\x00\x05' b'\x55\x9e\xa6\x9b' \ b'\xae\xdc\xcd\x53' b'\x68\x81\xba\x63' \ b'\x2b\x40\xd8\x2b' def testPackRequest0(self): bin = request.RecolorCursor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.RecolorCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestQueryBestSize(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 1974766133, 'height': 64528, 'item_class': 1, 'width': 8620, } self.req_bin_0 = b'\x61\x01\x00\x03' b'\x75\xb4\x8a\x35' \ b'\x21\xac\xfc\x10' self.reply_args_0 = { 'height': 2023, 'sequence_number': 41036, 'width': 35260, } self.reply_bin_0 = b'\x01\x00\xa0\x4c' b'\x00\x00\x00\x00' \ b'\x89\xbc\x07\xe7' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryBestSize._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryBestSize._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryBestSize._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryBestSize._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestQueryExtension(EndianTest): def setUp(self): self.req_args_0 = { 'name': 'XTRA', } self.req_bin_0 = b'\x62\x00\x00\x03' b'\x00\x04\x00\x00' \ b'\x58\x54\x52\x41' self.reply_args_0 = { 'first_error': 237, 'first_event': 149, 'major_opcode': 134, 'present': 1, 'sequence_number': 59692, } self.reply_bin_0 = b'\x01\x00\xe9\x2c' b'\x00\x00\x00\x00' \ b'\x01\x86\x95\xed' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryExtension._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryExtension._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryExtension._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryExtension._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestListExtensions(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x63\x00\x00\x01' self.reply_args_0 = { 'names': ['XTRA', 'XTRA-II'], 'sequence_number': 9149, } self.reply_bin_0 = b'\x01\x02\x23\xbd' b'\x00\x00\x00\x04' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x04\x58\x54\x52' b'\x41\x07\x58\x54' \ b'\x52\x41\x2d\x49' b'\x49\x00\x00\x00' def testPackRequest0(self): bin = request.ListExtensions._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListExtensions._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListExtensions._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListExtensions._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestChangeKeyboardMapping(EndianTest): def setUp(self): self.req_args_0 = { 'first_keycode': 157, 'keysyms': [[1861549105, 991489870, 390260112], [107985429, 558681426, 814119353], [702984500, 454537006, 976459372], [701896028, 724776911, 1634728346], [1889012491, 814167346, 597551532], [1614928797, 2042695294, 1786543801], [905303576, 541748982, 1792957544], [175892294, 1009976242, 41625283], [1608517348, 1158393599, 111852976], [2147285698, 2044231981, 751534113], [481513427, 1396173819, 147356828], [1677685199, 2055755177, 1399632465], [86453688, 1619703478, 66636412], [2039275666, 531036848, 428123802], [1802230236, 43765755, 1334308166], [327238597, 512271361, 271057482], [1016964633, 1437651928, 245649464], [1211115441, 2035292716, 468075293], [998652876, 1502089592, 550279151], [1646901134, 792196355, 360324443]], } self.req_bin_0 = b'\x64\x14\x00\x3e' b'\x9d\x03\x00\x00' \ b'\x6e\xf4\xfc\x31' b'\x3b\x18\xef\x4e' \ b'\x17\x42\xe5\x90' b'\x06\x6f\xba\x15' \ b'\x21\x4c\xcd\x52' b'\x30\x86\x79\xb9' \ b'\x29\xe6\xb1\x34' b'\x1b\x17\xaf\x2e' \ b'\x3a\x33\x96\x6c' b'\x29\xd6\x15\x5c' \ b'\x2b\x33\x37\xcf' b'\x61\x6f\xf9\x9a' \ b'\x70\x98\x0b\x0b' b'\x30\x87\x35\x32' \ b'\x23\x9d\xe9\xac' b'\x60\x41\xdb\x9d' \ b'\x79\xc1\x0e\x7e' b'\x6a\x7c\x7e\xb9' \ b'\x35\xf5\xd6\x18' b'\x20\x4a\x6e\xf6' \ b'\x6a\xde\x5c\x68' b'\x0a\x7b\xe7\x46' \ b'\x3c\x33\x03\xb2' b'\x02\x7b\x26\xc3' \ b'\x5f\xe0\x06\xe4' b'\x45\x0b\xae\xff' \ b'\x06\xaa\xbd\xb0' b'\x7f\xfc\xfa\xc2' \ b'\x79\xd8\x81\x2d' b'\x2c\xcb\x80\x21' \ b'\x1c\xb3\x4f\xd3' b'\x53\x37\xeb\xfb' \ b'\x08\xc8\x7c\x9c' b'\x63\xff\x71\xcf' \ b'\x7a\x88\x55\xa9' b'\x53\x6c\xb2\x51' \ b'\x05\x27\x2d\xb8' b'\x60\x8a\xb6\xb6' \ b'\x03\xf8\xca\x7c' b'\x79\x8c\xe0\x92' \ b'\x1f\xa6\xfa\xb0' b'\x19\x84\xa6\x9a' \ b'\x6b\x6b\xd9\xdc' b'\x02\x9b\xcf\xfb' \ b'\x4f\x87\xed\x46' b'\x13\x81\x43\xc5' \ b'\x1e\x88\xa4\x01' b'\x10\x28\x02\x4a' \ b'\x3c\x9d\xa6\x19' b'\x55\xb0\xd3\xd8' \ b'\x0e\xa4\x50\x38' b'\x48\x30\x27\xb1' \ b'\x79\x50\x1a\x2c' b'\x1b\xe6\x43\x1d' \ b'\x3b\x86\x3b\xcc' b'\x59\x88\x11\x78' \ b'\x20\xcc\x97\xef' b'\x62\x29\xb7\x8e' \ b'\x2f\x37\xf5\x03' b'\x15\x7a\x1d\x5b' def testPackRequest0(self): bin = request.ChangeKeyboardMapping._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetKeyboardMapping(EndianTest): def setUp(self): self.req_args_0 = { 'count': 207, 'first_keycode': 169, } self.req_bin_0 = b'\x65\x00\x00\x02' b'\xa9\xcf\x00\x00' self.reply_args_0 = { 'keysyms': [[232140298, 1242716010, 55143985], [1994770011, 669923085, 1236514049], [1454592222, 1949971307, 2057660497], [805965556, 851808913, 2021792706], [1535482384, 425909956, 163201187], [1271520474, 1483083165, 1783638995], [1346992789, 521515080, 218831382], [1497210568, 1658890074, 647643874], [1825990828, 1469435098, 1289374120], [1729858135, 259963764, 1709884923], [2112789657, 1215330896, 1680696611], [88195295, 745614404, 1144061708], [919934772, 1420606257, 795794911], [148083460, 1086542523, 1390588550], [732788374, 27170279, 1824449766], [902069278, 1765942198, 1052700150], [226642993, 930984408, 2063275595], [777792886, 1364908620, 1914642756], [1779635393, 987282730, 1518933756], [328545991, 935201525, 378251236]], 'sequence_number': 48346, } self.reply_bin_0 = b'\x01\x03\xbc\xda' b'\x00\x00\x00\x3c' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x0d\xd6\x2e\x0a' b'\x4a\x12\x57\x6a' \ b'\x03\x49\x6e\x31' b'\x76\xe5\xc6\x5b' \ b'\x27\xee\x37\x0d' b'\x49\xb3\xb5\x01' \ b'\x56\xb3\x50\xde' b'\x74\x3a\x33\x6b' \ b'\x7a\xa5\x68\x51' b'\x30\x0a\x0e\xf4' \ b'\x32\xc5\x92\x91' b'\x78\x82\x1b\xc2' \ b'\x5b\x85\x9a\x10' b'\x19\x62\xde\xc4' \ b'\x09\xba\x40\xa3' b'\x4b\xc9\xdc\xda' \ b'\x58\x66\x0d\x9d' b'\x6a\x50\x2b\xd3' \ b'\x50\x49\x7a\x95' b'\x1f\x15\xb0\x48' \ b'\x0d\x0b\x1a\x16' b'\x59\x3d\x9e\xc8' \ b'\x62\xe0\xa7\x5a' b'\x26\x9a\x42\xe2' \ b'\x6c\xd6\x68\xac' b'\x57\x95\xcc\xda' \ b'\x4c\xda\x49\xa8' b'\x67\x1b\x8a\x57' \ b'\x0f\x7e\xbb\x74' b'\x65\xea\xc5\xfb' \ b'\x7d\xee\x9c\x99' b'\x48\x70\x7a\x50' \ b'\x64\x2d\x65\x23' b'\x05\x41\xc0\xdf' \ b'\x2c\x71\x2c\x44' b'\x44\x30\xff\x0c' \ b'\x36\xd5\x17\x34' b'\x54\xac\xbb\x31' \ b'\x2f\x6e\xdd\xdf' b'\x08\xd3\x93\x04' \ b'\x40\xc3\x52\xbb' b'\x52\xe2\xb2\x86' \ b'\x2b\xad\x76\x96' b'\x01\x9e\x95\xe7' \ b'\x6c\xbe\xe4\xe6' b'\x35\xc4\x7c\x1e' \ b'\x69\x42\x23\xb6' b'\x3e\xbe\xed\xf6' \ b'\x0d\x82\x4c\x31' b'\x37\x7d\xb1\xd8' \ b'\x7a\xfb\x16\x4b' b'\x2e\x5c\x2d\x76' \ b'\x51\x5a\xda\x4c' b'\x72\x1f\x21\x44' \ b'\x6a\x13\x14\xc1' b'\x3a\xd8\xbd\x2a' \ b'\x5a\x89\x16\xfc' b'\x13\x95\x36\xc7' \ b'\x37\xbe\x0a\xf5' b'\x16\x8b\xa7\xe4' def testPackRequest0(self): bin = request.GetKeyboardMapping._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetKeyboardMapping._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetKeyboardMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestChangeKeyboardControl(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'led': 196, 'auto_repeat_mode': 0, 'bell_pitch': -2303, 'bell_percent': -5, 'key_click_percent': -59, 'key': 190, 'bell_duration': -4223, 'led_mode': 1}, } self.req_bin_0 = b'\x66\x00\x00\x0a' b'\x00\x00\x00\xff' \ b'\xc5\x00\x00\x00' b'\xfb\x00\x00\x00' \ b'\xf7\x01\x00\x00' b'\xef\x81\x00\x00' \ b'\xc4\x00\x00\x00' b'\x01\x00\x00\x00' \ b'\xbe\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.ChangeKeyboardControl._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetKeyboardControl(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x67\x00\x00\x01' self.reply_args_0 = { 'auto_repeats': [199, 243, 190, 246, 225, 214, 135, 254, 211, 174, 252, 182, 218, 194, 215, 199, 198, 130, 176, 149, 189, 232, 253, 189, 249, 253, 242, 132, 151, 203, 184, 231], 'bell_duration': 35050, 'bell_percent': 249, 'bell_pitch': 36528, 'global_auto_repeat': 0, 'key_click_percent': 222, 'led_mask': 1425908825, 'sequence_number': 20323, } self.reply_bin_0 = b'\x01\x00\x4f\x63' b'\x00\x00\x00\x05' \ b'\x54\xfd\xa4\x59' b'\xde\xf9\x8e\xb0' \ b'\x88\xea\x00\x00' b'\xc7\xf3\xbe\xf6' \ b'\xe1\xd6\x87\xfe' b'\xd3\xae\xfc\xb6' \ b'\xda\xc2\xd7\xc7' b'\xc6\x82\xb0\x95' \ b'\xbd\xe8\xfd\xbd' b'\xf9\xfd\xf2\x84' \ b'\x97\xcb\xb8\xe7' def testPackRequest0(self): bin = request.GetKeyboardControl._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetKeyboardControl._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetKeyboardControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestBell(EndianTest): def setUp(self): self.req_args_0 = { 'percent': -40, } self.req_bin_0 = b'\x68\xd8\x00\x01' def testPackRequest0(self): bin = request.Bell._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.Bell._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestChangePointerControl(EndianTest): def setUp(self): self.req_args_0 = { 'accel_denum': -8326, 'accel_num': -18826, 'do_accel': 1, 'do_thresh': 1, 'threshold': -14733, } self.req_bin_0 = b'\x69\x00\x00\x03' b'\xb6\x76\xdf\x7a' \ b'\xc6\x73\x01\x01' def testPackRequest0(self): bin = request.ChangePointerControl._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangePointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetPointerControl(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x6a\x00\x00\x01' self.reply_args_0 = { 'accel_denom': 18010, 'accel_num': 29992, 'sequence_number': 46318, 'threshold': 20350, } self.reply_bin_0 = b'\x01\x00\xb4\xee' b'\x00\x00\x00\x00' \ b'\x75\x28\x46\x5a' b'\x4f\x7e\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetPointerControl._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetPointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetPointerControl._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetPointerControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestSetScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { 'allow_exposures': 2, 'interval': -25214, 'prefer_blank': 0, 'timeout': -24531, } self.req_bin_0 = b'\x6b\x00\x00\x03' b'\xa0\x2d\x9d\x82' \ b'\x00\x02\x00\x00' def testPackRequest0(self): bin = request.SetScreenSaver._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x6c\x00\x00\x01' self.reply_args_0 = { 'allow_exposures': 0, 'interval': 8091, 'prefer_blanking': 0, 'sequence_number': 12877, 'timeout': 20935, } self.reply_bin_0 = b'\x01\x00\x32\x4d' b'\x00\x00\x00\x00' \ b'\x51\xc7\x1f\x9b' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetScreenSaver._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetScreenSaver._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetScreenSaver._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestChangeHosts(EndianTest): def setUp(self): self.req_args_0 = { 'host': [183, 251, 198, 200], 'host_family': 0, 'mode': 0, } self.req_bin_0 = b'\x6d\x00\x00\x03' b'\x00\x00\x00\x04' \ b'\xb7\xfb\xc6\xc8' def testPackRequest0(self): bin = request.ChangeHosts._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeHosts._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestListHosts(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x6e\x00\x00\x01' self.reply_args_0 = { 'hosts': [{'name': [34, 23, 178, 12], 'family': 0}, {'name': [130, 236, 254, 15], 'family': 0}], 'mode': 1, 'sequence_number': 15164, } self.reply_bin_0 = b'\x01\x01\x3b\x3c' b'\x00\x00\x00\x04' \ b'\x00\x02\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x04' b'\x22\x17\xb2\x0c' \ b'\x00\x00\x00\x04' b'\x82\xec\xfe\x0f' def testPackRequest0(self): bin = request.ListHosts._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListHosts._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListHosts._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListHosts._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestSetAccessControl(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 1, } self.req_bin_0 = b'\x6f\x01\x00\x01' def testPackRequest0(self): bin = request.SetAccessControl._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetAccessControl._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestSetCloseDownMode(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 0, } self.req_bin_0 = b'\x70\x00\x00\x01' def testPackRequest0(self): bin = request.SetCloseDownMode._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetCloseDownMode._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestKillClient(EndianTest): def setUp(self): self.req_args_0 = { 'resource': 649180254, } self.req_bin_0 = b'\x71\x00\x00\x02' b'\x26\xb1\xb4\x5e' def testPackRequest0(self): bin = request.KillClient._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.KillClient._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestRotateProperties(EndianTest): def setUp(self): self.req_args_0 = { 'delta': -11867, 'properties': [30448914, 1520523655, 1147111912, 271900374, 589144637, 97809756, 2092347973, 117159267, 1188394866, 627424198, 1497757970, 2027482546], 'window': 271248673, } self.req_bin_0 = b'\x72\x00\x00\x0f' b'\x10\x2a\xed\x21' \ b'\x00\x0c\xd1\xa5' b'\x01\xd0\x9d\x12' \ b'\x5a\xa1\x59\x87' b'\x44\x5f\x89\xe8' \ b'\x10\x34\xde\xd6' b'\x23\x1d\xa2\x3d' \ b'\x05\xd4\x75\x5c' b'\x7c\xb6\xb2\x45' \ b'\x06\xfb\xb5\x63' b'\x46\xd5\x77\x72' \ b'\x25\x65\xbb\xc6' b'\x59\x45\xf9\x12' \ b'\x78\xd8\xed\xb2' def testPackRequest0(self): bin = request.RotateProperties._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.RotateProperties._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestForceScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 1, } self.req_bin_0 = b'\x73\x01\x00\x01' def testPackRequest0(self): bin = request.ForceScreenSaver._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ForceScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestSetPointerMapping(EndianTest): def setUp(self): self.req_args_0 = { 'map': [154, 131, 200, 248, 250], } self.req_bin_0 = b'\x74\x05\x00\x03' b'\x9a\x83\xc8\xf8' \ b'\xfa\x00\x00\x00' self.reply_args_0 = { 'sequence_number': 22584, 'status': 240, } self.reply_bin_0 = b'\x01\xf0\x58\x38' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SetPointerMapping._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.SetPointerMapping._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.SetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestGetPointerMapping(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x75\x00\x00\x01' self.reply_args_0 = { 'map': [175, 141, 192, 250, 157], 'sequence_number': 54134, } self.reply_bin_0 = b'\x01\x05\xd3\x76' b'\x00\x00\x00\x02' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\xaf\x8d\xc0\xfa' b'\x9d\x00\x00\x00' def testPackRequest0(self): bin = request.GetPointerMapping._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetPointerMapping._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestSetModifierMapping(EndianTest): def setUp(self): self.req_args_0 = { 'keycodes': [[33, 205], [251, 37], [27, 77], [76, 155], [43, 127], [60, 213], [115, 194], [230, 226]], } self.req_bin_0 = b'\x76\x02\x00\x05' b'\x21\xcd\xfb\x25' \ b'\x1b\x4d\x4c\x9b' b'\x2b\x7f\x3c\xd5' \ b'\x73\xc2\xe6\xe2' self.reply_args_0 = { 'sequence_number': 56627, 'status': 204, } self.reply_bin_0 = b'\x01\xcc\xdd\x33' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SetModifierMapping._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.SetModifierMapping._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.SetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestGetModifierMapping(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x77\x00\x00\x01' self.reply_args_0 = { 'keycodes': [[219, 156], [30, 50], [106, 108], [135, 41], [80, 122], [88, 38], [80, 1], [209, 230]], 'sequence_number': 45434, } self.reply_bin_0 = b'\x01\x02\xb1\x7a' b'\x00\x00\x00\x04' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\xdb\x9c\x1e\x32' b'\x6a\x6c\x87\x29' \ b'\x50\x7a\x58\x26' b'\x50\x01\xd1\xe6' def testPackRequest0(self): bin = request.GetModifierMapping._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetModifierMapping._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestNoOperation(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x7f\x00\x00\x01' def testPackRequest0(self): bin = request.NoOperation._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.NoOperation._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) if __name__ == "__main__": unittest.main() python-xlib-0.33/test/test_requests_le.py000077500000000000000000004455771435211557500207000ustar00rootroot00000000000000#!/usr/bin/env python2 import sys, os sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest from Xlib.protocol import request, event from . import LittleEndianTest as EndianTest from . import DummyDisplay dummy_display = DummyDisplay() class TestCreateWindow(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'background_pixmap': 1373224142, 'background_pixel': 239147199, 'border_pixmap': 53775720, 'border_pixel': 1592533117, 'bit_gravity': 3, 'win_gravity': 2, 'backing_store': 0, 'backing_planes': 299720948, 'backing_pixel': 1581625428, 'override_redirect': 0, 'save_under': 0, 'event_mask': 1268138548, 'do_not_propagate_mask': 906135756, 'colormap': 68318329, 'cursor': 64054583}, 'border_width': 13287, 'depth': 151, 'height': 37037, 'parent': 499701004, 'visual': 1395681732, 'wid': 469587013, 'width': 1995, 'window_class': 2, 'x': -16209, 'y': -13042, } self.req_bin_0 = b'\x01\x97\x17\x00' b'\x45\x54\xfd\x1b' \ b'\x0c\xd5\xc8\x1d' b'\xaf\xc0\x0e\xcd' \ b'\xcb\x07\xad\x90' b'\xe7\x33\x02\x00' \ b'\xc4\x69\x30\x53' b'\xff\x7f\x00\x00' \ b'\xce\xbc\xd9\x51' b'\xbf\x18\x41\x0e' \ b'\x68\x8d\x34\x03' b'\x7d\x20\xec\x5e' \ b'\x03\x00\x00\x00' b'\x02\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\xf4\x60\xdd\x11' \ b'\x54\xb0\x45\x5e' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x34\x42\x96\x4b' \ b'\xcc\x88\x02\x36' b'\x79\x74\x12\x04' \ b'\x37\x65\xd1\x03' def testPackRequest0(self): bin = request.CreateWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestChangeWindowAttributes(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'background_pixmap': 1506149446, 'background_pixel': 1170318459, 'border_pixmap': 900977490, 'border_pixel': 473458160, 'bit_gravity': 6, 'win_gravity': 8, 'backing_store': 1, 'backing_planes': 1738304197, 'backing_pixel': 1866873765, 'override_redirect': 0, 'save_under': 0, 'event_mask': 1499308477, 'do_not_propagate_mask': 907623048, 'colormap': 730747963, 'cursor': 596789700}, 'window': 333955224, } self.req_bin_0 = b'\x02\x00\x12\x00' b'\x98\xc0\xe7\x13' \ b'\xff\x7f\x00\x00' b'\x46\x04\xc6\x59' \ b'\x7b\xa4\xc1\x45' b'\x52\xd3\xb3\x35' \ b'\xf0\x65\x38\x1c' b'\x06\x00\x00\x00' \ b'\x08\x00\x00\x00' b'\x01\x00\x00\x00' \ b'\xc5\x6a\x9c\x67' b'\xa5\x3b\x46\x6f' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\xbd\xa1\x5d\x59' b'\x88\x3a\x19\x36' \ b'\x3b\x54\x8e\x2b' b'\xc4\x49\x92\x23' def testPackRequest0(self): bin = request.ChangeWindowAttributes._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetWindowAttributes(EndianTest): def setUp(self): self.req_args_0 = { 'window': 462448317, } self.req_bin_0 = b'\x03\x00\x02\x00' b'\xbd\x66\x90\x1b' self.reply_args_0 = { 'all_event_masks': 1980679760, 'backing_bit_planes': 1820045833, 'backing_pixel': 738704824, 'backing_store': 214, 'bit_gravity': 152, 'colormap': 2089815718, 'do_not_propagate_mask': 5420, 'map_is_installed': 0, 'map_state': 245, 'override_redirect': 0, 'save_under': 1, 'sequence_number': 6954, 'visual': 199235720, 'win_class': 25154, 'win_gravity': 219, 'your_event_mask': 812961929, } self.reply_bin_0 = b'\x01\xd6\x2a\x1b' b'\x03\x00\x00\x00' \ b'\x88\x18\xe0\x0b' b'\x42\x62\x98\xdb' \ b'\x09\xb2\x7b\x6c' b'\xb8\xbd\x07\x2c' \ b'\x01\x00\xf5\x00' b'\xa6\x0e\x90\x7c' \ b'\x50\xc6\x0e\x76' b'\x89\xd0\x74\x30' \ b'\x2c\x15\x00\x00' def testPackRequest0(self): bin = request.GetWindowAttributes._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetWindowAttributes._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetWindowAttributes._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestDestroyWindow(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1185563768, } self.req_bin_0 = b'\x04\x00\x02\x00' b'\x78\x44\xaa\x46' def testPackRequest0(self): bin = request.DestroyWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.DestroyWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestDestroySubWindows(EndianTest): def setUp(self): self.req_args_0 = { 'window': 629661088, } self.req_bin_0 = b'\x05\x00\x02\x00' b'\xa0\xdd\x87\x25' def testPackRequest0(self): bin = request.DestroySubWindows._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.DestroySubWindows._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestChangeSaveSet(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 1, 'window': 1239919839, } self.req_bin_0 = b'\x06\x01\x02\x00' b'\xdf\xac\xe7\x49' def testPackRequest0(self): bin = request.ChangeSaveSet._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeSaveSet._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestReparentWindow(EndianTest): def setUp(self): self.req_args_0 = { 'parent': 1513122040, 'window': 413002134, 'x': -30489, 'y': -31267, } self.req_bin_0 = b'\x07\x00\x04\x00' b'\x96\xe9\x9d\x18' \ b'\xf8\x68\x30\x5a' b'\xe7\x88\xdd\x85' def testPackRequest0(self): bin = request.ReparentWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ReparentWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestMapWindow(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1420117708, } self.req_bin_0 = b'\x08\x00\x02\x00' b'\xcc\x46\xa5\x54' def testPackRequest0(self): bin = request.MapWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.MapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestMapSubwindows(EndianTest): def setUp(self): self.req_args_0 = { 'window': 489473351, } self.req_bin_0 = b'\x09\x00\x02\x00' b'\x47\xc5\x2c\x1d' def testPackRequest0(self): bin = request.MapSubwindows._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.MapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestUnmapWindow(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1660217157, } self.req_bin_0 = b'\x0a\x00\x02\x00' b'\x45\xe7\xf4\x62' def testPackRequest0(self): bin = request.UnmapWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UnmapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestUnmapSubwindows(EndianTest): def setUp(self): self.req_args_0 = { 'window': 621521446, } self.req_bin_0 = b'\x0b\x00\x02\x00' b'\x26\xaa\x0b\x25' def testPackRequest0(self): bin = request.UnmapSubwindows._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UnmapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestConfigureWindow(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'x': -27539, 'y': -17512, 'width': 39387, 'height': 57679, 'border_width': -14551, 'sibling': 973756745, 'stack_mode': 2}, 'window': 349362548, } self.req_bin_0 = b'\x0c\x00\x0a\x00' b'\x74\xd9\xd2\x14' \ b'\x7f\x00\x00\x00' b'\x6d\x94\x00\x00' \ b'\x98\xbb\x00\x00' b'\xdb\x99\x00\x00' \ b'\x4f\xe1\x00\x00' b'\x29\xc7\x00\x00' \ b'\x49\x59\x0a\x3a' b'\x02\x00\x00\x00' def testPackRequest0(self): bin = request.ConfigureWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ConfigureWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCirculateWindow(EndianTest): def setUp(self): self.req_args_0 = { 'direction': 1, 'window': 763003561, } self.req_bin_0 = b'\x0d\x01\x02\x00' b'\xa9\x82\x7a\x2d' def testPackRequest0(self): bin = request.CirculateWindow._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CirculateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetGeometry(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 449978455, } self.req_bin_0 = b'\x0e\x00\x02\x00' b'\x57\x20\xd2\x1a' self.reply_args_0 = { 'border_width': 41869, 'depth': 196, 'height': 40176, 'root': 2011515940, 'sequence_number': 46250, 'width': 4935, 'x': -10370, 'y': -11534, } self.reply_bin_0 = b'\x01\xc4\xaa\xb4' b'\x00\x00\x00\x00' \ b'\x24\x4c\xe5\x77' b'\x7e\xd7\xf2\xd2' \ b'\x47\x13\xf0\x9c' b'\x8d\xa3\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetGeometry._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetGeometry._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetGeometry._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetGeometry._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestQueryTree(EndianTest): def setUp(self): self.req_args_0 = { 'window': 367582976, } self.req_bin_0 = b'\x0f\x00\x02\x00' b'\x00\xdf\xe8\x15' self.reply_args_0 = { 'children': [1147122179, 1565853418, 525792997, 350969719, 992761785, 814939899, 579774073], 'parent': 1374454548, 'root': 1987327953, 'sequence_number': 65105, } self.reply_bin_0 = b'\x01\x00\x51\xfe' b'\x07\x00\x00\x00' \ b'\xd1\x37\x74\x76' b'\x14\x83\xec\x51' \ b'\x07\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x03\xb2\x5f\x44' b'\xea\x06\x55\x5d' \ b'\xe5\xf6\x56\x1f' b'\x77\x5f\xeb\x14' \ b'\xb9\x57\x2c\x3b' b'\xfb\xfe\x92\x30' \ b'\x79\xa6\x8e\x22' def testPackRequest0(self): bin = request.QueryTree._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryTree._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryTree._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryTree._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestInternAtom(EndianTest): def setUp(self): self.req_args_0 = { 'name': 'fuzzy_prop', 'only_if_exists': 0, } self.req_bin_0 = b'\x10\x00\x05\x00' b'\x0a\x00\x00\x00' \ b'\x66\x75\x7a\x7a' b'\x79\x5f\x70\x72' \ b'\x6f\x70\x00\x00' self.reply_args_0 = { 'atom': 696457407, 'sequence_number': 45122, } self.reply_bin_0 = b'\x01\x00\x42\xb0' b'\x00\x00\x00\x00' \ b'\xbf\x18\x83\x29' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.InternAtom._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.InternAtom._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.InternAtom._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.InternAtom._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestGetAtomName(EndianTest): def setUp(self): self.req_args_0 = { 'atom': 1810076242, } self.req_bin_0 = b'\x11\x00\x02\x00' b'\x52\x92\xe3\x6b' self.reply_args_0 = { 'name': 'WM_CLASS', 'sequence_number': 50608, } self.reply_bin_0 = b'\x01\x00\xb0\xc5' b'\x02\x00\x00\x00' \ b'\x08\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x57\x4d\x5f\x43' b'\x4c\x41\x53\x53' def testPackRequest0(self): bin = request.GetAtomName._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetAtomName._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetAtomName._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetAtomName._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestChangeProperty(EndianTest): def setUp(self): self.req_args_0 = { 'data': (8, b''), 'mode': 0, 'property': 1764873173, 'type': 69000273, 'window': 491942524, } self.req_bin_0 = b'\x12\x00\x06\x00' b'\x7c\x72\x52\x1d' \ b'\xd5\xd3\x31\x69' b'\x51\xdc\x1c\x04' \ b'\x08\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_1 = { 'data': (8, b'foo'), 'mode': 1, 'property': 575034703, 'type': 142204480, 'window': 861560365, } self.req_bin_1 = b'\x12\x01\x07\x00' b'\x2d\x5e\x5a\x33' \ b'\x4f\x55\x46\x22' b'\x40\xde\x79\x08' \ b'\x08\x00\x00\x00' b'\x03\x00\x00\x00' \ b'\x66\x6f\x6f\x00' self.req_args_2 = { 'data': (8, b'zoom'), 'mode': 0, 'property': 2024948722, 'type': 1218075423, 'window': 1961010416, } self.req_bin_2 = b'\x12\x00\x07\x00' b'\xf0\xa4\xe2\x74' \ b'\xf2\x43\xb2\x78' b'\x1f\x5b\x9a\x48' \ b'\x08\x00\x00\x00' b'\x04\x00\x00\x00' \ b'\x7a\x6f\x6f\x6d' self.req_args_3 = { 'data': (16, []), 'mode': 2, 'property': 456677559, 'type': 1407609354, 'window': 675831147, } self.req_bin_3 = b'\x12\x02\x06\x00' b'\x6b\x5d\x48\x28' \ b'\xb7\x58\x38\x1b' b'\x0a\x6a\xe6\x53' \ b'\x10\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_4 = { 'data': (16, [1, 2, 3]), 'mode': 1, 'property': 1899908134, 'type': 1964041522, 'window': 849678568, } self.req_bin_4 = b'\x12\x01\x08\x00' b'\xe8\x10\xa5\x32' \ b'\x26\x4c\x3e\x71' b'\x32\xe5\x10\x75' \ b'\x10\x00\x00\x00' b'\x03\x00\x00\x00' \ b'\x01\x00\x02\x00' b'\x03\x00\x00\x00' self.req_args_5 = { 'data': (16, [1, 2, 3, 4]), 'mode': 2, 'property': 306879937, 'type': 568891375, 'window': 985442388, } self.req_bin_5 = b'\x12\x02\x08\x00' b'\x54\xa8\xbc\x3a' \ b'\xc1\x9d\x4a\x12' b'\xef\x97\xe8\x21' \ b'\x10\x00\x00\x00' b'\x04\x00\x00\x00' \ b'\x01\x00\x02\x00' b'\x03\x00\x04\x00' self.req_args_6 = { 'data': (32, []), 'mode': 0, 'property': 1599917196, 'type': 1205594429, 'window': 529694076, } self.req_bin_6 = b'\x12\x00\x06\x00' b'\x7c\x7d\x92\x1f' \ b'\x8c\xcc\x5c\x5f' b'\x3d\xe9\xdb\x47' \ b'\x20\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_7 = { 'data': (32, [1, 2, 3]), 'mode': 2, 'property': 1604265475, 'type': 1255454396, 'window': 564298846, } self.req_bin_7 = b'\x12\x02\x09\x00' b'\x5e\x84\xa2\x21' \ b'\x03\x26\x9f\x5f' b'\xbc\xb6\xd4\x4a' \ b'\x20\x00\x00\x00' b'\x03\x00\x00\x00' \ b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \ b'\x03\x00\x00\x00' def testPackRequest0(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_1) self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_1) def testPackRequest2(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_2) self.assertBinaryEqual(bin, self.req_bin_2) def testUnpackRequest2(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_2, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_2) def testPackRequest3(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_3) self.assertBinaryEqual(bin, self.req_bin_3) def testUnpackRequest3(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_3, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_3) def testPackRequest4(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_4) self.assertBinaryEqual(bin, self.req_bin_4) def testUnpackRequest4(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_4, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_4) def testPackRequest5(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_5) self.assertBinaryEqual(bin, self.req_bin_5) def testUnpackRequest5(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_5, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_5) def testPackRequest6(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_6) self.assertBinaryEqual(bin, self.req_bin_6) def testUnpackRequest6(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_6, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_6) def testPackRequest7(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_7) self.assertBinaryEqual(bin, self.req_bin_7) def testUnpackRequest7(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_7, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_7) class TestDeleteProperty(EndianTest): def setUp(self): self.req_args_0 = { 'property': 1928125498, 'window': 920120163, } self.req_bin_0 = b'\x13\x00\x03\x00' b'\x63\xeb\xd7\x36' \ b'\x3a\xdc\xec\x72' def testPackRequest0(self): bin = request.DeleteProperty._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.DeleteProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetProperty(EndianTest): def setUp(self): self.req_args_0 = { 'delete': 1, 'long_length': 297130690, 'long_offset': 2142261240, 'property': 471053276, 'type': 2141806322, 'window': 777446987, } self.req_bin_0 = b'\x14\x01\x06\x00' b'\x4b\xe6\x56\x2e' \ b'\xdc\xb3\x13\x1c' b'\xf2\x5e\xa9\x7f' \ b'\xf8\x4f\xb0\x7f' b'\xc2\xda\xb5\x11' self.reply_args_0 = { 'bytes_after': 195292012, 'property_type': 1059882735, 'sequence_number': 33648, 'value': (8, b''), } self.reply_bin_0 = b'\x01\x08\x70\x83' b'\x00\x00\x00\x00' \ b'\xef\x86\x2c\x3f' b'\x6c\xeb\xa3\x0b' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_1 = { 'bytes_after': 1849269963, 'property_type': 101247178, 'sequence_number': 49786, 'value': (8, b'foo'), } self.reply_bin_1 = b'\x01\x08\x7a\xc2' b'\x01\x00\x00\x00' \ b'\xca\xe8\x08\x06' b'\xcb\x9e\x39\x6e' \ b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x66\x6f\x6f\x00' self.reply_args_2 = { 'bytes_after': 1347495650, 'property_type': 328289775, 'sequence_number': 7441, 'value': (8, b'zoom'), } self.reply_bin_2 = b'\x01\x08\x11\x1d' b'\x01\x00\x00\x00' \ b'\xef\x4d\x91\x13' b'\xe2\x26\x51\x50' \ b'\x04\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x7a\x6f\x6f\x6d' self.reply_args_3 = { 'bytes_after': 1461387818, 'property_type': 1701043014, 'sequence_number': 10740, 'value': (16, []), } self.reply_bin_3 = b'\x01\x10\xf4\x29' b'\x00\x00\x00\x00' \ b'\x46\xdb\x63\x65' b'\x2a\x02\x1b\x57' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_4 = { 'bytes_after': 136490248, 'property_type': 1280844186, 'sequence_number': 27922, 'value': (16, [1, 2, 3]), } self.reply_bin_4 = b'\x01\x10\x12\x6d' b'\x02\x00\x00\x00' \ b'\x9a\x21\x58\x4c' b'\x08\xad\x22\x08' \ b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x01\x00\x02\x00' b'\x03\x00\x00\x00' self.reply_args_5 = { 'bytes_after': 1279726180, 'property_type': 819586705, 'sequence_number': 25472, 'value': (16, [1, 2, 3, 4]), } self.reply_bin_5 = b'\x01\x10\x80\x63' b'\x02\x00\x00\x00' \ b'\x91\xe6\xd9\x30' b'\x64\x12\x47\x4c' \ b'\x04\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x01\x00\x02\x00' b'\x03\x00\x04\x00' self.reply_args_6 = { 'bytes_after': 539973238, 'property_type': 1136329940, 'sequence_number': 30930, 'value': (32, []), } self.reply_bin_6 = b'\x01\x20\xd2\x78' b'\x00\x00\x00\x00' \ b'\xd4\x04\xbb\x43' b'\x76\x56\x2f\x20' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_7 = { 'bytes_after': 1848575862, 'property_type': 1188109101, 'sequence_number': 63896, 'value': (32, [1, 2, 3]), } self.reply_bin_7 = b'\x01\x20\x98\xf9' b'\x03\x00\x00\x00' \ b'\x2d\x1b\xd1\x46' b'\x76\x07\x2f\x6e' \ b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \ b'\x03\x00\x00\x00' def testPackRequest0(self): bin = request.GetProperty._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) def testPackReply1(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_1) self.assertBinaryEqual(bin, self.reply_bin_1) def testUnpackReply1(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_1) def testPackReply2(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_2) self.assertBinaryEqual(bin, self.reply_bin_2) def testUnpackReply2(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_2, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_2) def testPackReply3(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_3) self.assertBinaryEqual(bin, self.reply_bin_3) def testUnpackReply3(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_3, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_3) def testPackReply4(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_4) self.assertBinaryEqual(bin, self.reply_bin_4) def testUnpackReply4(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_4, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_4) def testPackReply5(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_5) self.assertBinaryEqual(bin, self.reply_bin_5) def testUnpackReply5(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_5, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_5) def testPackReply6(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_6) self.assertBinaryEqual(bin, self.reply_bin_6) def testUnpackReply6(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_6, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_6) def testPackReply7(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_7) self.assertBinaryEqual(bin, self.reply_bin_7) def testUnpackReply7(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_7, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_7) class TestListProperties(EndianTest): def setUp(self): self.req_args_0 = { 'window': 2023920407, } self.req_bin_0 = b'\x15\x00\x02\x00' b'\x17\x93\xa2\x78' self.reply_args_0 = { 'atoms': [24720840, 1460963027, 1547803868, 246063525, 1464027403, 1900134270, 1153200538, 1612563336, 573068260, 1650618737, 1376520521, 730586807, 239622004, 630352260, 933716813, 339706725, 974429777, 7034796, 2048369638, 1550746425, 1880945398, 1545568005, 565689201], 'sequence_number': 63949, } self.reply_bin_0 = b'\x01\x00\xcd\xf9' b'\x17\x00\x00\x00' \ b'\x17\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\xc8\x35\x79\x01' b'\xd3\x86\x14\x57' \ b'\xdc\x9c\x41\x5c' b'\xa5\xa1\xaa\x0e' \ b'\x0b\x49\x43\x57' b'\x7e\xbf\x41\x71' \ b'\x9a\x71\xbc\x44' b'\x88\xc3\x1d\x60' \ b'\xe4\x53\x28\x22' b'\x71\x71\x62\x62' \ b'\x49\x09\x0c\x52' b'\xb7\xde\x8b\x2b' \ b'\x74\x57\x48\x0e' b'\x84\x69\x92\x25' \ b'\x4d\x63\xa7\x37' b'\x65\x83\x3f\x14' \ b'\x51\x9e\x14\x3a' b'\xac\x57\x6b\x00' \ b'\xe6\xa3\x17\x7a' b'\x39\x83\x6e\x5c' \ b'\xf6\xf2\x1c\x70' b'\x05\x7f\x1f\x5c' \ b'\x71\xbb\xb7\x21' def testPackRequest0(self): bin = request.ListProperties._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListProperties._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListProperties._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListProperties._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestSetSelectionOwner(EndianTest): def setUp(self): self.req_args_0 = { 'selection': 1636366903, 'time': 383717530, 'window': 1075066031, } self.req_bin_0 = b'\x16\x00\x04\x00' b'\xaf\x34\x14\x40' \ b'\x37\xfa\x88\x61' b'\x9a\x10\xdf\x16' def testPackRequest0(self): bin = request.SetSelectionOwner._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetSelectionOwner(EndianTest): def setUp(self): self.req_args_0 = { 'selection': 1090303630, } self.req_bin_0 = b'\x17\x00\x02\x00' b'\x8e\xb6\xfc\x40' self.reply_args_0 = { 'owner': 228581038, 'sequence_number': 60065, } self.reply_bin_0 = b'\x01\x00\xa1\xea' b'\x00\x00\x00\x00' \ b'\xae\xde\x9f\x0d' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetSelectionOwner._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetSelectionOwner._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetSelectionOwner._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestConvertSelection(EndianTest): def setUp(self): self.req_args_0 = { 'property': 1807536699, 'requestor': 1869489931, 'selection': 1342887479, 'target': 640970836, 'time': 1372199123, } self.req_bin_0 = b'\x18\x00\x06\x00' b'\x0b\x27\x6e\x6f' \ b'\x37\xd6\x0a\x50' b'\x54\x70\x34\x26' \ b'\x3b\xd2\xbc\x6b' b'\xd3\x18\xca\x51' def testPackRequest0(self): bin = request.ConvertSelection._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ConvertSelection._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestSendEvent(EndianTest): def setUp(self): self.req_args_0 = { 'destination': 1158373169, 'event': event.Expose(count=50227, height=24760, sequence_number=0, type=12, width=10272, window=1090263274, x=40165, y=13291), 'event_mask': 2047690655, 'propagate': 0, } self.req_bin_0 = b'\x19\x00\x0b\x00' b'\x31\x5f\x0b\x45' \ b'\x9f\x47\x0d\x7a' b'\x0c\x00\x00\x00' \ b'\xea\x18\xfc\x40' b'\xe5\x9c\xeb\x33' \ b'\x20\x28\xb8\x60' b'\x33\xc4\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SendEvent._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SendEvent._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGrabPointer(EndianTest): def setUp(self): self.req_args_0 = { 'confine_to': 240299645, 'cursor': 1995289624, 'event_mask': 21499, 'grab_window': 1286289242, 'keyboard_mode': 0, 'owner_events': 0, 'pointer_mode': 1, 'time': 779560794, } self.req_bin_0 = b'\x1a\x00\x06\x00' b'\x5a\x37\xab\x4c' \ b'\xfb\x53\x01\x00' b'\x7d\xae\x52\x0e' \ b'\x18\xb4\xed\x76' b'\x5a\x27\x77\x2e' self.reply_args_0 = { 'sequence_number': 15948, 'status': 206, } self.reply_bin_0 = b'\x01\xce\x4c\x3e' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GrabPointer._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GrabPointer._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GrabPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestUngrabPointer(EndianTest): def setUp(self): self.req_args_0 = { 'time': 124458893, } self.req_bin_0 = b'\x1b\x00\x02\x00' b'\x8d\x17\x6b\x07' def testPackRequest0(self): bin = request.UngrabPointer._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGrabButton(EndianTest): def setUp(self): self.req_args_0 = { 'button': 145, 'confine_to': 1571825127, 'cursor': 1043722096, 'event_mask': 37438, 'grab_window': 1885576796, 'keyboard_mode': 0, 'modifiers': 64349, 'owner_events': 0, 'pointer_mode': 0, } self.req_bin_0 = b'\x1c\x00\x06\x00' b'\x5c\x9e\x63\x70' \ b'\x3e\x92\x00\x00' b'\xe7\x25\xb0\x5d' \ b'\x70\xef\x35\x3e' b'\x91\x00\x5d\xfb' def testPackRequest0(self): bin = request.GrabButton._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestUngrabButton(EndianTest): def setUp(self): self.req_args_0 = { 'button': 160, 'grab_window': 275784110, 'modifiers': 43493, } self.req_bin_0 = b'\x1d\xa0\x03\x00' b'\xae\x21\x70\x10' \ b'\xe5\xa9\x00\x00' def testPackRequest0(self): bin = request.UngrabButton._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestChangeActivePointerGrab(EndianTest): def setUp(self): self.req_args_0 = { 'cursor': 1020726671, 'event_mask': 36287, 'time': 2033407590, } self.req_bin_0 = b'\x1e\x00\x04\x00' b'\x8f\x0d\xd7\x3c' \ b'\x66\x56\x33\x79' b'\xbf\x8d\x00\x00' def testPackRequest0(self): bin = request.ChangeActivePointerGrab._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeActivePointerGrab._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGrabKeyboard(EndianTest): def setUp(self): self.req_args_0 = { 'grab_window': 569270305, 'keyboard_mode': 0, 'owner_events': 0, 'pointer_mode': 1, 'time': 1133236353, } self.req_bin_0 = b'\x1f\x00\x04\x00' b'\x21\x60\xee\x21' \ b'\x81\xd0\x8b\x43' b'\x01\x00\x00\x00' self.reply_args_0 = { 'sequence_number': 46979, 'status': 179, } self.reply_bin_0 = b'\x01\xb3\x83\xb7' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GrabKeyboard._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GrabKeyboard._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GrabKeyboard._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestUngrabKeyboard(EndianTest): def setUp(self): self.req_args_0 = { 'time': 669471181, } self.req_bin_0 = b'\x20\x00\x02\x00' b'\xcd\x51\xe7\x27' def testPackRequest0(self): bin = request.UngrabKeyboard._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGrabKey(EndianTest): def setUp(self): self.req_args_0 = { 'grab_window': 2137132511, 'key': 223, 'keyboard_mode': 1, 'modifiers': 44275, 'owner_events': 1, 'pointer_mode': 1, } self.req_bin_0 = b'\x21\x01\x04\x00' b'\xdf\x0d\x62\x7f' \ b'\xf3\xac\xdf\x01' b'\x01\x00\x00\x00' def testPackRequest0(self): bin = request.GrabKey._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestUngrabKey(EndianTest): def setUp(self): self.req_args_0 = { 'grab_window': 532438798, 'key': 158, 'modifiers': 14981, } self.req_bin_0 = b'\x22\x9e\x03\x00' b'\x0e\x5f\xbc\x1f' \ b'\x85\x3a\x00\x00' def testPackRequest0(self): bin = request.UngrabKey._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestAllowEvents(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 1, 'time': 726098765, } self.req_bin_0 = b'\x23\x01\x02\x00' b'\x4d\x63\x47\x2b' def testPackRequest0(self): bin = request.AllowEvents._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllowEvents._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGrabServer(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x24\x00\x01\x00' def testPackRequest0(self): bin = request.GrabServer._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestUngrabServer(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x25\x00\x01\x00' def testPackRequest0(self): bin = request.UngrabServer._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestQueryPointer(EndianTest): def setUp(self): self.req_args_0 = { 'window': 45236268, } self.req_bin_0 = b'\x26\x00\x02\x00' b'\x2c\x40\xb2\x02' self.reply_args_0 = { 'child': 15507755, 'mask': 15259, 'root': 472978779, 'root_x': -30442, 'root_y': -9574, 'same_screen': 0, 'sequence_number': 38820, 'win_x': -12089, 'win_y': -30839, } self.reply_bin_0 = b'\x01\x00\xa4\x97' b'\x00\x00\x00\x00' \ b'\x5b\x15\x31\x1c' b'\x2b\xa1\xec\x00' \ b'\x16\x89\x9a\xda' b'\xc7\xd0\x89\x87' \ b'\x9b\x3b\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryPointer._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryPointer._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestGetMotionEvents(EndianTest): def setUp(self): self.req_args_0 = { 'start': 1944440211, 'stop': 67524349, 'window': 144806627, } self.req_bin_0 = b'\x27\x00\x04\x00' b'\xe3\x92\xa1\x08' \ b'\x93\xcd\xe5\x73' b'\xfd\x56\x06\x04' self.reply_args_0 = { 'events': [{'time': 1846118496, 'x': -21941, 'y': -30447}, {'time': 1104207400, 'x': -24970, 'y': -23643}, {'time': 1436684371, 'x': -16862, 'y': -25748}, {'time': 1158061593, 'x': -28433, 'y': -9066}, {'time': 2009067067, 'x': -3855, 'y': -14057}], 'sequence_number': 38018, } self.reply_bin_0 = b'\x01\x00\x82\x94' b'\x0a\x00\x00\x00' \ b'\x05\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x60\x88\x09\x6e' b'\x4b\xaa\x11\x89' \ b'\x28\xde\xd0\x41' b'\x76\x9e\xa5\xa3' \ b'\x53\x10\xa2\x55' b'\x22\xbe\x6c\x9b' \ b'\x19\x9e\x06\x45' b'\xef\x90\x96\xdc' \ b'\x3b\xee\xbf\x77' b'\xf1\xf0\x17\xc9' def testPackRequest0(self): bin = request.GetMotionEvents._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetMotionEvents._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetMotionEvents._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetMotionEvents._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestTranslateCoords(EndianTest): def setUp(self): self.req_args_0 = { 'dst_wid': 521898132, 'src_wid': 1015118844, 'src_x': -7058, 'src_y': -17270, } self.req_bin_0 = b'\x28\x00\x04\x00' b'\xfc\x7b\x81\x3c' \ b'\x94\x88\x1b\x1f' b'\x6e\xe4\x8a\xbc' self.reply_args_0 = { 'child': 202628650, 'same_screen': 1, 'sequence_number': 12734, 'x': -29592, 'y': -11175, } self.reply_bin_0 = b'\x01\x01\xbe\x31' b'\x00\x00\x00\x00' \ b'\x2a\xde\x13\x0c' b'\x68\x8c\x59\xd4' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.TranslateCoords._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.TranslateCoords._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.TranslateCoords._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.TranslateCoords._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestWarpPointer(EndianTest): def setUp(self): self.req_args_0 = { 'dst_window': 760913775, 'dst_x': -8878, 'dst_y': -30993, 'src_height': 56868, 'src_width': 30862, 'src_window': 925740905, 'src_x': -18889, 'src_y': -19298, } self.req_bin_0 = b'\x29\x00\x06\x00' b'\x69\xaf\x2d\x37' \ b'\x6f\x9f\x5a\x2d' b'\x37\xb6\x9e\xb4' \ b'\x8e\x78\x24\xde' b'\x52\xdd\xef\x86' def testPackRequest0(self): bin = request.WarpPointer._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.WarpPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestSetInputFocus(EndianTest): def setUp(self): self.req_args_0 = { 'focus': 1403350503, 'revert_to': 2, 'time': 2113544232, } self.req_bin_0 = b'\x2a\x02\x03\x00' b'\xe7\x6d\xa5\x53' \ b'\x28\x20\xfa\x7d' def testPackRequest0(self): bin = request.SetInputFocus._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetInputFocus(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x2b\x00\x01\x00' self.reply_args_0 = { 'focus': 864688157, 'revert_to': 153, 'sequence_number': 4228, } self.reply_bin_0 = b'\x01\x99\x84\x10' b'\x00\x00\x00\x00' \ b'\x1d\x18\x8a\x33' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetInputFocus._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetInputFocus._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetInputFocus._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestQueryKeymap(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x2c\x00\x01\x00' self.reply_args_0 = { 'map': [214, 155, 191, 177, 176, 242, 163, 236, 174, 199, 246, 191, 147, 241, 153, 140, 131, 151, 188, 170, 232, 252, 251, 182, 230, 143, 170, 225, 128, 227, 195, 244], 'sequence_number': 18950, } self.reply_bin_0 = b'\x01\x00\x06\x4a' b'\x02\x00\x00\x00' \ b'\xd6\x9b\xbf\xb1' b'\xb0\xf2\xa3\xec' \ b'\xae\xc7\xf6\xbf' b'\x93\xf1\x99\x8c' \ b'\x83\x97\xbc\xaa' b'\xe8\xfc\xfb\xb6' \ b'\xe6\x8f\xaa\xe1' b'\x80\xe3\xc3\xf4' def testPackRequest0(self): bin = request.QueryKeymap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryKeymap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryKeymap._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryKeymap._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestOpenFont(EndianTest): def setUp(self): self.req_args_0 = { 'fid': 908467189, 'name': 'foofont', } self.req_bin_0 = b'\x2d\x00\x05\x00' b'\xf5\x1b\x26\x36' \ b'\x07\x00\x00\x00' b'\x66\x6f\x6f\x66' \ b'\x6f\x6e\x74\x00' def testPackRequest0(self): bin = request.OpenFont._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.OpenFont._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCloseFont(EndianTest): def setUp(self): self.req_args_0 = { 'font': 1495984396, } self.req_bin_0 = b'\x2e\x00\x02\x00' b'\x0c\xe9\x2a\x59' def testPackRequest0(self): bin = request.CloseFont._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CloseFont._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestQueryFont(EndianTest): def setUp(self): self.req_args_0 = { 'font': 2055889505, } self.req_bin_0 = b'\x2f\x00\x02\x00' b'\x61\x62\x8a\x7a' self.reply_args_0 = { 'all_chars_exist': 0, 'char_infos': [{'left_side_bearing': -7099, 'right_side_bearing': -14557, 'character_width': -11080, 'ascent': -9228, 'descent': -16821, 'attributes': 10400}, {'left_side_bearing': -26546, 'right_side_bearing': -23046, 'character_width': -25635, 'ascent': -1026, 'descent': -30852, 'attributes': 38213}, {'left_side_bearing': -8660, 'right_side_bearing': -15002, 'character_width': -30771, 'ascent': -8259, 'descent': -22492, 'attributes': 4002}], 'default_char': 39252, 'draw_direction': 145, 'font_ascent': -1914, 'font_descent': -3596, 'max_bounds': {'left_side_bearing': -27610, 'right_side_bearing': -30905, 'character_width': -1286, 'ascent': -16128, 'descent': -30143, 'attributes': 56049}, 'max_byte1': 231, 'max_char_or_byte2': 4746, 'min_bounds': {'left_side_bearing': -13626, 'right_side_bearing': -17145, 'character_width': -16291, 'ascent': -2642, 'descent': -4827, 'attributes': 35063}, 'min_byte1': 188, 'min_char_or_byte2': 12434, 'properties': [{'name': 1568813755, 'value': 2137719486}], 'sequence_number': 3542, } self.reply_bin_0 = b'\x01\x00\xd6\x0d' b'\x12\x00\x00\x00' \ b'\xc6\xca\x07\xbd' b'\x5d\xc0\xae\xf5' \ b'\x25\xed\xf7\x88' b'\x00\x00\x00\x00' \ b'\x26\x94\x47\x87' b'\xfa\xfa\x00\xc1' \ b'\x41\x8a\xf1\xda' b'\x00\x00\x00\x00' \ b'\x92\x30\x8a\x12' b'\x54\x99\x01\x00' \ b'\x91\xbc\xe7\x00' b'\x86\xf8\xf4\xf1' \ b'\x03\x00\x00\x00' b'\xbb\x32\x82\x5d' \ b'\xbe\x02\x6b\x7f' b'\x45\xe4\x23\xc7' \ b'\xb8\xd4\xf4\xdb' b'\x4b\xbe\xa0\x28' \ b'\x4e\x98\xfa\xa5' b'\xdd\x9b\xfe\xfb' \ b'\x7c\x87\x45\x95' b'\x2c\xde\x66\xc5' \ b'\xcd\x87\xbd\xdf' b'\x24\xa8\xa2\x0f' def testPackRequest0(self): bin = request.QueryFont._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryFont._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryFont._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryFont._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestQueryTextExtents(EndianTest): def setUp(self): self.req_args_0 = { 'font': 1223434172, 'string': (102, 111, 111), } self.req_bin_0 = b'\x30\x01\x04\x00' b'\xbc\x1f\xec\x48' \ b'\x00\x66\x00\x6f' b'\x00\x6f\x00\x00' self.reply_args_0 = { 'draw_direction': 191, 'font_ascent': -13287, 'font_descent': -31466, 'overall_ascent': -12473, 'overall_descent': -30082, 'overall_left': -735785526, 'overall_right': -894056953, 'overall_width': -1247205006, 'sequence_number': 38196, } self.reply_bin_0 = b'\x01\xbf\x34\x95' b'\x00\x00\x00\x00' \ b'\x19\xcc\x16\x85' b'\x47\xcf\x7e\x8a' \ b'\x72\x29\xa9\xb5' b'\xca\xcd\x24\xd4' \ b'\x07\xc6\xb5\xca' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryTextExtents._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryTextExtents._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryTextExtents._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryTextExtents._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestListFonts(EndianTest): def setUp(self): self.req_args_0 = { 'max_names': 37298, 'pattern': 'bhazr', } self.req_bin_0 = b'\x31\x00\x04\x00' b'\xb2\x91\x05\x00' \ b'\x62\x68\x61\x7a' b'\x72\x00\x00\x00' self.reply_args_0 = { 'fonts': ['fie', 'fuzzy', 'foozooom'], 'sequence_number': 34517, } self.reply_bin_0 = b'\x01\x00\xd5\x86' b'\x05\x00\x00\x00' \ b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x03\x66\x69\x65' b'\x05\x66\x75\x7a' \ b'\x7a\x79\x08\x66' b'\x6f\x6f\x7a\x6f' \ b'\x6f\x6f\x6d\x00' def testPackRequest0(self): bin = request.ListFonts._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListFonts._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListFonts._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListFonts._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestListFontsWithInfo(EndianTest): def setUp(self): self.req_args_0 = { 'max_names': 20989, 'pattern': 'bhazr2', } self.req_bin_0 = b'\x32\x00\x04\x00' b'\xfd\x51\x06\x00' \ b'\x62\x68\x61\x7a' b'\x72\x32\x00\x00' self.reply_args_0 = { 'all_chars_exist': 0, 'default_char': 61580, 'draw_direction': 146, 'font_ascent': -30368, 'font_descent': -15151, 'max_bounds': {'left_side_bearing': -28480, 'right_side_bearing': -10759, 'character_width': -11617, 'ascent': -22938, 'descent': -17786, 'attributes': 20976}, 'max_byte1': 245, 'max_char_or_byte2': 49530, 'min_bounds': {'left_side_bearing': -10823, 'right_side_bearing': -9300, 'character_width': -22473, 'ascent': -24947, 'descent': -24065, 'attributes': 26194}, 'min_byte1': 130, 'min_char_or_byte2': 61140, 'name': 'fontfont', 'properties': [{'name': 2007331946, 'value': 560055601}], 'replies_hint': 457810933, 'sequence_number': 13642, } self.reply_bin_0 = b'\x01\x08\x4a\x35' b'\x0b\x00\x00\x00' \ b'\xb9\xd5\xac\xdb' b'\x37\xa8\x8d\x9e' \ b'\xff\xa1\x52\x66' b'\x00\x00\x00\x00' \ b'\xc0\x90\xf9\xd5' b'\x9f\xd2\x66\xa6' \ b'\x86\xba\xf0\x51' b'\x00\x00\x00\x00' \ b'\xd4\xee\x7a\xc1' b'\x8c\xf0\x01\x00' \ b'\x92\x82\xf5\x00' b'\x60\x89\xd1\xc4' \ b'\xf5\xa3\x49\x1b' b'\x6a\x74\xa5\x77' \ b'\x31\xc5\x61\x21' b'\x66\x6f\x6e\x74' \ b'\x66\x6f\x6e\x74' def testPackRequest0(self): bin = request.ListFontsWithInfo._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListFontsWithInfo._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListFontsWithInfo._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListFontsWithInfo._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestSetFontPath(EndianTest): def setUp(self): self.req_args_0 = { 'path': ['foo', 'bar', 'gazonk'], } self.req_bin_0 = b'\x33\x00\x06\x00' b'\x03\x00\x00\x00' \ b'\x03\x66\x6f\x6f' b'\x03\x62\x61\x72' \ b'\x06\x67\x61\x7a' b'\x6f\x6e\x6b\x00' self.req_args_1 = { 'path': [], } self.req_bin_1 = b'\x33\x00\x02\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SetFontPath._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.SetFontPath._request.to_binary(*(), **self.req_args_1) self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.SetFontPath._request.parse_binary(self.req_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_1) class TestGetFontPath(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x34\x00\x01\x00' self.reply_args_0 = { 'paths': ['path1', 'path2232'], 'sequence_number': 33409, } self.reply_bin_0 = b'\x01\x00\x81\x82' b'\x04\x00\x00\x00' \ b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x05\x70\x61\x74' b'\x68\x31\x08\x70' \ b'\x61\x74\x68\x32' b'\x32\x33\x32\x00' self.reply_args_1 = { 'paths': [], 'sequence_number': 17636, } self.reply_bin_1 = b'\x01\x00\xe4\x44' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetFontPath._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetFontPath._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) def testPackReply1(self): bin = request.GetFontPath._reply.to_binary(*(), **self.reply_args_1) self.assertBinaryEqual(bin, self.reply_bin_1) def testUnpackReply1(self): args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_1) class TestCreatePixmap(EndianTest): def setUp(self): self.req_args_0 = { 'depth': 161, 'drawable': 749556300, 'height': 4764, 'pid': 2004224799, 'width': 57984, } self.req_bin_0 = b'\x35\xa1\x04\x00' b'\x1f\x0b\x76\x77' \ b'\x4c\x52\xad\x2c' b'\x80\xe2\x9c\x12' def testPackRequest0(self): bin = request.CreatePixmap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreatePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestFreePixmap(EndianTest): def setUp(self): self.req_args_0 = { 'pixmap': 1888284001, } self.req_bin_0 = b'\x36\x00\x02\x00' b'\x61\xed\x8c\x70' def testPackRequest0(self): bin = request.FreePixmap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCreateGC(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'function': 7, 'plane_mask': 793618921, 'foreground': 612071305, 'background': 338824284, 'line_width': 61484, 'line_style': 2, 'cap_style': 2, 'join_style': 2, 'fill_style': 0, 'fill_rule': 1, 'tile': 2000996399, 'stipple': 1424681955, 'tile_stipple_x_origin': -25980, 'tile_stipple_y_origin': -23968, 'font': 568001783, 'subwindow_mode': 0, 'graphics_exposures': 0, 'clip_x_origin': -22581, 'clip_y_origin': -14920, 'clip_mask': 605132525, 'dash_offset': 46571, 'dashes': 215, 'arc_mode': 0}, 'cid': 1476454377, 'drawable': 1362081172, } self.req_bin_0 = b'\x37\x00\x1b\x00' b'\xe9\xe7\x00\x58' \ b'\x94\xb5\x2f\x51' b'\xff\xff\x7f\x00' \ b'\x07\x00\x00\x00' b'\xe9\xa9\x4d\x2f' \ b'\x89\x77\x7b\x24' b'\x5c\x0c\x32\x14' \ b'\x2c\xf0\x00\x00' b'\x02\x00\x00\x00' \ b'\x02\x00\x00\x00' b'\x02\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x01\x00\x00\x00' \ b'\x2f\xc8\x44\x77' b'\xe3\xeb\xea\x54' \ b'\x84\x9a\x00\x00' b'\x60\xa2\x00\x00' \ b'\xf7\x04\xdb\x21' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\xcb\xa7\x00\x00' \ b'\xb8\xc5\x00\x00' b'\xed\x96\x11\x24' \ b'\xeb\xb5\x00\x00' b'\xd7\x00\x00\x00' \ b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.CreateGC._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateGC._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestChangeGC(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'function': 8, 'plane_mask': 1085423224, 'foreground': 1049179696, 'background': 539344312, 'line_width': 36097, 'line_style': 0, 'cap_style': 3, 'join_style': 1, 'fill_style': 0, 'fill_rule': 0, 'tile': 716372747, 'stipple': 1656031462, 'tile_stipple_x_origin': -24195, 'tile_stipple_y_origin': -15601, 'font': 347060191, 'subwindow_mode': 1, 'graphics_exposures': 1, 'clip_x_origin': -32135, 'clip_y_origin': -25437, 'clip_mask': 161650480, 'dash_offset': 42536, 'dashes': 137, 'arc_mode': 1}, 'gc': 1250995304, } self.req_bin_0 = b'\x38\x00\x1a\x00' b'\x68\xac\x90\x4a' \ b'\xff\xff\x7f\x00' b'\x08\x00\x00\x00' \ b'\x78\x3e\xb2\x40' b'\x30\x36\x89\x3e' \ b'\xb8\xbd\x25\x20' b'\x01\x8d\x00\x00' \ b'\x00\x00\x00\x00' b'\x03\x00\x00\x00' \ b'\x01\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x0b\xfb\xb2\x2a' \ b'\xe6\x08\xb5\x62' b'\x7d\xa1\x00\x00' \ b'\x0f\xc3\x00\x00' b'\xdf\xb7\xaf\x14' \ b'\x01\x00\x00\x00' b'\x01\x00\x00\x00' \ b'\x79\x82\x00\x00' b'\xa3\x9c\x00\x00' \ b'\x30\x97\xa2\x09' b'\x28\xa6\x00\x00' \ b'\x89\x00\x00\x00' b'\x01\x00\x00\x00' def testPackRequest0(self): bin = request.ChangeGC._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeGC._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCopyGC(EndianTest): def setUp(self): self.req_args_0 = { 'dst_gc': 318094523, 'mask': 923025483, 'src_gc': 1186604145, } self.req_bin_0 = b'\x39\x00\x04\x00' b'\x71\x24\xba\x46' \ b'\xbb\xbc\xf5\x12' b'\x4b\x40\x04\x37' def testPackRequest0(self): bin = request.CopyGC._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyGC._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestSetDashes(EndianTest): def setUp(self): self.req_args_0 = { 'dash_offset': 51381, 'dashes': [160, 138, 206, 221, 138, 219, 181, 191, 154], 'gc': 759584613, } self.req_bin_0 = b'\x3a\x00\x06\x00' b'\x65\x57\x46\x2d' \ b'\xb5\xc8\x09\x00' b'\xa0\x8a\xce\xdd' \ b'\x8a\xdb\xb5\xbf' b'\x9a\x00\x00\x00' def testPackRequest0(self): bin = request.SetDashes._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetDashes._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestSetClipRectangles(EndianTest): def setUp(self): self.req_args_0 = { 'gc': 1856792138, 'ordering': 1, 'rectangles': [{'x': -14422, 'y': -3797, 'width': 57581, 'height': 26888}, {'x': -858, 'y': -12431, 'width': 49373, 'height': 10384}], 'x_origin': -27444, 'y_origin': -780, } self.req_bin_0 = b'\x3b\x01\x07\x00' b'\x4a\x66\xac\x6e' \ b'\xcc\x94\xf4\xfc' b'\xaa\xc7\x2b\xf1' \ b'\xed\xe0\x08\x69' b'\xa6\xfc\x71\xcf' \ b'\xdd\xc0\x90\x28' self.req_args_1 = { 'gc': 1892892424, 'ordering': 1, 'rectangles': [], 'x_origin': -19258, 'y_origin': -31956, } self.req_bin_1 = b'\x3b\x01\x03\x00' b'\x08\x3f\xd3\x70' \ b'\xc6\xb4\x2c\x83' def testPackRequest0(self): bin = request.SetClipRectangles._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.SetClipRectangles._request.to_binary(*(), **self.req_args_1) self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_1) class TestFreeGC(EndianTest): def setUp(self): self.req_args_0 = { 'gc': 385239625, } self.req_bin_0 = b'\x3c\x00\x02\x00' b'\x49\x4a\xf6\x16' def testPackRequest0(self): bin = request.FreeGC._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeGC._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestClearArea(EndianTest): def setUp(self): self.req_args_0 = { 'exposures': 1, 'height': 44159, 'width': 52831, 'window': 1680227732, 'x': -2268, 'y': -19277, } self.req_bin_0 = b'\x3d\x01\x04\x00' b'\x94\x3d\x26\x64' \ b'\x24\xf7\xb3\xb4' b'\x5f\xce\x7f\xac' def testPackRequest0(self): bin = request.ClearArea._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ClearArea._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCopyArea(EndianTest): def setUp(self): self.req_args_0 = { 'dst_drawable': 1578589574, 'dst_x': -27552, 'dst_y': -6968, 'gc': 1741136437, 'height': 7340, 'src_drawable': 1855628899, 'src_x': -24637, 'src_y': -24026, 'width': 46214, } self.req_bin_0 = b'\x3e\x00\x07\x00' b'\x63\xa6\x9a\x6e' \ b'\x86\x5d\x17\x5e' b'\x35\xa2\xc7\x67' \ b'\xc3\x9f\x26\xa2' b'\x60\x94\xc8\xe4' \ b'\x86\xb4\xac\x1c' def testPackRequest0(self): bin = request.CopyArea._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyArea._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCopyPlane(EndianTest): def setUp(self): self.req_args_0 = { 'bit_plane': 988559210, 'dst_drawable': 1873029448, 'dst_x': -25480, 'dst_y': -26229, 'gc': 83225989, 'height': 60447, 'src_drawable': 821567629, 'src_x': -4634, 'src_y': -17345, 'width': 53771, } self.req_bin_0 = b'\x3f\x00\x08\x00' b'\x8d\x20\xf8\x30' \ b'\x48\x29\xa4\x6f' b'\x85\xed\xf5\x04' \ b'\xe6\xed\x3f\xbc' b'\x78\x9c\x8b\x99' \ b'\x0b\xd2\x1f\xec' b'\x6a\x37\xec\x3a' def testPackRequest0(self): bin = request.CopyPlane._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyPlane._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyPoint(EndianTest): def setUp(self): self.req_args_0 = { 'coord_mode': 0, 'drawable': 50884525, 'gc': 1417476013, 'points': [{'x': -21311, 'y': -22768}, {'x': -5881, 'y': -6707}, {'x': -4217, 'y': -25311}], } self.req_bin_0 = b'\x40\x00\x06\x00' b'\xad\x6f\x08\x03' \ b'\xad\xf7\x7c\x54' b'\xc1\xac\x10\xa7' \ b'\x07\xe9\xcd\xe5' b'\x87\xef\x21\x9d' def testPackRequest0(self): bin = request.PolyPoint._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyPoint._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyLine(EndianTest): def setUp(self): self.req_args_0 = { 'coord_mode': 1, 'drawable': 1459319574, 'gc': 2107068434, 'points': [{'x': -26440, 'y': -19712}, {'x': -22012, 'y': -23639}, {'x': -4445, 'y': -30494}, {'x': -1085, 'y': -7428}, {'x': -23622, 'y': -21262}], } self.req_bin_0 = b'\x41\x01\x08\x00' b'\x16\x73\xfb\x56' \ b'\x12\x50\x97\x7d' b'\xb8\x98\x00\xb3' \ b'\x04\xaa\xa9\xa3' b'\xa3\xee\xe2\x88' \ b'\xc3\xfb\xfc\xe2' b'\xba\xa3\xf2\xac' def testPackRequest0(self): bin = request.PolyLine._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyLine._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolySegment(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 59337240, 'gc': 247760051, 'segments': [{'x1': -5123, 'y1': -15198, 'x2': -21917, 'y2': -1992}], } self.req_bin_0 = b'\x42\x00\x05\x00' b'\x18\x6a\x89\x03' \ b'\xb3\x84\xc4\x0e' b'\xfd\xeb\xa2\xc4' \ b'\x63\xaa\x38\xf8' def testPackRequest0(self): bin = request.PolySegment._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolySegment._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyRectangle(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 742422946, 'gc': 1564604140, 'rectangles': [{'x': -4030, 'y': -970, 'width': 17374, 'height': 11958}, {'x': -13744, 'y': -1228, 'width': 64713, 'height': 17653}, {'x': -31515, 'y': -29216, 'width': 39352, 'height': 28735}], } self.req_bin_0 = b'\x43\x00\x09\x00' b'\xa2\x79\x40\x2c' \ b'\xec\xf6\x41\x5d' b'\x42\xf0\x36\xfc' \ b'\xde\x43\xb6\x2e' b'\x50\xca\x34\xfb' \ b'\xc9\xfc\xf5\x44' b'\xe5\x84\xe0\x8d' \ b'\xb8\x99\x3f\x70' def testPackRequest0(self): bin = request.PolyRectangle._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyArc(EndianTest): def setUp(self): self.req_args_0 = { 'arcs': [{'x': -6999, 'y': -22490, 'width': 28855, 'height': 39984, 'angle1': -517, 'angle2': -16010}, {'x': -28979, 'y': -20146, 'width': 59205, 'height': 38043, 'angle1': -26540, 'angle2': -24422}, {'x': -31314, 'y': -9543, 'width': 28833, 'height': 366, 'angle1': -15732, 'angle2': -2439}], 'drawable': 1732034432, 'gc': 1156382390, } self.req_bin_0 = b'\x44\x00\x0c\x00' b'\x80\xbf\x3c\x67' \ b'\xb6\xfe\xec\x44' b'\xa9\xe4\x26\xa8' \ b'\xb7\x70\x30\x9c' b'\xfb\xfd\x76\xc1' \ b'\xcd\x8e\x4e\xb1' b'\x45\xe7\x9b\x94' \ b'\x54\x98\x9a\xa0' b'\xae\x85\xb9\xda' \ b'\xa1\x70\x6e\x01' b'\x8c\xc2\x79\xf6' def testPackRequest0(self): bin = request.PolyArc._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyArc._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestFillPoly(EndianTest): def setUp(self): self.req_args_0 = { 'coord_mode': 0, 'drawable': 423195261, 'gc': 782225195, 'points': [{'x': -10262, 'y': -9194}, {'x': -1958, 'y': -8456}, {'x': -8617, 'y': -10793}], 'shape': 1, } self.req_bin_0 = b'\x45\x00\x07\x00' b'\x7d\x72\x39\x19' \ b'\x2b\xcf\x9f\x2e' b'\x01\x00\x00\x00' \ b'\xea\xd7\x16\xdc' b'\x5a\xf8\xf8\xde' \ b'\x57\xde\xd7\xd5' def testPackRequest0(self): bin = request.FillPoly._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FillPoly._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyFillRectangle(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 267696363, 'gc': 1545726032, 'rectangles': [{'x': -1676, 'y': -11003, 'width': 60599, 'height': 21895}, {'x': -12349, 'y': -22482, 'width': 43731, 'height': 55831}], } self.req_bin_0 = b'\x46\x00\x07\x00' b'\xeb\xb8\xf4\x0f' \ b'\x50\xe8\x21\x5c' b'\x74\xf9\x05\xd5' \ b'\xb7\xec\x87\x55' b'\xc3\xcf\x2e\xa8' \ b'\xd3\xaa\x17\xda' def testPackRequest0(self): bin = request.PolyFillRectangle._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyFillRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyFillArc(EndianTest): def setUp(self): self.req_args_0 = { 'arcs': [{'x': -3276, 'y': -22928, 'width': 33490, 'height': 20525, 'angle1': -10916, 'angle2': -19386}], 'drawable': 700537986, 'gc': 864213787, } self.req_bin_0 = b'\x47\x00\x06\x00' b'\x82\x5c\xc1\x29' \ b'\x1b\xdb\x82\x33' b'\x34\xf3\x70\xa6' \ b'\xd2\x82\x2d\x50' b'\x5c\xd5\x46\xb4' def testPackRequest0(self): bin = request.PolyFillArc._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyFillArc._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPutImage(EndianTest): def setUp(self): self.req_args_0 = { 'data': b'\xe9\x10\xf2o\x7f{\xae-\xe6\x18\xce\x83', 'depth': 172, 'drawable': 634980240, 'dst_x': -18991, 'dst_y': -10980, 'format': 2, 'gc': 1190657277, 'height': 12828, 'left_pad': 225, 'width': 8597, } self.req_bin_0 = b'\x48\x02\x09\x00' b'\x90\x07\xd9\x25' \ b'\xfd\xfc\xf7\x46' b'\x95\x21\x1c\x32' \ b'\xd1\xb5\x1c\xd5' b'\xe1\xac\x00\x00' \ b'\xe9\x10\xf2\x6f' b'\x7f\x7b\xae\x2d' \ b'\xe6\x18\xce\x83' def testPackRequest0(self): bin = request.PutImage._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PutImage._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetImage(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 872105322, 'format': 2, 'height': 20170, 'plane_mask': 616208054, 'width': 282, 'x': -14814, 'y': -5449, } self.req_bin_0 = b'\x49\x02\x05\x00' b'\x6a\x45\xfb\x33' \ b'\x22\xc6\xb7\xea' b'\x1a\x01\xca\x4e' \ b'\xb6\x96\xba\x24' self.reply_args_0 = { 'data': b'\xeb?:\xa7\xc6\x8b\xc2\x96o-S\xe6\xd6z6\x94\xd7v\xd2R.\xa2\xeaw\t\x13\x95\x85', 'depth': 181, 'sequence_number': 28429, 'visual': 1687469773, } self.reply_bin_0 = b'\x01\xb5\x0d\x6f' b'\x07\x00\x00\x00' \ b'\xcd\xbe\x94\x64' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\xeb\x3f\x3a\xa7' b'\xc6\x8b\xc2\x96' \ b'\x6f\x2d\x53\xe6' b'\xd6\x7a\x36\x94' \ b'\xd7\x76\xd2\x52' b'\x2e\xa2\xea\x77' \ b'\x09\x13\x95\x85' def testPackRequest0(self): bin = request.GetImage._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetImage._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetImage._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetImage._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestPolyText8(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 1245573363, 'gc': 1302861330, 'items': [{'delta': 2, 'string': 'zoo'}, 16909060, {'delta': 0, 'string': 'ie'}], 'x': -11315, 'y': -22209, } self.req_bin_0 = b'\x4a\x00\x08\x00' b'\xf3\xf0\x3d\x4a' \ b'\x12\x16\xa8\x4d' b'\xcd\xd3\x3f\xa9' \ b'\x03\x02\x7a\x6f' b'\x6f\xff\x01\x02' \ b'\x03\x04\x02\x00' b'\x69\x65\x00\x00' def testPackRequest0(self): bin = request.PolyText8._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyText8._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestPolyText16(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 998620068, 'gc': 948793778, 'items': [{'delta': 2, 'string': (4131, 18)}, 16909060], 'x': -18280, 'y': -10630, } self.req_bin_0 = b'\x4b\x00\x07\x00' b'\xa4\xbb\x85\x3b' \ b'\xb2\x71\x8d\x38' b'\x98\xb8\x7a\xd6' \ b'\x02\x02\x10\x23' b'\x00\x12\xff\x01' \ b'\x02\x03\x04\x00' def testPackRequest0(self): bin = request.PolyText16._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyText16._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestImageText8(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 458985805, 'gc': 1097803335, 'string': 'showme', 'x': -17263, 'y': -6759, } self.req_bin_0 = b'\x4c\x06\x06\x00' b'\x4d\x91\x5b\x1b' \ b'\x47\x26\x6f\x41' b'\x91\xbc\x99\xe5' \ b'\x73\x68\x6f\x77' b'\x6d\x65\x00\x00' def testPackRequest0(self): bin = request.ImageText8._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ImageText8._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestImageText16(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 1935336610, 'gc': 2061289059, 'string': (115, 104, 111, 119, 109, 111, 114, 101), 'x': -6684, 'y': -8653, } self.req_bin_0 = b'\x4d\x08\x08\x00' b'\xa2\xe4\x5a\x73' \ b'\x63\xc6\xdc\x7a' b'\xe4\xe5\x33\xde' \ b'\x00\x73\x00\x68' b'\x00\x6f\x00\x77' \ b'\x00\x6d\x00\x6f' b'\x00\x72\x00\x65' def testPackRequest0(self): bin = request.ImageText16._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ImageText16._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCreateColormap(EndianTest): def setUp(self): self.req_args_0 = { 'alloc': 0, 'mid': 1414936748, 'visual': 609492200, 'window': 182162564, } self.req_bin_0 = b'\x4e\x00\x04\x00' b'\xac\x38\x56\x54' \ b'\x84\x94\xdb\x0a' b'\xe8\x1c\x54\x24' def testPackRequest0(self): bin = request.CreateColormap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestFreeColormap(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 1106990292, } self.req_bin_0 = b'\x4f\x00\x02\x00' b'\xd4\x54\xfb\x41' def testPackRequest0(self): bin = request.FreeColormap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCopyColormapAndFree(EndianTest): def setUp(self): self.req_args_0 = { 'mid': 1425680795, 'src_cmap': 1359295675, } self.req_bin_0 = b'\x50\x00\x03\x00' b'\x9b\x29\xfa\x54' \ b'\xbb\x34\x05\x51' def testPackRequest0(self): bin = request.CopyColormapAndFree._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyColormapAndFree._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestInstallColormap(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 1329917990, } self.req_bin_0 = b'\x51\x00\x02\x00' b'\x26\xf0\x44\x4f' def testPackRequest0(self): bin = request.InstallColormap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.InstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestUninstallColormap(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 719876845, } self.req_bin_0 = b'\x52\x00\x02\x00' b'\xed\x72\xe8\x2a' def testPackRequest0(self): bin = request.UninstallColormap._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UninstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestListInstalledColormaps(EndianTest): def setUp(self): self.req_args_0 = { 'window': 200613013, } self.req_bin_0 = b'\x53\x00\x02\x00' b'\x95\x1c\xf5\x0b' self.reply_args_0 = { 'cmaps': [1757616530, 2044469232], 'sequence_number': 49482, } self.reply_bin_0 = b'\x01\x00\x4a\xc1' b'\x02\x00\x00\x00' \ b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x92\x19\xc3\x68' b'\xf0\x1f\xdc\x79' def testPackRequest0(self): bin = request.ListInstalledColormaps._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListInstalledColormaps._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListInstalledColormaps._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListInstalledColormaps._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestAllocColor(EndianTest): def setUp(self): self.req_args_0 = { 'blue': 14978, 'cmap': 504442007, 'green': 20599, 'red': 44348, } self.req_bin_0 = b'\x54\x00\x04\x00' b'\x97\x2c\x11\x1e' \ b'\x3c\xad\x77\x50' b'\x82\x3a\x00\x00' self.reply_args_0 = { 'blue': 1856, 'green': 9912, 'pixel': 99308744, 'red': 13306, 'sequence_number': 53114, } self.reply_bin_0 = b'\x01\x00\x7a\xcf' b'\x00\x00\x00\x00' \ b'\xfa\x33\xb8\x26' b'\x40\x07\x00\x00' \ b'\xc8\x54\xeb\x05' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.AllocColor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocColor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocColor._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestAllocNamedColor(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 525860889, 'name': 'octarin', } self.req_bin_0 = b'\x55\x00\x05\x00' b'\x19\x00\x58\x1f' \ b'\x07\x00\x00\x00' b'\x6f\x63\x74\x61' \ b'\x72\x69\x6e\x00' self.reply_args_0 = { 'exact_blue': 50619, 'exact_green': 55944, 'exact_red': 40316, 'pixel': 1020413057, 'screen_blue': 27416, 'screen_green': 30102, 'screen_red': 5028, 'sequence_number': 64739, } self.reply_bin_0 = b'\x01\x00\xe3\xfc' b'\x00\x00\x00\x00' \ b'\x81\x44\xd2\x3c' b'\x7c\x9d\x88\xda' \ b'\xbb\xc5\xa4\x13' b'\x96\x75\x18\x6b' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.AllocNamedColor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocNamedColor._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocNamedColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestAllocColorCells(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 1542701632, 'colors': 45892, 'contiguous': 0, 'planes': 25420, } self.req_bin_0 = b'\x56\x00\x03\x00' b'\x40\xc2\xf3\x5b' \ b'\x44\xb3\x4c\x63' self.reply_args_0 = { 'masks': [1726878301, 2057281944, 1494524694], 'pixels': [1061732426, 858313521, 524018138, 316972578, 1408939380, 1476723430, 11972931, 1917037904, 1612749468, 1847847580, 1653727126, 1901587588, 228960010, 1671710636, 913060041, 470023299, 377779303], 'sequence_number': 34200, } self.reply_bin_0 = b'\x01\x00\x98\x85' b'\x14\x00\x00\x00' \ b'\x11\x00\x03\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x4a\xc0\x48\x3f' b'\x31\xd3\x28\x33' \ b'\xda\xe1\x3b\x1f' b'\x22\x9e\xe4\x12' \ b'\x74\xb5\xfa\x53' b'\xe6\x02\x05\x58' \ b'\x43\xb1\xb6\x00' b'\x50\xad\x43\x72' \ b'\x9c\x9a\x20\x60' b'\x9c\xea\x23\x6e' \ b'\x96\xdf\x91\x62' b'\x84\xec\x57\x71' \ b'\x0a\xa7\xa5\x0d' b'\xac\x47\xa4\x63' \ b'\xc9\x30\x6c\x36' b'\x83\xfc\x03\x1c' \ b'\x67\x74\x84\x16' b'\x5d\x12\xee\x66' \ b'\x98\xa1\x9f\x7a' b'\x16\xa3\x14\x59' self.reply_args_1 = { 'masks': [], 'pixels': [], 'sequence_number': 30700, } self.reply_bin_1 = b'\x01\x00\xec\x77' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.AllocColorCells._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocColorCells._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocColorCells._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) def testPackReply1(self): bin = request.AllocColorCells._reply.to_binary(*(), **self.reply_args_1) self.assertBinaryEqual(bin, self.reply_bin_1) def testUnpackReply1(self): args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_1) class TestAllocColorPlanes(EndianTest): def setUp(self): self.req_args_0 = { 'blue': 8209, 'cmap': 1197085372, 'colors': 16587, 'contiguous': 0, 'green': 55852, 'red': 60383, } self.req_bin_0 = b'\x57\x00\x04\x00' b'\xbc\x12\x5a\x47' \ b'\xcb\x40\xdf\xeb' b'\x2c\xda\x11\x20' self.reply_args_0 = { 'blue_mask': 1200348460, 'green_mask': 2121548418, 'pixels': [980309855, 286409072, 1721094583, 997879295], 'red_mask': 1140662566, 'sequence_number': 44006, } self.reply_bin_0 = b'\x01\x00\xe6\xab' b'\x04\x00\x00\x00' \ b'\x04\x00\x00\x00' b'\x26\x21\xfd\x43' \ b'\x82\x42\x74\x7e' b'\x2c\xdd\x8b\x47' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x5f\x57\x6e\x3a' b'\x70\x41\x12\x11' \ b'\xb7\xd1\x95\x66' b'\xff\x6d\x7a\x3b' def testPackRequest0(self): bin = request.AllocColorPlanes._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocColorPlanes._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocColorPlanes._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocColorPlanes._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestFreeColors(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 341854532, 'pixels': [1278789650, 681457705, 2040260049, 1621952585, 1914388136, 950484730, 1315726377, 1750278681, 1544694596, 1915664535, 1084068385, 916484334, 1783699241, 1947521244, 1176611597, 957657715, 1926805276], 'plane_mask': 1597053435, } self.req_bin_0 = b'\x58\x00\x14\x00' b'\x44\x49\x60\x14' \ b'\xfb\x19\x31\x5f' b'\x12\xc8\x38\x4c' \ b'\x29\x38\x9e\x28' b'\xd1\xe5\x9b\x79' \ b'\x49\x08\xad\x60' b'\xa8\x3e\x1b\x72' \ b'\xfa\x3e\xa7\x38' b'\x29\x64\x6c\x4e' \ b'\x19\x22\x53\x68' b'\x44\x2b\x12\x5c' \ b'\x97\xb8\x2e\x72' b'\x21\x92\x9d\x40' \ b'\xee\x70\xa0\x36' b'\x29\x17\x51\x6a' \ b'\xdc\xd0\x14\x74' b'\x0d\xab\x21\x46' \ b'\x73\xb2\x14\x39' b'\x1c\xb7\xd8\x72' def testPackRequest0(self): bin = request.FreeColors._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeColors._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestStoreColors(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 686636594, 'items': [{'pixel': 1850111768, 'red': 31364, 'green': 29751, 'blue': 17242, 'flags': 191}, {'pixel': 1803657350, 'red': 42045, 'green': 18429, 'blue': 50444, 'flags': 252}, {'pixel': 1345997556, 'red': 15935, 'green': 18252, 'blue': 29083, 'flags': 147}, {'pixel': 1532391469, 'red': 18981, 'green': 15623, 'blue': 18063, 'flags': 213}], } self.req_bin_0 = b'\x59\x00\x0e\x00' b'\x32\x3e\xed\x28' \ b'\x18\x77\x46\x6e' b'\x84\x7a\x37\x74' \ b'\x5a\x43\xbf\x00' b'\x86\xa0\x81\x6b' \ b'\x3d\xa4\xfd\x47' b'\x0c\xc5\xfc\x00' \ b'\xf4\x4a\x3a\x50' b'\x3f\x3e\x4c\x47' \ b'\x9b\x71\x93\x00' b'\x2d\x70\x56\x5b' \ b'\x25\x4a\x07\x3d' b'\x8f\x46\xd5\x00' def testPackRequest0(self): bin = request.StoreColors._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.StoreColors._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestStoreNamedColor(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 297221571, 'flags': 148, 'name': 'blue', 'pixel': 323971915, } self.req_bin_0 = b'\x5a\x94\x05\x00' b'\xc3\x3d\xb7\x11' \ b'\x4b\x6b\x4f\x13' b'\x04\x00\x00\x00' \ b'\x62\x6c\x75\x65' def testPackRequest0(self): bin = request.StoreNamedColor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.StoreNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestQueryColors(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 875378525, 'pixels': [496695788, 822627561, 1490311416, 328212337, 1517089095, 459525846, 137995944, 890987562], } self.req_bin_0 = b'\x5b\x00\x0a\x00' b'\x5d\x37\x2d\x34' \ b'\xec\xf9\x9a\x1d' b'\xe9\x4c\x08\x31' \ b'\xf8\x58\xd4\x58' b'\x71\x1f\x90\x13' \ b'\x47\xf1\x6c\x5a' b'\xd6\xce\x63\x1b' \ b'\xa8\xa6\x39\x08' b'\x2a\x64\x1b\x35' self.reply_args_0 = { 'colors': [{'red': 35816, 'green': 30790, 'blue': 27504}, {'red': 4336, 'green': 13811, 'blue': 54840}, {'red': 27790, 'green': 25780, 'blue': 59555}, {'red': 50705, 'green': 38534, 'blue': 62257}, {'red': 45837, 'green': 1536, 'blue': 56402}], 'sequence_number': 57970, } self.reply_bin_0 = b'\x01\x00\x72\xe2' b'\x0a\x00\x00\x00' \ b'\x05\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\xe8\x8b\x46\x78' b'\x70\x6b\x00\x00' \ b'\xf0\x10\xf3\x35' b'\x38\xd6\x00\x00' \ b'\x8e\x6c\xb4\x64' b'\xa3\xe8\x00\x00' \ b'\x11\xc6\x86\x96' b'\x31\xf3\x00\x00' \ b'\x0d\xb3\x00\x06' b'\x52\xdc\x00\x00' self.req_args_1 = { 'cmap': 710627905, 'pixels': [], } self.req_bin_1 = b'\x5b\x00\x02\x00' b'\x41\x52\x5b\x2a' def testPackRequest0(self): bin = request.QueryColors._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryColors._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.QueryColors._request.to_binary(*(), **self.req_args_1) self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.QueryColors._request.parse_binary(self.req_bin_1, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_1) def testPackReply0(self): bin = request.QueryColors._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryColors._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestLookupColor(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 1644167361, 'name': 'octarin', } self.req_bin_0 = b'\x5c\x00\x05\x00' b'\xc1\x00\x00\x62' \ b'\x07\x00\x00\x00' b'\x6f\x63\x74\x61' \ b'\x72\x69\x6e\x00' self.reply_args_0 = { 'exact_blue': 642, 'exact_green': 31515, 'exact_red': 25184, 'screen_blue': 19825, 'screen_green': 23308, 'screen_red': 62039, 'sequence_number': 37984, } self.reply_bin_0 = b'\x01\x00\x60\x94' b'\x00\x00\x00\x00' \ b'\x60\x62\x1b\x7b' b'\x82\x02\x57\xf2' \ b'\x0c\x5b\x71\x4d' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.LookupColor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.LookupColor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.LookupColor._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.LookupColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestCreateCursor(EndianTest): def setUp(self): self.req_args_0 = { 'back_blue': 49245, 'back_green': 35528, 'back_red': 27716, 'cid': 1618141054, 'fore_blue': 55026, 'fore_green': 62740, 'fore_red': 58690, 'mask': 1832831050, 'source': 837555484, 'x': 48400, 'y': 36047, } self.req_bin_0 = b'\x5d\x00\x08\x00' b'\x7e\xdf\x72\x60' \ b'\x1c\x15\xec\x31' b'\x4a\xc8\x3e\x6d' \ b'\x42\xe5\x14\xf5' b'\xf2\xd6\x44\x6c' \ b'\xc8\x8a\x5d\xc0' b'\x10\xbd\xcf\x8c' def testPackRequest0(self): bin = request.CreateCursor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestCreateGlyphCursor(EndianTest): def setUp(self): self.req_args_0 = { 'back_blue': 25740, 'back_green': 2158, 'back_red': 32083, 'cid': 1717769345, 'fore_blue': 28818, 'fore_green': 18143, 'fore_red': 14636, 'mask': 1928100723, 'mask_char': 32252, 'source': 1295540602, 'source_char': 14709, } self.req_bin_0 = b'\x5e\x00\x08\x00' b'\x81\x14\x63\x66' \ b'\x7a\x61\x38\x4d' b'\x73\x7b\xec\x72' \ b'\x75\x39\xfc\x7d' b'\x2c\x39\xdf\x46' \ b'\x92\x70\x53\x7d' b'\x6e\x08\x8c\x64' def testPackRequest0(self): bin = request.CreateGlyphCursor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateGlyphCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestFreeCursor(EndianTest): def setUp(self): self.req_args_0 = { 'cursor': 721898231, } self.req_bin_0 = b'\x5f\x00\x02\x00' b'\xf7\x4a\x07\x2b' def testPackRequest0(self): bin = request.FreeCursor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestRecolorCursor(EndianTest): def setUp(self): self.req_args_0 = { 'back_blue': 55339, 'back_green': 11072, 'back_red': 47715, 'cursor': 1436460699, 'fore_blue': 26753, 'fore_green': 52563, 'fore_red': 44764, } self.req_bin_0 = b'\x60\x00\x05\x00' b'\x9b\xa6\x9e\x55' \ b'\xdc\xae\x53\xcd' b'\x81\x68\x63\xba' \ b'\x40\x2b\x2b\xd8' def testPackRequest0(self): bin = request.RecolorCursor._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.RecolorCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestQueryBestSize(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 1974766133, 'height': 64528, 'item_class': 1, 'width': 8620, } self.req_bin_0 = b'\x61\x01\x03\x00' b'\x35\x8a\xb4\x75' \ b'\xac\x21\x10\xfc' self.reply_args_0 = { 'height': 2023, 'sequence_number': 41036, 'width': 35260, } self.reply_bin_0 = b'\x01\x00\x4c\xa0' b'\x00\x00\x00\x00' \ b'\xbc\x89\xe7\x07' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryBestSize._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryBestSize._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryBestSize._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryBestSize._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestQueryExtension(EndianTest): def setUp(self): self.req_args_0 = { 'name': 'XTRA', } self.req_bin_0 = b'\x62\x00\x03\x00' b'\x04\x00\x00\x00' \ b'\x58\x54\x52\x41' self.reply_args_0 = { 'first_error': 237, 'first_event': 149, 'major_opcode': 134, 'present': 1, 'sequence_number': 59692, } self.reply_bin_0 = b'\x01\x00\x2c\xe9' b'\x00\x00\x00\x00' \ b'\x01\x86\x95\xed' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryExtension._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryExtension._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryExtension._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryExtension._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestListExtensions(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x63\x00\x01\x00' self.reply_args_0 = { 'names': ['XTRA', 'XTRA-II'], 'sequence_number': 9149, } self.reply_bin_0 = b'\x01\x02\xbd\x23' b'\x04\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x04\x58\x54\x52' b'\x41\x07\x58\x54' \ b'\x52\x41\x2d\x49' b'\x49\x00\x00\x00' def testPackRequest0(self): bin = request.ListExtensions._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListExtensions._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListExtensions._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListExtensions._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestChangeKeyboardMapping(EndianTest): def setUp(self): self.req_args_0 = { 'first_keycode': 157, 'keysyms': [[1861549105, 991489870, 390260112], [107985429, 558681426, 814119353], [702984500, 454537006, 976459372], [701896028, 724776911, 1634728346], [1889012491, 814167346, 597551532], [1614928797, 2042695294, 1786543801], [905303576, 541748982, 1792957544], [175892294, 1009976242, 41625283], [1608517348, 1158393599, 111852976], [2147285698, 2044231981, 751534113], [481513427, 1396173819, 147356828], [1677685199, 2055755177, 1399632465], [86453688, 1619703478, 66636412], [2039275666, 531036848, 428123802], [1802230236, 43765755, 1334308166], [327238597, 512271361, 271057482], [1016964633, 1437651928, 245649464], [1211115441, 2035292716, 468075293], [998652876, 1502089592, 550279151], [1646901134, 792196355, 360324443]], } self.req_bin_0 = b'\x64\x14\x3e\x00' b'\x9d\x03\x00\x00' \ b'\x31\xfc\xf4\x6e' b'\x4e\xef\x18\x3b' \ b'\x90\xe5\x42\x17' b'\x15\xba\x6f\x06' \ b'\x52\xcd\x4c\x21' b'\xb9\x79\x86\x30' \ b'\x34\xb1\xe6\x29' b'\x2e\xaf\x17\x1b' \ b'\x6c\x96\x33\x3a' b'\x5c\x15\xd6\x29' \ b'\xcf\x37\x33\x2b' b'\x9a\xf9\x6f\x61' \ b'\x0b\x0b\x98\x70' b'\x32\x35\x87\x30' \ b'\xac\xe9\x9d\x23' b'\x9d\xdb\x41\x60' \ b'\x7e\x0e\xc1\x79' b'\xb9\x7e\x7c\x6a' \ b'\x18\xd6\xf5\x35' b'\xf6\x6e\x4a\x20' \ b'\x68\x5c\xde\x6a' b'\x46\xe7\x7b\x0a' \ b'\xb2\x03\x33\x3c' b'\xc3\x26\x7b\x02' \ b'\xe4\x06\xe0\x5f' b'\xff\xae\x0b\x45' \ b'\xb0\xbd\xaa\x06' b'\xc2\xfa\xfc\x7f' \ b'\x2d\x81\xd8\x79' b'\x21\x80\xcb\x2c' \ b'\xd3\x4f\xb3\x1c' b'\xfb\xeb\x37\x53' \ b'\x9c\x7c\xc8\x08' b'\xcf\x71\xff\x63' \ b'\xa9\x55\x88\x7a' b'\x51\xb2\x6c\x53' \ b'\xb8\x2d\x27\x05' b'\xb6\xb6\x8a\x60' \ b'\x7c\xca\xf8\x03' b'\x92\xe0\x8c\x79' \ b'\xb0\xfa\xa6\x1f' b'\x9a\xa6\x84\x19' \ b'\xdc\xd9\x6b\x6b' b'\xfb\xcf\x9b\x02' \ b'\x46\xed\x87\x4f' b'\xc5\x43\x81\x13' \ b'\x01\xa4\x88\x1e' b'\x4a\x02\x28\x10' \ b'\x19\xa6\x9d\x3c' b'\xd8\xd3\xb0\x55' \ b'\x38\x50\xa4\x0e' b'\xb1\x27\x30\x48' \ b'\x2c\x1a\x50\x79' b'\x1d\x43\xe6\x1b' \ b'\xcc\x3b\x86\x3b' b'\x78\x11\x88\x59' \ b'\xef\x97\xcc\x20' b'\x8e\xb7\x29\x62' \ b'\x03\xf5\x37\x2f' b'\x5b\x1d\x7a\x15' def testPackRequest0(self): bin = request.ChangeKeyboardMapping._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetKeyboardMapping(EndianTest): def setUp(self): self.req_args_0 = { 'count': 207, 'first_keycode': 169, } self.req_bin_0 = b'\x65\x00\x02\x00' b'\xa9\xcf\x00\x00' self.reply_args_0 = { 'keysyms': [[232140298, 1242716010, 55143985], [1994770011, 669923085, 1236514049], [1454592222, 1949971307, 2057660497], [805965556, 851808913, 2021792706], [1535482384, 425909956, 163201187], [1271520474, 1483083165, 1783638995], [1346992789, 521515080, 218831382], [1497210568, 1658890074, 647643874], [1825990828, 1469435098, 1289374120], [1729858135, 259963764, 1709884923], [2112789657, 1215330896, 1680696611], [88195295, 745614404, 1144061708], [919934772, 1420606257, 795794911], [148083460, 1086542523, 1390588550], [732788374, 27170279, 1824449766], [902069278, 1765942198, 1052700150], [226642993, 930984408, 2063275595], [777792886, 1364908620, 1914642756], [1779635393, 987282730, 1518933756], [328545991, 935201525, 378251236]], 'sequence_number': 48346, } self.reply_bin_0 = b'\x01\x03\xda\xbc' b'\x3c\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x0a\x2e\xd6\x0d' b'\x6a\x57\x12\x4a' \ b'\x31\x6e\x49\x03' b'\x5b\xc6\xe5\x76' \ b'\x0d\x37\xee\x27' b'\x01\xb5\xb3\x49' \ b'\xde\x50\xb3\x56' b'\x6b\x33\x3a\x74' \ b'\x51\x68\xa5\x7a' b'\xf4\x0e\x0a\x30' \ b'\x91\x92\xc5\x32' b'\xc2\x1b\x82\x78' \ b'\x10\x9a\x85\x5b' b'\xc4\xde\x62\x19' \ b'\xa3\x40\xba\x09' b'\xda\xdc\xc9\x4b' \ b'\x9d\x0d\x66\x58' b'\xd3\x2b\x50\x6a' \ b'\x95\x7a\x49\x50' b'\x48\xb0\x15\x1f' \ b'\x16\x1a\x0b\x0d' b'\xc8\x9e\x3d\x59' \ b'\x5a\xa7\xe0\x62' b'\xe2\x42\x9a\x26' \ b'\xac\x68\xd6\x6c' b'\xda\xcc\x95\x57' \ b'\xa8\x49\xda\x4c' b'\x57\x8a\x1b\x67' \ b'\x74\xbb\x7e\x0f' b'\xfb\xc5\xea\x65' \ b'\x99\x9c\xee\x7d' b'\x50\x7a\x70\x48' \ b'\x23\x65\x2d\x64' b'\xdf\xc0\x41\x05' \ b'\x44\x2c\x71\x2c' b'\x0c\xff\x30\x44' \ b'\x34\x17\xd5\x36' b'\x31\xbb\xac\x54' \ b'\xdf\xdd\x6e\x2f' b'\x04\x93\xd3\x08' \ b'\xbb\x52\xc3\x40' b'\x86\xb2\xe2\x52' \ b'\x96\x76\xad\x2b' b'\xe7\x95\x9e\x01' \ b'\xe6\xe4\xbe\x6c' b'\x1e\x7c\xc4\x35' \ b'\xb6\x23\x42\x69' b'\xf6\xed\xbe\x3e' \ b'\x31\x4c\x82\x0d' b'\xd8\xb1\x7d\x37' \ b'\x4b\x16\xfb\x7a' b'\x76\x2d\x5c\x2e' \ b'\x4c\xda\x5a\x51' b'\x44\x21\x1f\x72' \ b'\xc1\x14\x13\x6a' b'\x2a\xbd\xd8\x3a' \ b'\xfc\x16\x89\x5a' b'\xc7\x36\x95\x13' \ b'\xf5\x0a\xbe\x37' b'\xe4\xa7\x8b\x16' def testPackRequest0(self): bin = request.GetKeyboardMapping._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetKeyboardMapping._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetKeyboardMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestChangeKeyboardControl(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'key_click_percent': -59, 'bell_percent': -5, 'bell_pitch': -2303, 'bell_duration': -4223, 'led': 196, 'led_mode': 1, 'key': 190, 'auto_repeat_mode': 0}, } self.req_bin_0 = b'\x66\x00\x0a\x00' b'\xff\x00\x00\x00' \ b'\xc5\x00\x00\x00' b'\xfb\x00\x00\x00' \ b'\x01\xf7\x00\x00' b'\x81\xef\x00\x00' \ b'\xc4\x00\x00\x00' b'\x01\x00\x00\x00' \ b'\xbe\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.ChangeKeyboardControl._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetKeyboardControl(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x67\x00\x01\x00' self.reply_args_0 = { 'auto_repeats': [199, 243, 190, 246, 225, 214, 135, 254, 211, 174, 252, 182, 218, 194, 215, 199, 198, 130, 176, 149, 189, 232, 253, 189, 249, 253, 242, 132, 151, 203, 184, 231], 'bell_duration': 35050, 'bell_percent': 249, 'bell_pitch': 36528, 'global_auto_repeat': 0, 'key_click_percent': 222, 'led_mask': 1425908825, 'sequence_number': 20323, } self.reply_bin_0 = b'\x01\x00\x63\x4f' b'\x05\x00\x00\x00' \ b'\x59\xa4\xfd\x54' b'\xde\xf9\xb0\x8e' \ b'\xea\x88\x00\x00' b'\xc7\xf3\xbe\xf6' \ b'\xe1\xd6\x87\xfe' b'\xd3\xae\xfc\xb6' \ b'\xda\xc2\xd7\xc7' b'\xc6\x82\xb0\x95' \ b'\xbd\xe8\xfd\xbd' b'\xf9\xfd\xf2\x84' \ b'\x97\xcb\xb8\xe7' def testPackRequest0(self): bin = request.GetKeyboardControl._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetKeyboardControl._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetKeyboardControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestBell(EndianTest): def setUp(self): self.req_args_0 = { 'percent': -40, } self.req_bin_0 = b'\x68\xd8\x01\x00' def testPackRequest0(self): bin = request.Bell._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.Bell._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestChangePointerControl(EndianTest): def setUp(self): self.req_args_0 = { 'accel_denum': -8326, 'accel_num': -18826, 'do_accel': 1, 'do_thresh': 1, 'threshold': -14733, } self.req_bin_0 = b'\x69\x00\x03\x00' b'\x76\xb6\x7a\xdf' \ b'\x73\xc6\x01\x01' def testPackRequest0(self): bin = request.ChangePointerControl._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangePointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetPointerControl(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x6a\x00\x01\x00' self.reply_args_0 = { 'accel_denom': 18010, 'accel_num': 29992, 'sequence_number': 46318, 'threshold': 20350, } self.reply_bin_0 = b'\x01\x00\xee\xb4' b'\x00\x00\x00\x00' \ b'\x28\x75\x5a\x46' b'\x7e\x4f\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetPointerControl._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetPointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetPointerControl._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetPointerControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestSetScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { 'allow_exposures': 2, 'interval': -25214, 'prefer_blank': 0, 'timeout': -24531, } self.req_bin_0 = b'\x6b\x00\x03\x00' b'\x2d\xa0\x82\x9d' \ b'\x00\x02\x00\x00' def testPackRequest0(self): bin = request.SetScreenSaver._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestGetScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x6c\x00\x01\x00' self.reply_args_0 = { 'allow_exposures': 0, 'interval': 8091, 'prefer_blanking': 0, 'sequence_number': 12877, 'timeout': 20935, } self.reply_bin_0 = b'\x01\x00\x4d\x32' b'\x00\x00\x00\x00' \ b'\xc7\x51\x9b\x1f' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetScreenSaver._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetScreenSaver._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetScreenSaver._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestChangeHosts(EndianTest): def setUp(self): self.req_args_0 = { 'host': [183, 251, 198, 200], 'host_family': 0, 'mode': 0, } self.req_bin_0 = b'\x6d\x00\x03\x00' b'\x00\x00\x04\x00' \ b'\xb7\xfb\xc6\xc8' def testPackRequest0(self): bin = request.ChangeHosts._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeHosts._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestListHosts(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x6e\x00\x01\x00' self.reply_args_0 = { 'hosts': [{'family': 0, 'name': [34, 23, 178, 12]}, {'family': 0, 'name': [130, 236, 254, 15]}], 'mode': 1, 'sequence_number': 15164, } self.reply_bin_0 = b'\x01\x01\x3c\x3b' b'\x04\x00\x00\x00' \ b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x04\x00' b'\x22\x17\xb2\x0c' \ b'\x00\x00\x04\x00' b'\x82\xec\xfe\x0f' def testPackRequest0(self): bin = request.ListHosts._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListHosts._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListHosts._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListHosts._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestSetAccessControl(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 1, } self.req_bin_0 = b'\x6f\x01\x01\x00' def testPackRequest0(self): bin = request.SetAccessControl._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetAccessControl._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestSetCloseDownMode(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 0, } self.req_bin_0 = b'\x70\x00\x01\x00' def testPackRequest0(self): bin = request.SetCloseDownMode._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetCloseDownMode._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestKillClient(EndianTest): def setUp(self): self.req_args_0 = { 'resource': 649180254, } self.req_bin_0 = b'\x71\x00\x02\x00' b'\x5e\xb4\xb1\x26' def testPackRequest0(self): bin = request.KillClient._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.KillClient._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestRotateProperties(EndianTest): def setUp(self): self.req_args_0 = { 'delta': -11867, 'properties': [30448914, 1520523655, 1147111912, 271900374, 589144637, 97809756, 2092347973, 117159267, 1188394866, 627424198, 1497757970, 2027482546], 'window': 271248673, } self.req_bin_0 = b'\x72\x00\x0f\x00' b'\x21\xed\x2a\x10' \ b'\x0c\x00\xa5\xd1' b'\x12\x9d\xd0\x01' \ b'\x87\x59\xa1\x5a' b'\xe8\x89\x5f\x44' \ b'\xd6\xde\x34\x10' b'\x3d\xa2\x1d\x23' \ b'\x5c\x75\xd4\x05' b'\x45\xb2\xb6\x7c' \ b'\x63\xb5\xfb\x06' b'\x72\x77\xd5\x46' \ b'\xc6\xbb\x65\x25' b'\x12\xf9\x45\x59' \ b'\xb2\xed\xd8\x78' def testPackRequest0(self): bin = request.RotateProperties._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.RotateProperties._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestForceScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 1, } self.req_bin_0 = b'\x73\x01\x01\x00' def testPackRequest0(self): bin = request.ForceScreenSaver._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ForceScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) class TestSetPointerMapping(EndianTest): def setUp(self): self.req_args_0 = { 'map': [154, 131, 200, 248, 250], } self.req_bin_0 = b'\x74\x05\x03\x00' b'\x9a\x83\xc8\xf8' \ b'\xfa\x00\x00\x00' self.reply_args_0 = { 'sequence_number': 22584, 'status': 240, } self.reply_bin_0 = b'\x01\xf0\x38\x58' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SetPointerMapping._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.SetPointerMapping._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.SetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestGetPointerMapping(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x75\x00\x01\x00' self.reply_args_0 = { 'map': [175, 141, 192, 250, 157], 'sequence_number': 54134, } self.reply_bin_0 = b'\x01\x05\x76\xd3' b'\x02\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\xaf\x8d\xc0\xfa' b'\x9d\x00\x00\x00' def testPackRequest0(self): bin = request.GetPointerMapping._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetPointerMapping._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestSetModifierMapping(EndianTest): def setUp(self): self.req_args_0 = { 'keycodes': [[33, 205], [251, 37], [27, 77], [76, 155], [43, 127], [60, 213], [115, 194], [230, 226]], } self.req_bin_0 = b'\x76\x02\x05\x00' b'\x21\xcd\xfb\x25' \ b'\x1b\x4d\x4c\x9b' b'\x2b\x7f\x3c\xd5' \ b'\x73\xc2\xe6\xe2' self.reply_args_0 = { 'sequence_number': 56627, 'status': 204, } self.reply_bin_0 = b'\x01\xcc\x33\xdd' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SetModifierMapping._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.SetModifierMapping._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.SetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestGetModifierMapping(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x77\x00\x01\x00' self.reply_args_0 = { 'keycodes': [[219, 156], [30, 50], [106, 108], [135, 41], [80, 122], [88, 38], [80, 1], [209, 230]], 'sequence_number': 45434, } self.reply_bin_0 = b'\x01\x02\x7a\xb1' b'\x04\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\xdb\x9c\x1e\x32' b'\x6a\x6c\x87\x29' \ b'\x50\x7a\x58\x26' b'\x50\x01\xd1\xe6' def testPackRequest0(self): bin = request.GetModifierMapping._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetModifierMapping._reply.to_binary(*(), **self.reply_args_0) self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.reply_args_0) class TestNoOperation(EndianTest): def setUp(self): self.req_args_0 = { } self.req_bin_0 = b'\x7f\x00\x01\x00' def testPackRequest0(self): bin = request.NoOperation._request.to_binary(*(), **self.req_args_0) self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.NoOperation._request.parse_binary(self.req_bin_0, dummy_display, 1) self.assertBinaryEmpty(remain) self.assertEqual(args, self.req_args_0) if __name__ == "__main__": unittest.main() python-xlib-0.33/test/test_struct.py000066400000000000000000000237771435211557500176600ustar00rootroot00000000000000 from collections import OrderedDict from functools import partial import struct import types import re from six import binary_type, iterbytes from Xlib.protocol import rq from . import DummyDisplay, TestCase dummy_display = DummyDisplay() def pack(format, *args): return struct.pack('=' + format, *args) def packstr(s, padding=0): return s.encode() + (b'\0' * padding) class StructTest(object): """ Test class helper for rq.Struct packing/unpacking support. """ struct = None values_in = None binary = None values_out = None def test_pack_value_dict(self): self.assertBinaryEqual(self.struct.pack_value(dict(self.values_in)), self.binary) def test_pack_value_tuple(self): self.assertBinaryEqual(self.struct.pack_value(tuple(self.values_in.values())), self.binary) def test_to_binary_args(self): self.assertBinaryEqual(self.struct.to_binary(*self.values_in.values()), self.binary) def test_to_binary_kwargs(self): self.assertBinaryEqual(self.struct.to_binary(**dict(self.values_in)), self.binary) def test_parse_binary(self): values, remain = self.struct.parse_binary(self.binary, dummy_display) self.assertEqual(values, rq.DictWrapper(dict(self.values_out))) self.assertBinaryEmpty(remain) def _struct_test(name, fields): """ Generate a new Struct packing/unpacking test. is a list of (field_name, field_type, field_value, field_binary): - field_name: name of the field, None if it's not a named field (e.g. LengthOf) - field_type: factory for the field type, taking one parameter only, the name of the field and returning a rq.Field subclass instance - field_value_in: the raw value passed in when packing and expected output on unpacking - field_binary: the binary representation of the field value or a function to convert it to binary for creating the expected result of packing the struct - field_value_out: the raw value passed expected on output on unpacking (optional, is used if not specified) """ class_name = ''.join([part.capitalize() for part in re.sub(r'[^\w]+', ' ', name).split()]) class_name += 'StructTest' struct_layout = [] values_in = OrderedDict() binary = b'' values_out = OrderedDict() for field_params in fields: assert 4 <= len(field_params) <= 5 field_name, field_type, field_value_in, field_binary = field_params[0:4] if len(field_params) == 5: field_value_out = field_params[4] else: field_value_out = field_value_in struct_layout.append(field_type(field_name)) if field_name is not None: if field_value_in is not None: values_in[field_name] = field_value_in if field_value_out is not None: values_out[field_name] = field_value_out if isinstance(field_binary, binary_type): binary += field_binary elif isinstance(field_binary, (types.FunctionType, types.LambdaType, partial)): binary += field_binary(field_value_in) else: raise ValueError('unsupported type for binary: {data} [{type}]'.format( data=str(field_binary), type=type(field_binary)) ) class_dict = { 'struct': rq.Struct(*struct_layout), 'values_in': values_in, 'binary': binary, 'values_out': values_out, } globals()[class_name] = type(class_name, (StructTest, TestCase), class_dict) _struct_test('card', ( ('c8' , rq.Card8 , 0x42 , partial(pack, 'B')), ('c16', rq.Card16, 0x666 , partial(pack, 'H')), ('c32', rq.Card32, 0xdeadbeef, partial(pack, 'L')), )) _struct_test('int', ( ('i8' , rq.Int8 , -42 , partial(pack, 'b')), ('i16', rq.Int16, -666 , partial(pack, 'h')), ('i32', rq.Int32, -2147483648, partial(pack, 'l')), )) _struct_test('list', ( (None , lambda name: rq.LengthOf('lc8', 1) , None , pack('B', 2) ), (None , lambda name: rq.LengthOf('lc16', 2) , None , pack('H', 3) ), (None , lambda name: rq.LengthOf('lc32', 4) , None , pack('L', 5) ), ('lc8' , lambda name: rq.List(name, rq.Card8 , pad=0), [0x42, 0xc3] , lambda v: pack('2B' , *v)), ('lc16' , lambda name: rq.List(name, rq.Card16, pad=0), [666, 1, 60143] , lambda v: pack('3H' , *v)), ('lc32' , lambda name: rq.List(name, rq.Card32, pad=0), [0xf02facb, 666, 1, 0x1043, 0xdeadbeef], lambda v: pack('5L' , *v)), )) _struct_test('list pad', ( (None , lambda name: rq.LengthOf('lc8', 1) , None , pack('B', 2) ), (None , lambda name: rq.LengthOf('lc16', 2) , None , pack('H', 3) ), (None , lambda name: rq.LengthOf('lc32', 4) , None , pack('L', 5) ), ('lc8' , lambda name: rq.List(name, rq.Card8 , pad=1), [0x42, 0xc3] , lambda v: pack('2B2x', *v)), ('lc16' , lambda name: rq.List(name, rq.Card16, pad=1), [666, 1, 60143] , lambda v: pack('3H2x', *v)), ('lc32' , lambda name: rq.List(name, rq.Card32, pad=1), [0xf02facb, 666, 1, 0x1043, 0xdeadbeef], lambda v: pack('5L' , *v)), )) _struct_test('fixed list', ( ('lc8' , lambda name: rq.FixedList(name, 2, rq.Card8 , pad=0), [0x42, 0xc3] , lambda v: pack('2B' , *v)), ('lc16' , lambda name: rq.FixedList(name, 3, rq.Card16, pad=0), [666, 1, 60143] , lambda v: pack('3H' , *v)), ('lc32' , lambda name: rq.FixedList(name, 5, rq.Card32, pad=0), [0xf02facb, 666, 1, 0x1043, 0xdeadbeef], lambda v: pack('5L' , *v)), )) _struct_test('fixed list pad', ( ('lc8p' , lambda name: rq.FixedList(name, 2, rq.Card8 , pad=1), [0x42, 0xc3] , lambda v: pack('2B2x', *v)), ('lc16p', lambda name: rq.FixedList(name, 3, rq.Card16, pad=1), [666, 1, 60143] , lambda v: pack('3H2x', *v)), ('lc32p', lambda name: rq.FixedList(name, 5, rq.Card32, pad=1), [0xf02facb, 666, 1, 0x1043, 0xdeadbeef], lambda v: pack('5L' , *v)), )) _struct_test('string8', ( (None, lambda name: rq.LengthOf('s1', 1) , None , pack('B', 7) ), (None, lambda name: rq.LengthOf('s2', 2) , None , pack('H', 13)), (None, lambda name: rq.LengthOf('s3', 4) , None , pack('L', 34)), ('s1', lambda name: rq.String8(name, pad=0), "testing" , packstr ), ('s2', lambda name: rq.String8(name, pad=0), "one two three" , packstr ), ('s3', lambda name: rq.String8(name, pad=0), "supercalifragilisticexpialidocious", packstr ), )) _struct_test('string8 pad', ( (None, lambda name: rq.LengthOf('s1', 1) , None , pack('B', 7) ), (None, lambda name: rq.LengthOf('s2', 2) , None , pack('H', 13) ), (None, lambda name: rq.LengthOf('s3', 4) , None , pack('L', 34) ), ('s1', lambda name: rq.String8(name, pad=1), "testing" , partial(packstr, padding=1)), ('s2', lambda name: rq.String8(name, pad=1), "one two three" , partial(packstr, padding=3)), ('s3', lambda name: rq.String8(name, pad=1), "supercalifragilisticexpialidocious", partial(packstr, padding=2)), )) _struct_test('simple string16', ( (None, lambda name: rq.LengthOf('s1', 1) , None , pack('B', 3) ), (None, lambda name: rq.LengthOf('s2', 2) , None , pack('H', 3) ), ('s1', lambda name: rq.String16(name, pad=0), (0, 1, 2), lambda s: struct.pack('>' + 'H' * len(s), *s)), # An 8-bits string is also allowed on input. ('s2', lambda name: rq.String16(name, pad=0), b'\x03\x04\x05', lambda s: struct.pack('>' + 'H' * len(s), *iterbytes(s)), (3, 4, 5)), )) _struct_test('binary', ( (None, lambda name: rq.LengthOf('s1', 1) , None , pack('B', 7) ), (None, lambda name: rq.LengthOf('s2', 2) , None , pack('H', 13)), (None, lambda name: rq.LengthOf('s3', 4) , None , pack('L', 34)), ('s1', lambda name: rq.Binary(name, pad=0), b"testing" , lambda v: v), ('s2', lambda name: rq.Binary(name, pad=0), b"one two three" , lambda v: v), ('s3', lambda name: rq.Binary(name, pad=0), b"supercalifragilisticexpialidocious", lambda v: v), )) _struct_test('binary pad', ( (None, lambda name: rq.LengthOf('s1', 1) , None , pack('B', 7) ), (None, lambda name: rq.LengthOf('s2', 2) , None , pack('H', 13)), (None, lambda name: rq.LengthOf('s3', 4) , None , pack('L', 34)), ('s1', lambda name: rq.Binary(name, pad=1), b"testing" , lambda v: v + b'\0' * 1), ('s2', lambda name: rq.Binary(name, pad=1), b"one two three" , lambda v: v + b'\0' * 3), ('s3', lambda name: rq.Binary(name, pad=1), b"supercalifragilisticexpialidocious", lambda v: v + b'\0' * 2), )) _struct_test('fixed binary', ( ('s1', lambda name: rq.FixedBinary(name, 7 ), b"testing" , lambda v: v), ('s2', lambda name: rq.FixedBinary(name, 13), b"one two three" , lambda v: v), ('s3', lambda name: rq.FixedBinary(name, 34), b"supercalifragilisticexpialidocious", lambda v: v), # Make sure fixed binary fields are handled as static fields. ('c8', rq.Card8, 0x42, partial(pack, 'B')), )) python-xlib-0.33/test/test_unix_connect.py000066400000000000000000000150271435211557500210150ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -* from functools import partial import socket import sys import unittest from mock import patch from Xlib.support import unix_connect from Xlib.error import DisplayConnectionError, DisplayNameError @unittest.skipUnless(sys.platform.startswith('linux'), 'Linux specific tests') class TestUnixConnect(unittest.TestCase): def test_get_display(self): # Valid cases. for display, expected in ( # Implicit Unix socket connections. (':0.1', (None, '', 0, 1)), (':4', (None, '', 4, 0)), # Implicit TCP connections. ('foo:1.2', (None, 'foo', 1, 2)), ('bar:5', (None, 'bar', 5, 0)), # Explicit Unix socket connections. ('unix/foo:4.3', ('unix', 'foo', 4, 3)), ('unix/:66', ('unix', '', 66, 0)), # Explicit TCP connections. ('tcp/foo:11.1', ('tcp', 'foo', 11, 1)), ('tcp/bar:66.6', ('tcp', 'bar', 66, 6)), ('tcp/unix:54.3', ('tcp', 'unix', 54, 3)), # Special case: `unix:0.0` is equivalent to `:0.0`. ('unix:99.5', (None, 'unix', 99, 5)), ('unix:42', (None, 'unix', 42, 0)), ): result = unix_connect.get_display(display) self.assertEqual(result, (display,) + expected) # Invalid cases. for display in ( # No display number. '', ':', 'foo', 'bar:', # Bad screen number. ':48.', ':47.f', # Bad hostname. u'fòó:0', u'tcp/bàr:1', u'unix/fòóbàr:2', # Bad protocol. 'udp/foo:0' # With explicit TCP connections, hostname must be set. 'tcp/:0', ): with self.assertRaises(DisplayNameError): unix_connect.get_display(display) def test_get_socket(self): class FakeSocket(object): def fileno(self): return 42 calls = [] def _get_socket(socket_type, raises, *params): calls.append(('_get_%s_socket' % socket_type,) + params) if raises: raise socket.error() return FakeSocket() def path_exists(returns, path): calls.append(('os.path.exists', path)) return returns def ensure_not_inheritable(*args): calls.append(('ensure_not_inheritable',) + args) for params, allow_unix, unix_addr_exists, allow_tcp, expect_connection_error, expected_calls in ( # Successful explicit TCP socket connection. (('tcp/host:6', None, 'host', 6), False, False, True, False, [ ('_get_tcp_socket', 'host', 6), ]), # Failed explicit TCP socket connection. (('tcp/host:6', None, 'host', 6), False, False, False, True, [ ('_get_tcp_socket', 'host', 6), ]), # Successful implicit TCP socket connection. (('host:5', None, 'host', 5), False, False, True, False, [ ('_get_tcp_socket', 'host', 5), ]), # Failed implicit TCP socket connection. (('host:5', None, 'host', 5), False, False, False, True, [ ('_get_tcp_socket', 'host', 5), ]), # Successful explicit Unix socket connection. (('unix/name:0', 'unix', 'name', 0), True, True, False, False, [ ('os.path.exists', '/tmp/.X11-unix/X0'), ('_get_unix_socket', '/tmp/.X11-unix/X0'), ]), # Failed explicit Unix socket connection. (('unix/name:0', 'unix', 'name', 0), False, True, False, True, [ ('os.path.exists', '/tmp/.X11-unix/X0'), ('_get_unix_socket', '/tmp/.X11-unix/X0'), ]), # Successful explicit Unix socket connection, variant. (('unix:0', None, 'unix', 0), True, True, False, False, [ ('os.path.exists', '/tmp/.X11-unix/X0'), ('_get_unix_socket', '/tmp/.X11-unix/X0'), ]), # Failed explicit Unix socket connection, variant. (('unix:0', None, 'unix', 0), False, True, False, True, [ ('os.path.exists', '/tmp/.X11-unix/X0'), ('_get_unix_socket', '/tmp/.X11-unix/X0'), ]), # Successful implicit Unix socket connection. ((':4', None, '', 4), True, True, False, False, [ ('os.path.exists', '/tmp/.X11-unix/X4'), ('_get_unix_socket', '/tmp/.X11-unix/X4'), ]), # Successful implicit Unix socket connection, abstract address. ((':3', None, '', 3), True, False, False, False, [ ('os.path.exists', '/tmp/.X11-unix/X3'), ('_get_unix_socket', '\0/tmp/.X11-unix/X3'), ]), # Failed implicit Unix socket connection, successful fallback on TCP. ((':2', None, '', 2), False, False, True, False, [ ('os.path.exists', '/tmp/.X11-unix/X2'), ('_get_unix_socket', '\0/tmp/.X11-unix/X2'), ('_get_tcp_socket', '', 2), ]), # Failed implicit Unix socket connection, failed fallback on TCP. ((':1', None, '', 1), False, False, False, True, [ ('os.path.exists', '/tmp/.X11-unix/X1'), ('_get_unix_socket', '\0/tmp/.X11-unix/X1'), ('_get_tcp_socket', '', 1), ]), ): with \ patch('Xlib.support.unix_connect._get_unix_socket', partial(_get_socket, 'unix', not allow_unix)), \ patch('Xlib.support.unix_connect._get_tcp_socket', partial(_get_socket, 'tcp', not allow_tcp)), \ patch('os.path.exists', partial(path_exists, unix_addr_exists)), \ patch('Xlib.support.unix_connect._ensure_not_inheritable', ensure_not_inheritable): del calls[:] if expect_connection_error: with self.assertRaises(DisplayConnectionError): unix_connect.get_socket(*params) else: s = unix_connect.get_socket(*params) self.assertIsInstance(s, FakeSocket) expected_calls.append(('ensure_not_inheritable', s)) self.assertEqual(calls, expected_calls) if __name__ == '__main__': unittest.main() python-xlib-0.33/test/test_xlib_display.py000066400000000000000000000146541435211557500210110ustar00rootroot00000000000000#!/usr/bin/env python import sys import os import unittest sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import Xlib.display import Xlib.error import Xlib.protocol.display import Xlib.protocol.event import Xlib.protocol.rq import Xlib.xobject.fontable import Xlib.X class TestXlibDisplay(unittest.TestCase): def setUp(self): # Create authority file. self.display_num = os.getenv("DISPLAY") self.display = Xlib.display.Display(self.display_num) self.dummy_str = "qqq" self.keysym = 65535 def test_display_instance(self): self.assertTrue(isinstance(self.display, Xlib.display.Display)) def test_default_display_name(self): self.assertEqual(self.display.get_display_name(), self.display_num) def test_default_screen_number(self): self.assertEqual(self.display.get_default_screen(), 0) def test_returns_no_events(self): self.assertEqual(self.display.pending_events(), 0) def test_pointer_mapping_is_list(self): self.assertTrue(isinstance(self.display.get_pointer_mapping(), list)) def test_set_get_pointer_mapping(self): orig_mapping = self.display.get_pointer_mapping() length = len(orig_mapping) try: self.display.set_pointer_mapping([0] * length) self.assertEqual(self.display.get_pointer_mapping(), [0] * length) finally: self.display.set_pointer_mapping(orig_mapping) def test_can_close_display(self): self.display.close() self.assertEqual(str(self.display.display.socket_error), "Display connection closed by client") def test_can_close_display_and_check_for_error(self): self.display.close() self.assertRaises(Xlib.error.ConnectionClosedError, self.display.flush) def test_return_fileno(self): self.assertTrue(isinstance(self.display.fileno(), int)) def test_has_no_invalid_extension(self): self.assertTrue(~self.display.has_extension(self.dummy_str)) def test_has_valid_extension(self): extensions = self.display.list_extensions() if extensions: self.assertTrue(~self.display.has_extension(extensions[0])) def test_can_create_resource_object(self): self.assertTrue( isinstance(self.display.create_resource_object("font", 0), Xlib.xobject.fontable.Font)) def test_get_default_screen_instance(self): self.assertTrue(isinstance(self.display.screen(), Xlib.protocol.rq.DictWrapper)) def test_get_zero_screen_instance(self): self.assertTrue(isinstance(self.display.screen(0), Xlib.protocol.rq.DictWrapper)) def test_default_screen_count(self): self.assertEqual(self.display.screen_count(), 1) def test_cannot_add_existing_display_method(self): self.assertRaises(AssertionError, self.display.extension_add_method, "display", "extension_add_method", lambda x: x) def test_cannot_add_existing_font_method(self): self.assertRaises(AssertionError, self.display.extension_add_method, "font", "__init__", lambda x: x) def test_can_add_extension_error(self): self.display.extension_add_error(1, Xlib.error.XError) self.assertEqual(self.display.display.error_classes[1], Xlib.error.XError) def test_keycode_to_keysym_for_invalid_index(self): self.assertEqual(self.display.keycode_to_keysym(0, 0), Xlib.X.NoSymbol) def test_keysym_to_keycode_for_nosymbol(self): self.assertEqual(self.display.keysym_to_keycode(Xlib.X.NoSymbol), 0) def test_keysym_to_keycode_for_valid_symbol(self): self.assertEqual(self.display.keysym_to_keycode(self.keysym), 119) def test_keysym_to_keycodes_for_nosymbol(self): self.assertEqual(self.display.keysym_to_keycodes(Xlib.X.NoSymbol), []) def test_refresh_keyboard_mapping_invalid_event(self): self.assertRaises(TypeError, self.display.refresh_keyboard_mapping, Xlib.protocol.event.AnyEvent) def test_get_modifier_mapping(self): self.assertEqual(len(self.display.get_modifier_mapping()), 8) def test_set_modifier_mapping(self): mapping = self.display.get_modifier_mapping() self.assertEqual(self.display.set_modifier_mapping(mapping), Xlib.X.MappingSuccess) def test_get_screensaver(self): self.assertTrue(isinstance(self.display.get_screen_saver(), Xlib.protocol.request.GetScreenSaver)) def test_list_hosts(self): self.assertTrue(isinstance(self.display.list_hosts(), Xlib.protocol.request.ListHosts)) def test_get_keyboard_control(self): self.assertTrue( isinstance(self.display.get_keyboard_control(), Xlib.protocol.request.GetKeyboardControl)) def test_change_keyboard_mapping(self): kpt_mapping = self.display.get_keyboard_mapping(254, 1) self.display.change_keyboard_mapping(254, kpt_mapping) self.assertEqual(self.display.get_keyboard_mapping(254, 1), kpt_mapping) def test_get_font_path(self): self.assertNotEqual(self.display.get_font_path(), []) def test_get_atom_name(self): atom = self.display.get_atom(self.display_num) val = self.display.get_atom_name(atom) self.assertEqual(val, self.display_num) def test_intern_atom(self): atom = self.display.intern_atom(self.display_num) val = self.display.get_atom_name(atom) self.assertEqual(val, self.display_num) def test_get_input_focus(self): self.assertTrue(isinstance(self.display.get_input_focus(), Xlib.protocol.request.GetInputFocus)) def test_query_keymap(self): self.assertTrue(isinstance(self.display.query_keymap(), list)) def test_open_invalid_font(self): self.assertEqual(self.display.open_font(self.dummy_str), None) def test_list_fonts(self): fonts = self.display.list_fonts("*", 1) self.assertNotEqual(fonts, []) def test_lookup_valid_keysym(self): self.assertNotEqual(self.display.lookup_string(self.keysym), None) def test_lookup_invalid_keysym(self): self.assertEqual(self.display.lookup_string(-1), None) def test_rebind_string(self): self.display.rebind_string(self.keysym, self.dummy_str) self.assertEqual(self.display.lookup_string(self.keysym), self.dummy_str) def test_get_selection_owner(self): atom = self.display.get_atom(self.display_num) self.assertEqual(self.display.get_selection_owner(atom), 0) if __name__ == '__main__': unittest.main() python-xlib-0.33/tox.ini000066400000000000000000000002711435211557500152370ustar00rootroot00000000000000[tox] envlist = py27,py33,py34,py35,py36 skip_missing_interpreters = true [testenv] deps= -rdev-requirements.txt -rrequirements.txt commands={envpython} -W all runtests.py {posargs} python-xlib-0.33/utils/000077500000000000000000000000001435211557500150645ustar00rootroot00000000000000python-xlib-0.33/utils/parsexbug.py000066400000000000000000000164341435211557500174460ustar00rootroot00000000000000#!/usr/bin/python import sys import os import pprint import struct # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) def dummy_buffer(str, x, y = sys.maxint): return str[x:y] __builtins__.buffer = dummy_buffer from Xlib.protocol import display, request, rq, event from Xlib import error # We don't want any fancy dictwrapper, just plain mappings rq.DictWrapper = lambda x: x class BugFile(object): def __init__(self, file): self.file = file self.cbuf = self.sbuf = '' def read_client(self, bytes): while len(self.cbuf) < bytes and self.file: self.read_next() d = self.cbuf[:bytes] self.cbuf = self.cbuf[bytes:] return d def read_server(self, bytes): while len(self.sbuf) < bytes and self.file: self.read_next() d = self.sbuf[:bytes] self.sbuf = self.sbuf[bytes:] return d def read_next(self): line = self.file.readline() if line == '': self.file = None return src = line[0] length = int(line[1:-1]) data = self.file.read(length) if src == 'C': self.cbuf = self.cbuf + data elif src == 'S': self.sbuf = self.sbuf + data else: raise ValueError('Bad control line: %s' % line) class ParseString(object): def __init__(self, datafunc): self.get_data = datafunc self.data = '' def __getitem__(self, key): if not isinstance(key, slice): if key < 0: raise ValueError('bad string index: {0}'.format(key)) if len(self.data) <= key: if not self.get_data: raise RuntimeError('attempt to allocate more data after returning a new ParseString') self.data = self.data + self.get_data(key - len(self.data) + 1) return self.data[key] else: # replacement of __getslice__ i = key.start j = key.stop if j == sys.maxint: if self.get_data: ps = ParseString(self.get_data) self.get_data = None return ps else: raise RuntimeError('attempt to allocate another ParseString') if i < 0 or j < 0 or i > j: raise ValueError('bad slice indices: [%d:%d]' % (i, j)) if len(self.data) < j: if not self.get_data: raise RuntimeError('attempt to allocate more data after returning a new ParseString') self.data = self.data + self.get_data(j - len(self.data)) return self.data[i:j] class DummyDisplay(object): def get_resource_class(self, name): return None class ParseXbug(object): def __init__(self, infile = sys.stdin, outfile = sys.stdout): bf = BugFile(infile) self.cdata = ParseString(bf.read_client) sdata = ParseString(bf.read_server) self.outfile = outfile self.xpprint = pprint.PrettyPrinter(indent = 2, stream = outfile) self.disp = DummyDisplay() # Parse client setup request r, self.cdata = display.ConnectionSetupRequest._request.parse_binary(self.cdata, self.disp) self.print_xbug('request', 'ConnectionSetup', r) # Parse server reply r, sdata = display.ConnectionSetupRequest._reply.parse_binary(sdata, self.disp) extra = r['additional_length'] * 4 del r['additional_length'] extradata = sdata[:extra] sdata = sdata[extra:] if r['status'] == 0: r['reason'] = extradata[:r['reason_length']] del r['status'] del r['reason_length'] self.print_xbug('error', 'ConnectionSetup', r) return elif r['status'] == 1: r2, d = display.ConnectionSetupRequest._success_reply.parse_binary(extradata, self.disp) del r['status'] del r['reason_length'] r.update(r2) del r2 self.print_xbug('reply', 'ConnectionSetup', r) else: raise ValueError('bad connection setup reply status: %d' % r['status']) self.last_serial = 0 self.last_request = None while 1: # Get next server item, always at least 32 bytes d = sdata[:32] if len(d) != 32: # Print out remaining requests try: self.get_requests(sys.maxint) except ValueError: pass return sdata = sdata[32:] # Check type t = ord(d[0]) # Error if t == 0: # Code is second byte code = ord(d[1]) # Fetch error class estruct = error.xerror_class.get(code, error.XError) r, d = estruct._fields.parse_binary(d, self.disp) del r['type'] self.get_requests(r['sequence_number']) self.print_xbug('error', estruct.__name__, r) # Reply elif t == 1: # Get sequence number, and read corresponding request sno = struct.unpack('=H', d[2:4])[0] self.get_requests(sno) # Get entire reply length rlen = int(struct.unpack('=L', d[4:8])[0]) * 4 d = d + sdata[:rlen] sdata = sdata[rlen:] if self.last_request: r, d = self.last_request._reply.parse_binary(d, self.disp) self.print_xbug('reply', self.last_request.__name__, r) else: self.print_xbug('reply', 'Unknown', { 'sequence_number': sno }) # Some event else: estruct = event.event_class.get(t, event.AnyEvent) r, d = estruct._fields.parse_binary(d, self.disp) self.get_requests(r['sequence_number']) self.print_xbug('event', estruct.__name__, r) def get_requests(self, serial): # Get request length while self.last_serial < serial: d = self.cdata[2:4] if len(d) != 2: raise ValueError('client request missing') rlen = struct.unpack('=H', d)[0] * 4 d = self.cdata[:rlen] if len(d) != rlen: raise ValueError('client request missing') self.cdata = self.cdata[rlen:] opcode = ord(d[0]) self.last_request = request.major_codes.get(opcode) self.last_serial = self.last_serial + 1 if self.last_request: r, d = self.last_request._request.parse_binary(d, self.disp) r['sequence_number'] = self.last_serial self.print_xbug('request', self.last_request.__name__, r) else: self.print_xbug('request', 'Unknown (%d)' % opcode, { 'sequence_number': self.last_serial }) def print_xbug(self, rtype, name, data): self.outfile.write('%-8s %s\n' % (rtype + ':', name)) self.xpprint.pprint(data) self.outfile.write('\n') if __name__ == '__main__': ParseXbug() python-xlib-0.33/utils/tcpbug.py000077500000000000000000000043021435211557500167240ustar00rootroot00000000000000#!/usr/bin/python import socket import select import sys import os def tcpbug(listenaddr, destaddr, outputfd): listen = socket.socket(socket.AF_INET, socket.SOCK_STREAM) listen.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) listen.bind(listenaddr) listen.listen(1) client, addr = listen.accept() server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.connect(destaddr) cwbuf = swbuf = outbuf = '' while client or server or outbuf: readset = [] if client: readset.append(client) if server: readset.append(server) writeset = [] if cwbuf and client: writeset.append(client) if swbuf and server: writeset.append(server) if outbuf: writeset.append(outputfd) readset, writeset, e = select.select(readset, writeset, []) if client in readset: data = client.recv(2000) if data: swbuf = swbuf + data outbuf = outbuf + 'C%d\n%s' % (len(data), data) else: client = None if server in readset: data = server.recv(2000) if data: cwbuf = cwbuf + data outbuf = outbuf + 'S%d\n%s' % (len(data), data) else: server = None if client in writeset: n = client.send(cwbuf) cwbuf = cwbuf[n:] if server in writeset: n = server.send(swbuf) swbuf = swbuf[n:] if outputfd in writeset: n = os.write(outputfd, outbuf) outbuf = outbuf[n:] if client and not cwbuf and not server: client.close() client = None if server and not swbuf and not client: server.close() server = None def main(): try: lport = int(sys.argv[1]) dhost = sys.argv[2] dport = int(sys.argv[3]) except (IndexError, ValueError): sys.stderr.write('Usage: %s listenport desthost destport\n' % sys.argv[0]) exit(1) tcpbug(('', lport), (dhost, dport), 1) if __name__ == '__main__': main()