X11-Protocol-Other-28/ 0002755 0001750 0001750 00000000000 12237274532 012321 5 ustar gg gg X11-Protocol-Other-28/COPYING 0000644 0001750 0001750 00000104374 10641206144 013352 0 ustar gg gg
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
X11-Protocol-Other-28/Changes 0000644 0001750 0001750 00000010474 12235547646 013627 0 ustar gg gg Copyright 2011, 2012, 2013 Kevin Ryde
This file is part of X11-Protocol-Other.
X11-Protocol-Other is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at
your option) any later version.
X11-Protocol-Other is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You can get a copy of the GNU General Public License online at
.
Version 28, November 2013
- X11::Protocol::XSetRoot new use_esetroot option
Version 27, October 2013
- X11::Protocol::WM new functions get_net_wm_state(), set_net_wm_state(),
change_net_wm_state()
Version 26, October 2013
- XFixesCreatePointerBarrier() correction to sending device IDs
Version 25, September 2013
- tests TOG_CUP.t and XFree86_DGA.t further fixes
Version 24, September 2013
- X11::Protocol::XSetRoot clear Esetroot too
Version 23, December 2012
- tests fix WM.t withdraw(), and yet more relaxing XFree86_DGA.t
Version 22, November 2012
- tests MIT_SCREEN_SAVER.t allow for saver disabled
Version 21, November 2012
- X11::Protocol::WM new functions set_text_property(), get_wm_icon_size(),
get_wm_hints(), change_wm_hints()
Version 20, September 2012
- X11::Protocol::WM new aspect_to_num_den()
Version 19, September 2012
- new X11::Protocol::Ext::XTEST (protocol version 2.2)
- X11::Protocol::WM new root_to_virtual_root()
- X11::Protocol::ChooseWindow use virtual root
Version 18, March 2012
- X11::Protocol::WM new iconify() and withdraw()
- X11::Protocol::XSetRoot act on __SWM_VROOT
Version 17, January 2012
- tests more relaxing of XFree86_DGA expectations
Version 16, January 2012
- tests fixes
Version 15, January 2012
- new X11::Protocol::Ext::XFree86_DGA, protocol version 1.0
- new X11::Protocol::Ext::TOG_CUP
- XSetRoot check TOG-CUP reserved pixels
Version 14, November 2011
- X11::Protocol::WM new set_wm_normal_hints(), pack_wm_size_hints(),
set_motif_wm_hints(), pack_motif_wm_hints(),
pack_wm_hints(), unpack_wm_state(),
get_net_frame_extents(),
Version 13, November 2011
- XFIXES 5.0 pointer barriers
Version 12, October 2011
- X11::Protocol::WM fix is_utf8() fallback
Version 11, June 2011
- new Encode::X11
- X11::Protocol::WM new functions
set_wm_class()
set_wm_client_machine()
set_wm_client_machine_from_syshostname()
set_wm_command()
set_wm_icon_name()
set_wm_name()
set_wm_protocols()
set_net_wm_pid()
Version 10, June 2011
- new X11::CursorFont
- new X11::Protocol::ChooseWindow
- new X11::Protocol::Ext::DOUBLE_BUFFER
- X11::Protocol::WM new functions
frame_window_to_client()
get_wm_state()
set_net_wm_user_time()
Version 9, May 2011
- new X11::Protocol::Ext::MIT_SUNDRY_NONSTANDARD
Version 8, April 2011
- new X11::Protocol::Ext::XFIXES
- tests avoid some warning messages
Version 7, April 2011
- new X11::Protocol::Ext::MIT_SHM
- new X11::Protocol::Ext::MIT_SCREEN_SAVER
Version 6, April 2011
- new X11::Protocol::Ext::XINERAMA
- DAMAGE error "Damage"
- tests X_Resource don't stringize floats when comparing
Version 5, April 2011
- new X11::Protocol::Ext::DAMAGE extension 1.1
Version 4, April 2011
- new X11::Protocol::Ext::Composite extension 0.3
- new X11::Protocol::Ext::X_Resource extension 1.0
- XSetRoot allow pixmap=>'None' as well as 0
- WM set_net_wm_window_type() document atom integer arg
Version 3, April 2011
- new X11::Protocol::XSetRoot with set_background()
- X11::Protocol::Other new hexstr_to_rgb()
Version 2, March 2011
- new X11::AtomConstants
- new X11::Protocol::WM with functions
set_wm_hints()
set_wm_transient_for()
set_net_wm_window_type()
Version 1, February 2011
- the first version
- initial X11::Protocol::GrabServer
- initial X11::Protocol::Other, with functions
root_to_screen()
root_to_screen_info()
default_colormap_to_screen()
default_colormap_to_screen_info()
visual_is_dynamic()
visual_class_is_dynamic()
window_size()
window_visual()
X11-Protocol-Other-28/xtools/ 0002755 0001750 0001750 00000000000 12237274211 013643 5 ustar gg gg X11-Protocol-Other-28/xtools/my-wunused.sh 0000755 0001750 0001750 00000002741 12072627526 016331 0 ustar gg gg #!/bin/sh
# my-wunused.sh -- run warnings::unused on dist files
# Copyright 2009, 2010, 2011, 2012, 2013 Kevin Ryde
# my-wunused.sh is shared by several distributions.
#
# my-wunused.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# my-wunused.sh is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
set -e
set -x
EXE_FILES=`sed -n 's/^EXE_FILES = \(.*\)/\1/p' Makefile`
TO_INST_PM=`find lib -name \*.pm`
LINT_FILES="Makefile.PL $EXE_FILES $TO_INST_PM"
if test -e "t/*.t"; then
LINT_FILES="$LINT_FILES t/*.t"
fi
if test -e "xt/*.t"; then
LINT_FILES="$LINT_FILES xt/*.t"
fi
for i in t xt examples devel; do
if test -e "$i/*.pl"; then
LINT_FILES="$LINT_FILES $i/*.pl"
fi
if test -e "$i/*.pm"; then
LINT_FILES="$LINT_FILES $i/*.pm"
fi
done
echo "$LINT_FILES"
for i in $LINT_FILES; do
# warnings::unused broken by perl 5.14, so use 5.10 for checks
# perl-5.10.0 -I /usr/share/perl5 -Mwarnings::unused=-global -I lib -c $i
perl -MTest::Vars -e 'Test::Vars::vars_ok($ARGV[0])' "$i"
done
X11-Protocol-Other-28/xtools/my-diff-prev.sh 0000755 0001750 0001750 00000003006 11776230514 016511 0 ustar gg gg #!/bin/sh
# my-diff-prev.sh -- diff against previous version
# Copyright 2009, 2010, 2011, 2012 Kevin Ryde
# my-diff-prev.sh is shared by several distributions.
#
# my-diff-prev.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# my-diff-prev.sh is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
set -e
set -x
DISTNAME=`sed -n 's/^DISTNAME = \(.*\)/\1/p' Makefile`
if test -z "$DISTNAME"; then
echo "DISTNAME not found"
exit 1
fi
VERSION=`sed -n 's/^VERSION = \(.*\)/\1/p' Makefile`
if test -z "$VERSION"; then
echo "VERSION not found"
exit 1
fi
case $VERSION in
3.*) PREV_VERSION=3.018000 ;;
1.*) PREV_VERSION=1.16 ;;
*) PREV_VERSION="`expr $VERSION - 1`" ;;
esac
if test -z "$VERSION"; then
echo "PREV_VERSION not established"
exit 1
fi
rm -rf diff.tmp
mkdir -p diff.tmp
(cd diff.tmp;
tar xfz ../$DISTNAME-$PREV_VERSION.tar.gz
tar xfz ../$DISTNAME-$VERSION.tar.gz
diff -ur $DISTNAME-$PREV_VERSION \
$DISTNAME-$VERSION \
>tree.diff || true
)
${PAGER:-more} diff.tmp/tree.diff || true
rm -rf diff.tmp
exit 0
X11-Protocol-Other-28/xtools/my-check-file-part-of.sh 0000644 0001750 0001750 00000001723 11714421457 020170 0 ustar gg gg #!/bin/sh
# my-check-file-is-part-of.sh -- grep for spelling errors
# Copyright 2009, 2010, 2011, 2012 Kevin Ryde
# my-check-file-is-part-of.sh is shared by several distributions.
#
# my-check-file-is-part-of.sh is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at your
# option) any later version.
#
# my-check-file-is-part-of.sh is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
exit 0
set -e
set -x
# $(MY_EXTRA_FILE_PART_OF)
if grep --text 'This file is'' part of ' -r . | egrep -iv '$DISTNAME'
then false
else true
fi
X11-Protocol-Other-28/xtools/my-tags.sh 0000644 0001750 0001750 00000002003 11714065142 015551 0 ustar gg gg #!/bin/sh
# my-tags.sh -- make tags
# Copyright 2009, 2010, 2011, 2012 Kevin Ryde
# my-tags.sh is shared by several distributions.
#
# my-tags.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# my-tags.sh is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
set -e
set -x
# in a hash-style multi-const this "use constant" pattern only picks up the
# first constant, unfortunately, but it's better than nothing
etags \
--regex='{perl}/use[ \t]+constant\(::defer\)?[ \t]+\({[ \t]*\)?\([A-Za-z_][^ \t=,;]+\)/\3/' \
`find lib -type f`
X11-Protocol-Other-28/xtools/my-check-spelling.sh 0000755 0001750 0001750 00000003151 12212556052 017512 0 ustar gg gg #!/bin/sh
# my-check-spelling.sh -- grep for spelling errors
# Copyright 2009, 2010, 2011, 2012, 2013 Kevin Ryde
# my-check-spelling.sh is shared by several distributions.
#
# my-check-spelling.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# my-check-spelling.sh is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
set -e
# set -x
# | tee /dev/stdout
# -name samp -prune \
# -o -name formats -prune \
# -o -name "*~" -prune \
# -o -name "*.tar.gz" -prune \
# -o -name "*.deb" -prune \
# -o
# -o -name dist-deb -prune \
# | egrep -v '(Makefile|dist-deb)' \
if find . -name my-check-spelling.sh -prune \
-o -type f -print0 \
| xargs -0 egrep --color=always -nHi 'recurrance|nineth|\bon on\b|\bto to\b|tranpose|adjustement|glpyh|rectanglar|availabe|grabing|cusor|refering|writeable|nineth|\bommitt?ed|omited|[$][rd]elf|requrie|noticable|continous|existant|explict|agument|destionation|\bthe the\b|\bfor for\b|\bare have\b|\bare are\b|\bwith with\b|\bin in\b|\b[tw]hen then\b|\bnote sure\b|\bnote yet\b|correspondance|sprial|wholely|satisif'
then
# nothing found
exit 1
else
exit 0
fi
X11-Protocol-Other-28/xtools/my-kwalitee.sh 0000755 0001750 0001750 00000002146 11775434756 016455 0 ustar gg gg #!/bin/sh
# my-kwalitee.sh -- run cpants_lint kwalitee checker
# Copyright 2009, 2010, 2011, 2012 Kevin Ryde
# my-kwalitee.sh is shared by several distributions.
#
# my-kwalitee.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# my-kwalitee.sh is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
# Module::CPANTS::Analyse
set -e
set -x
DISTVNAME=`sed -n 's/^DISTVNAME = \(.*\)/\1/p' Makefile`
if test -z "$DISTVNAME"; then
echo "DISTVNAME not found"
exit 1
fi
if [ -e ~/bin/my-gpg-agent-daemon ]; then
eval `my-gpg-agent-daemon`
echo "gpg-agent $GPG_AGENT_INFO"
fi
TGZ="$DISTVNAME.tar.gz"
make "$TGZ"
cpants_lint "$TGZ"
X11-Protocol-Other-28/xtools/my-pc.sh 0000755 0001750 0001750 00000003233 12206324154 015224 0 ustar gg gg #!/bin/sh
# my-pc.sh -- run cpants_lint kwalitee checker
# Copyright 2009, 2010, 2011, 2012, 2013 Kevin Ryde
# my-pc.sh is shared by several distributions.
#
# my-pc.sh is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at your
# option) any later version.
#
# my-pc.sh is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
set -x
# PERLRUNINST=`sed -n 's/^PERLRUNINST = \(.*\)/\1/p' Makefile`
# if test -z "$PERLRUNINST"; then
# echo "PERLRUNINST not found"
# exit 1
# fi
EXE_FILES=`sed -n 's/^EXE_FILES = \(.*\)/\1/p' Makefile`
TO_INST_PM=`find lib -name \*.pm`
LINT_FILES="Makefile.PL $EXE_FILES $TO_INST_PM"
if test -e "t/*.t"; then
LINT_FILES="$LINT_FILES t/*.t"
fi
if test -e "xt/*.t"; then
LINT_FILES="$LINT_FILES xt/*.t"
fi
for i in t xt examples devel; do
if test -e "$i/*.pl"; then
LINT_FILES="$LINT_FILES $i/*.pl"
fi
if test -e "$i/*.pm"; then
LINT_FILES="$LINT_FILES $i/*.pm"
fi
done
perl -e 'use Test::Vars; all_vars_ok()'
# MyMakeMakerExtras_Pod_Coverage
perl -e 'use Pod::Coverage package => $class'
podlinkcheck -I lib `ls $LINT_FILES | grep -v '\.bash$$|\.desktop$$\.png$$|\.xpm$$'`
podchecker -nowarnings `ls $LINT_FILES | grep -v '\.bash$$|\.desktop$$\.png$$|\.xpm$$'`
perlcritic $LINT_FILES
X11-Protocol-Other-28/xtools/my-deb.sh 0000755 0001750 0001750 00000006761 12070737741 015376 0 ustar gg gg #!/bin/sh
# my-deb.sh -- make .deb
# Copyright 2009, 2010, 2011, 2012, 2013 Kevin Ryde
# my-deb.sh is shared by several distributions.
#
# my-deb.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# my-deb.sh is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
# warnings::unused broken by perl 5.14, so use 5.10 for checks
set -e
set -x
DISTNAME=`sed -n 's/^DISTNAME = \(.*\)/\1/p' Makefile`
if test -z "$DISTNAME"; then
echo "DISTNAME not found"
exit 1
fi
DISTVNAME=`sed -n 's/^DISTVNAME = \(.*\)/\1/p' Makefile`
if test -z "$DISTVNAME"; then
echo "DISTVNAME not found"
exit 1
fi
VERSION=`sed -n 's/^VERSION = \(.*\)/\1/p' Makefile`
if test -z "$VERSION"; then
echo "VERSION not found"
exit 1
fi
XS_FILES=`sed -n 's/^XS_FILES = \(.*\)/\1/p' Makefile`
EXE_FILES=`sed -n 's/^EXE_FILES = \(.*\)/\1/p' Makefile`
if test -z "$XS_FILES"
then DPKG_ARCH=all
else DPKG_ARCH=`dpkg --print-architecture`
fi
# programs named after the dist, libraries named with "lib"
# gtk2-ex-splash and wx-perl-podbrowser programs are lib too though
DEBNAME=`echo $DISTNAME | tr A-Z a-z`
case "$EXE_FILES" in
gtk2-ex-splash|wx-perl-podbrowser|'')
DEBNAME="lib${DEBNAME}-perl" ;;
esac
DEBVNAME="${DEBNAME}_$VERSION-0.1"
DEBFILE="${DEBVNAME}_$DPKG_ARCH.deb"
# ExtUtils::MakeMaker 6.42 of perl 5.10.0 makes "$(DISTVNAME).tar.gz" depend
# on "$(DISTVNAME)" distdir directory, which is always non-existent after a
# successful dist build, so the .tar.gz is always rebuilt.
#
# So although the .deb depends on the .tar.gz don't express that here or it
# rebuilds the .tar.gz every time.
#
# The right rule for the .tar.gz would be to depend on the files which go
# into it of course ...
#
# DISPLAY is unset for making a deb since under fakeroot gtk stuff may try
# to read config files like ~/.pangorc from root's home dir /root/.pangorc,
# and that dir will be unreadable by ordinary users (normally), provoking
# warnings and possible failures from nowarnings().
#
test -f $DISTVNAME.tar.gz || make $DISTVNAME.tar.gz
debver="`dpkg-parsechangelog -c1 | sed -n -r -e 's/^Version: (.*)-[0-9.]+$/\1/p'`"
echo "debver $debver", want $VERSION
test "$debver" = "$VERSION"
rm -rf $DISTVNAME
tar xfz $DISTVNAME.tar.gz
unset DISPLAY; export DISPLAY
cd $DISTVNAME
dpkg-checkbuilddeps debian/control
fakeroot debian/rules binary
cd ..
rm -rf $DISTVNAME
#------------------------------------------------------------------------------
# lintian .deb and source
lintian -I -i \
--suppress-tags new-package-should-close-itp-bug,desktop-entry-contains-encoding-key \
$DEBFILE
TEMP="/tmp/temp-lintian-$DISTVNAME"
rm -rf $TEMP
mkdir $TEMP
cp $DISTVNAME.tar.gz $TEMP/${DEBNAME}_$VERSION.orig.tar.gz
cd $TEMP
tar xfz ${DEBNAME}_$VERSION.orig.tar.gz
if test "$DISTVNAME" != "$DEBNAME-$VERSION"; then
mv -T $DISTVNAME $DEBNAME-$VERSION
fi
dpkg-source -b $DEBNAME-$VERSION \
${DEBNAME}_$VERSION.orig.tar.gz; \
lintian -I -i \
--suppress-tags maintainer-upload-has-incorrect-version-number,empty-debian-diff,debian-rules-uses-deprecated-makefile *.dsc
cd /
rm -rf $TEMP
exit 0
X11-Protocol-Other-28/xtools/my-manifest.sh 0000755 0001750 0001750 00000001652 11764227757 016456 0 ustar gg gg #!/bin/sh
# my-manifest.sh -- update MANIFEST file
# Copyright 2009, 2010, 2011, 2012 Kevin Ryde
# my-manifest.sh is shared by several distributions.
#
# my-manifest.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# my-manifest.sh is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
set -e
if [ -e MANIFEST ]; then
mv MANIFEST MANIFEST.old || true
fi
touch SIGNATURE
(
make manifest 2>&1;
diff -u MANIFEST.old MANIFEST
) | ${PAGER:-more}
X11-Protocol-Other-28/xtools/my-check-copyright-years.sh 0000755 0001750 0001750 00000004037 12230015164 021024 0 ustar gg gg #!/bin/sh
# my-check-copyright-years.sh -- check copyright years in dist
# Copyright 2009, 2010, 2011, 2012, 2013 Kevin Ryde
# my-check-copyright-years.sh is shared by several distributions.
#
# my-check-copyright-years.sh is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at your
# option) any later version.
#
# my-check-copyright-years.sh is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
set -e
#set -x
# find files in the dist with mod times this year, but without this year in
# the copyright line
if test -z "$DISTVNAME"; then
DISTVNAME=`sed -n 's/^DISTVNAME = \(.*\)/\1/p' Makefile`
fi
if test -z "$DISTVNAME"; then
echo "DISTVNAME not found"
exit 1
fi
MY_HIDE=
year=`date +%Y`
result=0
# files with dates $year
tar tvfz $DISTVNAME.tar.gz \
| egrep "$year-|debian/copyright" \
| sed "s:^.*$DISTVNAME/::" \
| {
while read i
do
# echo "consider $i"
GREP=grep
case $i in \
'' | */ \
| ppport.h \
| debian/changelog | debian/compat | debian/doc-base \
| debian/patches/*.diff | debian/source/format \
| COPYING | MANIFEST* | SIGNATURE | META.yml | META.json \
| version.texi | */version.texi \
| *utf16* | examples/rs''s2lea''fnode.conf \
| */MathI''mage/ln2.gz | */MathI''mage/pi.gz \
| *.mo | *.locatedb* | t/samp.* \
| t/empty.dat | t/*.xpm | t/*.xbm | t/*.jpg | t/*.gif \
| t/*.g${MY_HIDE}d)
continue ;;
*.gz)
GREP=zgrep
esac; \
if test -e "$srcdir/$i"
then f="$srcdir/$i"
else f="$i"
fi
if $GREP -q -e "Copyright.*$year" $f
then :;
else
echo "$i:1: this file"
grep Copyright $f
result=1
fi
done
}
exit $result
X11-Protocol-Other-28/xt/ 0002755 0001750 0001750 00000000000 12237274211 012746 5 ustar gg gg X11-Protocol-Other-28/xt/0-Test-ConsistentVersion.t 0000644 0001750 0001750 00000002253 11655356324 017715 0 ustar gg gg #!/usr/bin/perl -w
# 0-Test-ConsistentVersion.t -- run Test::ConsistentVersion if available
# Copyright 2011 Kevin Ryde
# 0-Test-ConsistentVersion.t is shared by several distributions.
#
# 0-Test-ConsistentVersion.t is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# 0-Test-ConsistentVersion.t is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
use 5.004;
use strict;
use Test::More;
eval { require Test::ConsistentVersion }
or plan skip_all => "due to Test::ConsistentVersion not available -- $@";
Test::ConsistentVersion::check_consistent_versions
(no_readme => 1, # no version number in my READMEs
no_pod => 1, # no version number in my docs, at the moment
);
# ! -e 'README');
exit 0;
X11-Protocol-Other-28/xt/Encode-X11-emacs.t 0000644 0001750 0001750 00000005551 12231571025 015766 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011, 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Check that emacs decodes the Encode::X11 output successfully.
use 5.004;
use strict;
use warnings;
use Test;
use FindBin;
use File::Spec;
use lib 't';
use MyTestHelpers;
MyTestHelpers::nowarnings();
# uncomment this to run the ### lines
#use Devel::Comments;
my $test_count = 4;
plan tests => $test_count;
if (! eval { require Encode }) {
MyTestHelpers::diag ('Encode.pm module not available -- ',$@);
foreach (1 .. $test_count) {
skip ('No Encode module', 1, 1);
}
exit 0;
}
require Encode::X11;
#------------------------------------------------------------------------------
# emacs23 decodes 0x1B 0x28 0x49 0x7E as ascii 0x7E instead of overline U+203E
# skip that one for now
my @ords = grep { ! ($_ == 0x7E
|| ($_ >= 0x7F && $_ <= 0x9F)
|| ($_ >= 0xD800 && $_ <= 0xDFFF)
|| ($_ >= 0xFDD0 && $_ <= 0xFDEF)
|| ($_ >= 0xFFFE && $_ <= 0xFFFF)
|| ($_ >= 0x1FFFE && $_ <= 0x1FFFF)) }
# 32 .. 0x2FA1;
32 .. 0x2FA1D;
{
my $chars = '';
my $bytes = '';
foreach my $i (@ords) {
### i: sprintf("0x%X",$i)
my $chr = chr($i);
my $input_chr = $chr;
my $encode = Encode::encode('x11-compound-text', $input_chr,
Encode::FB_QUIET());
if (length $input_chr) {
MyTestHelpers::diag ("skip unencodable ",to_hex($chr));
next;
}
$bytes .= $encode;
$chars .= $chr;
}
{
open my $fh, '> :raw', 'tempfile.ctext' or die;
print $fh $bytes or die;
close $fh or die;
}
{
open my $fh, '> :encoding(utf-8)', 'tempfile.utf8' or die;
print $fh $chars or die;
close $fh or die;
}
}
my $elfile = File::Spec->catfile ($FindBin::Bin, 'Encode-X11-emacs.el');
foreach my $emacs ("emacs21","emacs22","emacs23","emacs24") {
my $have_emacs = -x "/usr/bin/$emacs";
my $exit_status = 0;
if ($have_emacs) {
$exit_status = system("$emacs -batch -q -no-site-file -l $elfile -f my-try-decode"),
}
my $skip = ($have_emacs ? undef : "/usr/bin/$emacs not available");
skip ($skip, $exit_status, 0);
}
# unlink 'tempfile.ctext';
# unlink 'tempfile.utf8';
exit 0;
X11-Protocol-Other-28/xt/0-Test-Synopsis.t 0000755 0001750 0001750 00000001764 11655356314 016055 0 ustar gg gg #!/usr/bin/perl -w
# 0-Test-Synopsis.t -- run Test::Synopsis if available
# Copyright 2009, 2010, 2011 Kevin Ryde
# 0-Test-Synopsis.t is shared by several distributions.
#
# 0-Test-Synopsis.t is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# 0-Test-Synopsis.t is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
use 5.004;
use strict;
use Test::More;
eval 'use Test::Synopsis; 1'
or plan skip_all => "due to Test::Synopsis not available -- $@";
## no critic (ProhibitCallsToUndeclaredSubs)
all_synopsis_ok();
exit 0;
X11-Protocol-Other-28/xt/0-no-debug-left-on.t 0000755 0001750 0001750 00000006515 12044143060 016333 0 ustar gg gg #!/usr/bin/perl -w
# 0-no-debug-left-on.t -- check no Smart::Comments left on
# Copyright 2011, 2012 Kevin Ryde
# 0-no-debug-left-on.t is shared by several distributions.
#
# 0-no-debug-left-on.t is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# 0-no-debug-left-on.t is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
# cf Test::NoSmartComments which uses Module::ScanDeps.
require 5;
use strict;
Test::NoDebugLeftOn->Test_More(verbose => 0);
exit 0;
package Test::NoDebugLeftOn;
use strict;
use ExtUtils::Manifest;
sub Test_More {
my ($class, %options) = @_;
require Test::More;
Test::More::plan (tests => 1);
Test::More::ok ($class->check (diag => \&Test::More::diag,
%options));
1;
}
sub check {
my ($class, %options) = @_;
my $diag = $options{'diag'};
if (! -e 'Makefile.PL') {
&$diag ('skip, no Makefile.PL so not ExtUtils::MakeMaker');
return 1;
}
my $href = ExtUtils::Manifest::maniread();
my @files = keys %$href;
my $good = 1;
my @perl_files = grep {m{
^lib/
|^(lib|examples|x?t)/.*\.(p[lm]|t)$
|^Makefile.PL$
|^[^/]+$
}x
} @files;
my $filename;
foreach $filename (@perl_files) {
if ($options{'verbose'}) {
&$diag ("perl file ",$filename);
}
if (! open FH, "< $filename") {
&$diag ("Oops, cannot open $filename: $!");
$good = 0;
next;
}
while () {
if (/^__END__/) {
last;
}
# only a DEBUG=> non-zero number is bad, so an expression can copy a
# debug from another package
if (/(DEBUG\s*=>\s*[1-9][0-9]*)/
|| /^[ \t]*((use|no) (Smart|Devel)::Comments)/
|| /^[ \t]*(use lib\b.*devel.*)/
) {
print STDERR "\n$filename:$.: leftover: $_\n";
$good = 0;
}
}
if (! close FH) {
&$diag ("Oops, error closing $filename: $!");
$good = 0;
next;
}
}
my @C_files = grep {m{
# toplevel or lib .c and .xs files
^[^/]*\.([ch]|xs)$
|^(lib|examples|x?t)/.*\.([ch]|xs)$
}x
} @files;
foreach $filename (@C_files) {
if ($options{'verbose'}) {
&$diag ("C/XS file ",$filename);
}
if (! open FH, "< $filename") {
&$diag ("Oops, cannot open $filename: $!");
$good = 0;
next;
}
while () {
if (/^#\s*define\s+DEBUG\s+[1-9]/
) {
print STDERR "\n$filename:$.: leftover: $_\n";
$good = 0;
}
}
if (! close FH) {
&$diag ("Oops, error closing $filename: $!");
$good = 0;
next;
}
}
&$diag ("checked ",scalar(@perl_files)," perl files, ",
scalar(@C_files)," C/XS files\n");
return $good;
}
X11-Protocol-Other-28/xt/Encode-round.t 0000644 0001750 0001750 00000005046 11602200523 015446 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use 5.004;
use strict;
use warnings;
use Test;
use lib 't';
use MyTestHelpers;
MyTestHelpers::nowarnings();
my $test_count = 1;
plan tests => $test_count;
if (! eval { require Encode }) {
MyTestHelpers::diag ('Encode.pm module not available -- ',$@);
foreach (1 .. $test_count) {
skip ('No Encode module', 1, 1);
}
exit 0;
}
require Encode::X11;
#------------------------------------------------------------------------------
# round trip
my @ords = grep { ! (($_ >= 0x7F && $_ <= 0x9F)
|| ($_ >= 0xD800 && $_ <= 0xDFFF)
|| ($_ >= 0xFDD0 && $_ <= 0xFDEF)
|| ($_ >= 0xFFFE && $_ <= 0xFFFF)
|| ($_ >= 0x1FFFE && $_ <= 0x1FFFF)) }
32 .. 0x2FA1D;
# 32 .. 0x203E;
MyTestHelpers::diag("encode-decode exercise ",scalar(@ords)," many ords");
{
my $good = 1;
my $count = 0;
foreach my $i (@ords) {
my $chr = chr($i);
my $input_chr = $chr;
my $bytes = Encode::encode('x11-compound-text', $input_chr,
Encode::FB_QUIET());
if (length $input_chr) {
# diag "skip unencodable ",to_hex($chr);
next;
}
$count++;
my $bytes_left = $bytes;
my $decode = Encode::decode('x11-compound-text', $bytes_left,
Encode::FB_QUIET());
if ($bytes_left) {
MyTestHelpers::diag (sprintf "U+%04X decode remaining bytes: %s\n", $i, to_hex($bytes_left));
$good = 0;
}
if ($decode ne $chr) {
MyTestHelpers::diag (sprintf "U+%04X decode got %s want %s",
$i, to_hex($decode), to_hex($chr));
MyTestHelpers::diag (sprintf " encode bytes [len %d] %s",
length($bytes), to_hex($bytes));
$good = 0;
exit 1;
}
}
MyTestHelpers::diag ("total count ", $count);
ok ($good);
}
exit 0;
X11-Protocol-Other-28/xt/0-file-is-part-of.t 0000644 0001750 0001750 00000005766 12136177231 016204 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011, 2012, 2013 Kevin Ryde
# 0-file-is-part-of.t is shared by several distributions.
#
# 0-file-is-part-of.t is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# 0-file-is-part-of.t is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
require 5;
use strict;
use Test::More tests => 1;
use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings(); }
ok (Test::FileIsPartOfDist->check(verbose=>1),
'Test::FileIsPartOfDist');
exit 0;
package Test::FileIsPartOfDist;
BEGIN { require 5 }
use strict;
use ExtUtils::Manifest;
use File::Slurp;
sub import {
my $class = shift;
my $arg;
foreach $arg (@_) {
if ($arg eq '-test') {
require Test;
Test::plan(tests=>1);
is ($class->check, 1, 'Test::FileIsPartOfDist');
}
}
return 1;
}
sub new {
my $class = shift;
return bless { @_ }, $class;
}
sub check {
my $class = shift;
my $self = $class->new(@_);
my $manifest = ExtUtils::Manifest::maniread();
if (! $manifest) {
$self->diag("no MANIFEST perhaps");
return 0;
}
my @filenames = keys %$manifest;
my $distname = $self->makefile_distname;
if (! defined $distname) {
$self->diag("Oops, DISTNAME not found in Makefile");
return 0;
}
if ($self->{'verbose'}) {
$self->diag("DISTNAME $distname");
}
my $good = 1;
my $filename;
foreach $filename (@filenames) {
if (! $self->check_file_is_part_of($filename,$distname)) {
$good = 0;
}
}
return $good;
}
sub makefile_distname {
my ($self) = @_;
my $filename = "Makefile";
my $content = File::Slurp::read_file ($filename);
if (! defined $content) {
$self->diag("Cannot read $filename: $!");
return undef;
}
my $distname;
if ($content =~ /^DISTNAME\s*=\s*([^#\n]*)/m) {
$distname = $1;
$distname =~ s/\s+$//;
}
return $distname;
}
sub check_file_is_part_of {
my ($self, $filename, $distname) = @_;
my $content = File::Slurp::read_file ($filename);
if (! defined $content) {
$self->diag("Cannot read $filename: $!");
return 0;
}
$content =~ /([T]his file is part of[^\n]*)/i
or return 1;
my $got = $1;
if ($got =~ /[T]his file is part of \Q$distname/i) {
return 1;
}
$self->diag("$filename: $got");
$self->diag("expected DISTNAME: $distname");
return 0;
}
sub diag {
my $self = shift;
my $func = $self->{'diag_func'}
|| eval { Test::More->can('diag') }
|| \&_diag;
&$func(@_);
}
sub _diag {
my $msg = join('', map {defined($_)?$_:'[undef]'} @_)."\n";
$msg =~ s/^/# /mg;
print STDERR $msg;
}
X11-Protocol-Other-28/xt/XSetRoot-xsetroot.t 0000644 0001750 0001750 00000011320 12235773622 016552 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Exercise the inter-operation with xsetroot. The properties it sets should
# be deleted by X11::Protocol::XSetRoot->set_background().
#
# This test requires that the root visual is dynamic, ie. PseudoColor etc.
# The x.org Xvfb test server can be run up with that by
#
# xvfb-run -a -s '-cc 33' perl XSetRoot-xsetroot.t
#
# If that doesn't seem to work then check its operation with
# xvfb-run -a -s '-cc 33' xdpyinfo
BEGIN { require 5 }
use strict;
use Test;
use FindBin;
use lib "$FindBin::Bin/../t";
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }
use X11::Protocol::Other;
use X11::Protocol::XSetRoot;
# uncomment this to run the ### lines
#use Smart::Comments;
my $test_count = (tests => 5)[1];
plan tests => $test_count;
require X11::Protocol;
MyTestHelpers::diag ("X11::Protocol version ", X11::Protocol->VERSION);
my $display = $ENV{'DISPLAY'};
if (! defined $display) {
foreach (1 .. $test_count) {
skip ('No DISPLAY set', 1, 1);
}
exit 0;
}
MyTestHelpers::diag ("DISPLAY ", $display);
# pass display arg so as not to get a "guess" warning
my $X;
if (! eval { $X = X11::Protocol->new ($display); }) {
MyTestHelpers::diag ('Cannot connect to X server -- ',$@);
foreach (1 .. $test_count) {
skip ('Cannot connect to X server', 1, 1);
}
exit 0;
}
$X->QueryPointer($X->{'root'}); # sync
my $visual = $X->{'root_visual'};
my $visual_is_dynamic = X11::Protocol::Other::visual_is_dynamic($X,$visual);
if (! $visual_is_dynamic) {
MyTestHelpers::diag ("root_visual $visual is not dynamic, xsetroot won't RetainPermanent");
foreach (1 .. $test_count) {
skip ('root visual not dynamic', 1, 1);
}
exit 0;
}
MyTestHelpers::diag ('root visual is dynamic');
# Something fishy with xvfb test server seems to cause the reconnect below
# to fail. Keeping a second connection makes it better, dunno why.
my $keepalive_X = X11::Protocol->new ($display);
my $xsetroot_output = `xsetroot 2>&1`;
my $have_xsetroot = ($? == 0);
if (! $have_xsetroot) {
MyTestHelpers::diag ("xsetroot error:\n", $xsetroot_output);
foreach (1 .. $test_count) {
skip ('xsetroot program not available', 1, 1);
}
exit 0;
}
MyTestHelpers::diag ('xsetroot available');
#------------------------------------------------------------------------------
# set_background()
system ('xsetroot -solid pink');
# Properties are set.
my $xrootpmap;
{
my ($value, $type, $format, $bytes_after)
= $X->GetProperty ($X->root, $X->atom('_XSETROOT_ID'),
0, # AnyPropertyType
0, # offset
1, # length
0); # delete;
ok ($type, X11::AtomConstants::PIXMAP());
ok ($format, 32);
if ($type == X11::AtomConstants::PIXMAP()) {
$xrootpmap = unpack 'L', $value;
}
}
X11::Protocol::XSetRoot->set_background
(display => $display,
color => 'black');
# Properties should be deleted by set_background().
{
my ($value, $type, $format, $bytes_after)
= $X->GetProperty ($X->root, $X->atom('_XSETROOT_ID'),
0, # AnyPropertyType
0, # offset
1, # length
0); # delete;
ok ($type, 0);
ok ($format, 0);
}
{
my $skip;
my $xrootpmap_now_exists;
if (! $xrootpmap) {
$skip = 'due to _XSETROOT_ID not set';
} else {
my @ret = $X->robust_req ('GetImage',
$xrootpmap,
0,0, 1,1,
0xFFFF_FFFF, # plane mask
'ZPixmap'); # format
if (ref $ret[0]) {
# success
$xrootpmap_now_exists = 1;
} else {
my ($type, $major, $minor) = @ret;
MyTestHelpers::diag ("GetImage error (expected): type=$type opcode=$major.$minor");
# error
$xrootpmap_now_exists = 0;
}
}
skip ($skip,
$xrootpmap_now_exists, 0,
'_XSETROOT_ID pixmap should now not exist (due to KillClient)');
}
#------------------------------------------------------------------------------
exit 0;
X11-Protocol-Other-28/xt/0-Test-DistManifest.t 0000755 0001750 0001750 00000002311 11655356331 016604 0 ustar gg gg #!/usr/bin/perl -w
# 0-Test-DistManifest.t -- run Test::DistManifest if available
# Copyright 2009, 2010, 2011 Kevin Ryde
# 0-Test-DistManifest.t is shared by several distributions.
#
# 0-Test-DistManifest.t is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# 0-Test-DistManifest.t is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
use 5.004;
use strict;
use Test::More;
# This is only an author test really and it only really does much in a
# working directory where newly added files will exist. In a dist dir
# something would have to be badly wrong for the manifest to be off.
eval { require Test::DistManifest }
or plan skip_all => "due to Test::DistManifest not available -- $@";
Test::DistManifest::manifest_ok();
exit 0;
X11-Protocol-Other-28/xt/0-examples-xrefs.t 0000644 0001750 0001750 00000004300 12230011245 016213 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011, 2013 Kevin Ryde
# 0-examples-xrefs.t is shared by several distributions.
#
# 0-examples-xrefs.t is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# 0-examples-xrefs.t is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
BEGIN { require 5 }
use strict;
use ExtUtils::Manifest;
use Test::More;
use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings(); }
my $manifest = ExtUtils::Manifest::maniread();
my @example_files = grep m{examples/.*\.pl$}, keys %$manifest;
my @lib_files = grep m{lib/.*\.(pm|pod)$}, keys %$manifest;
sub any_file_contains_example {
my ($example) = @_;
my $filename;
foreach $filename (@lib_files) {
if (pod_contains_example($filename, $example)) {
return 1;
}
}
foreach $filename (@example_files) {
if ($filename ne $example
&& raw_contains_example($filename, $example)) {
return 1;
}
}
return 0;
}
sub pod_contains_example {
my ($filename, $example) = @_;
open FH, "< $filename" or die "Cannot open $filename: $!";
my $content = do { local $/; }; # slurp
close FH or die "Error closing $filename: $!";
return scalar ($content =~ /F<\Q$example\E>
|F\s+directory
/xs);
}
sub raw_contains_example {
my ($filename, $example) = @_;
$example =~ s{^examples/}{};
open FH, "< $filename" or die "Cannot open $filename: $!";
my $ret = scalar (grep /\b\Q$example\E\b/, );
close FH or die "Error closing $filename: $!";
return $ret > 0;
}
plan tests => scalar(@example_files) + 1;
my $example;
foreach $example (@example_files) {
is (any_file_contains_example($example), 1,
"$example mentioned in some lib/ file");
}
ok(1);
exit 0;
X11-Protocol-Other-28/xt/Encode-X11-emacs.el 0000644 0001750 0001750 00000002673 11601324072 016123 0 ustar gg gg ;; Copyright 2011 Kevin Ryde
;;
;; This file is part of X11-Protocol-Other.
;;
;; X11-Protocol-Other is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 3, or (at your option) any
;; later version.
;;
;; X11-Protocol-Other is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
;; Public License for more details.
;;
;; You should have received a copy of the GNU General Public License along
;; with X11-Protocol-Other. If not, see .
(defun my-try-decode ()
(unless (coding-system-p 'utf-8)
(require 'un-define))
(let (ustr ubuf cstr cbuf)
(let ((coding-system-for-read 'utf-8))
(find-file "../tempfile.utf8")
(setq ubuf (current-buffer))
(setq ustr (buffer-string)))
(let ((coding-system-for-read 'ctext))
(find-file "tempfile.ctext")
(setq cbuf (current-buffer))
(setq cstr (buffer-string)))
(let ((pos (compare-strings ustr nil nil
cstr nil nil)))
(unless (eq pos t)
(error "different at %S" pos)
(with-current-buffer ubuf
(goto-char (+ (point-min) (pos))))
(with-current-buffer cbuf
(goto-char (+ (point-min) (pos))))))))
X11-Protocol-Other-28/xt/0-Test-YAML-Meta.t 0000755 0001750 0001750 00000003262 11655356345 015653 0 ustar gg gg #!/usr/bin/perl -w
# 0-Test-YAML-Meta.t -- run Test::YAML::Meta if available
# Copyright 2009, 2010, 2011 Kevin Ryde
# 0-Test-YAML-Meta.t is shared by several distributions.
#
# 0-Test-YAML-Meta.t is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# 0-Test-YAML-Meta.t is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
use 5.004;
use strict;
use Test::More;
my $meta_filename = 'META.yml';
unless (-e $meta_filename) {
plan skip_all => "$meta_filename doesn't exist -- assume this is a working directory not a dist";
}
eval { require CPAN::Meta::Validator; 1 }
or plan skip_all => "due to CPAN::Meta::Validator not available -- $@";
eval { require YAML; 1 }
or skip "due to YAML module not available -- $@", 1;
plan tests => 1;
my $struct = YAML::LoadFile ($meta_filename);
my $cmv = CPAN::Meta::Validator->new($struct);
ok ($cmv->is_valid);
if (! $cmv->is_valid) {
diag "CPAN::Meta::Validator errors:";
foreach ($cmv->errors) { diag $_; }
}
exit 0;
# # Test::CPAN::Meta::YAML version 0.15 for upper case "optional_features" names
# #
# eval 'use Test::YAML::Meta 0.15; 1'
# or plan skip_all => "due to Test::CPAN::Meta::YAML 0.15 not available -- $@";
#
# Test::CPAN::Meta::YAML::meta_yaml_ok();
X11-Protocol-Other-28/xt/XSetRoot-Esetroot.t 0000644 0001750 0001750 00000011747 12236240465 016477 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Exercise the inter-operation with Esetroot. The properties it sets should
# be deleted by X11::Protocol::XSetRoot->set_background().
#
# imlib_render_pixmaps_for_whole_image_at_size
# xvfb-run -a -s '-cc 33' Esetroot /usr/share/doc/imagemagick/images/black.png
# xvfb-run -a -s '-cc 33' debian/build/utils/Esetroot /usr/share/doc/imagemagick/images/black.png
BEGIN { require 5 }
use strict;
use Test;
use FindBin;
use lib "$FindBin::Bin/../t";
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }
# uncomment this to run the ### lines
#use Smart::Comments;
my $test_count = (tests => 9)[1];
plan tests => $test_count;
require X11::Protocol;
MyTestHelpers::diag ("X11::Protocol version ", X11::Protocol->VERSION);
my $display = $ENV{'DISPLAY'};
if (! defined $display) {
foreach (1 .. $test_count) {
skip ('No DISPLAY set', 1, 1);
}
exit 0;
}
MyTestHelpers::diag ("DISPLAY ", $display);
# pass display arg so as not to get a "guess" warning
my $X;
if (! eval { $X = X11::Protocol->new ($display); }) {
MyTestHelpers::diag ('Cannot connect to X server -- ',$@);
foreach (1 .. $test_count) {
skip ('Cannot connect to X server', 1, 1);
}
exit 0;
}
$X->QueryPointer($X->{'root'}); # sync
# Something fishy with xvfb test server seems to cause the reconnect below
# to fail. Keeping a second connection makes it better, dunno why.
my $keepalive_X = X11::Protocol->new ($display);
my $Esetroot_output = `Esetroot 2>&1`;
my $have_Esetroot = ($? == 0);
if (! $have_Esetroot) {
MyTestHelpers::diag ("Esetroot error:\n", $Esetroot_output);
foreach (1 .. $test_count) {
skip ('Esetroot program not available', 1, 1);
}
exit 0;
}
MyTestHelpers::diag ('Esetroot available');
require X11::Protocol::XSetRoot;
#------------------------------------------------------------------------------
# set_background()
# system ('Esetroot /usr/share/Eterm/pix/help.png');
system ('Esetroot /usr/share/doc/imagemagick/images/black.png');
# Properties are set.
my $xrootpmap;
{
my ($value, $type, $format, $bytes_after)
= $X->GetProperty ($X->root, $X->atom('_XROOTPMAP_ID'),
0, # AnyPropertyType
0, # offset
1, # length
0); # delete;
ok ($type, X11::AtomConstants::PIXMAP());
ok ($format, 32);
if ($type == X11::AtomConstants::PIXMAP()) {
$xrootpmap = unpack 'L', $value;
}
}
{
my ($value, $type, $format, $bytes_after)
= $X->GetProperty ($X->root, $X->atom('ESETROOT_PMAP_ID'),
0, # AnyPropertyType
0, # offset
1, # length
0); # delete;
ok ($type, X11::AtomConstants::PIXMAP());
ok ($format, 32);
}
X11::Protocol::XSetRoot->set_background
(display => $display,
color => 'black');
# Properties should be deleted by set_background().
{
my ($value, $type, $format, $bytes_after)
= $X->GetProperty ($X->root, $X->atom('_XROOTPMAP_ID'),
0, # AnyPropertyType
0, # offset
1, # length
0); # delete;
ok ($type, 0);
ok ($format, 0);
}
{
my ($value, $type, $format, $bytes_after)
= $X->GetProperty ($X->root, $X->atom('ESETROOT_PMAP_ID'),
0, # AnyPropertyType
0, # offset
1, # length
0); # delete;
ok ($type, 0);
ok ($format, 0);
}
{
my $skip;
my $xrootpmap_now_exists;
if (! $xrootpmap) {
$skip = 'due to _XSETROOT_ID not set';
} else {
my @ret = $X->robust_req ('GetImage',
$xrootpmap,
0,0, 1,1,
0xFFFF_FFFF, # plane mask
'ZPixmap'); # format
if (ref $ret[0]) {
# success
$xrootpmap_now_exists = 1;
} else {
my ($type, $major, $minor) = @ret;
MyTestHelpers::diag ("GetImage error (expected): type=$type opcode=$major.$minor");
# error
$xrootpmap_now_exists = 0;
}
}
skip ($skip,
$xrootpmap_now_exists, 0,
'_XROOTPMAP_ID pixmap should now not exist (due to KillClient)');
}
#------------------------------------------------------------------------------
exit 0;
X11-Protocol-Other-28/xt/0-META-read.t 0000755 0001750 0001750 00000010715 12136177162 014741 0 ustar gg gg #!/usr/bin/perl -w
# 0-META-read.t -- check META.yml can be read by various YAML modules
# Copyright 2009, 2010, 2011, 2012, 2013 Kevin Ryde
# 0-META-read.t is shared among several distributions.
#
# 0-META-read.t is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# 0-META-read.t is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
use 5.005;
use strict;
use Test::More;
use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings(); }
# When some of META.yml is generated by explicit text in Makefile.PL it can
# be easy to make a mistake in the syntax, or indentation, etc, so the idea
# here is to check it's readable from some of the YAML readers.
#
# The various readers differ in how strictly they look at the syntax.
# There's no attempt here to say one of them is best or tightest or
# whatever, just see that they all work.
#
# See 0-Test-YAML-Meta.t for Test::YAML::Meta which looks into field
# contents, as well as maybe the YAML formatting.
my $meta_filename;
# allow for ancient perl, maybe
eval { require FindBin; 1 } # new in 5.004
or plan skip_all => "FindBin not available -- $@";
eval { require File::Spec; 1 } # new in 5.005
or plan skip_all => "File::Spec not available -- $@";
diag "FindBin $FindBin::Bin";
$meta_filename = File::Spec->catfile
($FindBin::Bin, File::Spec->updir, 'META.yml');
-e $meta_filename
or plan skip_all => "$meta_filename doesn't exist -- assume this is a working directory not a dist";
plan tests => 5;
SKIP: {
eval { require YAML; 1 }
or skip "due to YAML module not available -- $@", 1;
my $ok = eval { YAML::LoadFile ($meta_filename); 1 }
or diag "YAML::LoadFile() error -- $@";
ok ($ok, "Read $meta_filename with YAML module");
}
# YAML 0.68 is in fact YAML::Old, or something weird -- don't think they can
# load together
#
# SKIP: {
# eval { require YAML::Old; 1 }
# or skip 'due to YAML::Old not available -- $@', 1;
#
# eval { YAML::Old::LoadFile ($meta_filename) };
# is ($@, '',
# "Read $meta_filename with YAML::Old");
# }
SKIP: {
eval { require YAML::Syck; 1 }
or skip "due to YAML::Syck not available -- $@", 1;
my $ok = eval { YAML::Syck::LoadFile ($meta_filename); 1 }
or diag "YAML::Syck::LoadFile() error -- $@";
ok ($ok, "Read $meta_filename with YAML::Syck");
}
SKIP: {
eval { require YAML::Tiny; 1 }
or skip "due to YAML::Tiny not available -- $@", 1;
my $ok = eval { YAML::Tiny->read ($meta_filename); 1 }
or diag "YAML::Tiny->read() error -- $@";
ok ($ok, "Read $meta_filename with YAML::Tiny");
}
SKIP: {
eval { require YAML::XS; 1 }
or skip "due to YAML::XS not available -- $@", 1;
my $ok = eval { YAML::XS::LoadFile ($meta_filename); 1 }
or diag "YAML::XS::LoadFile() error -- $@";
ok ($ok, "Read $meta_filename with YAML::XS");
}
# Parse::CPAN::Meta describes itself for use on "typical" META.yml, so not
# sure if demanding it works will more exercise its subset of yaml than the
# correctness of our META.yml. At any rate might like to know if it fails,
# so as to avoid tricky yaml for everyone's benefit, maybe.
#
SKIP: {
eval { require Parse::CPAN::Meta; 1 }
or skip "due to Parse::CPAN::Meta not available -- $@", 1;
my $ok = eval { Parse::CPAN::Meta::LoadFile ($meta_filename); 1 }
or diag "Parse::CPAN::Meta::LoadFile() error -- $@";
ok ($ok, "Read $meta_filename with Parse::CPAN::Meta::LoadFile");
}
# Data::YAML::Reader 0.06 doesn't like header "--- #YAML:1.0" with the #
# part produced by other YAML writers, so skip for now
#
# SKIP: {
# eval { require Data::YAML::Reader; 1 }
# or skip 'due to Data::YAML::Reader not available -- $@', 1;
#
# my $reader = Data::YAML::Reader->new;
# open my $fh, '<', $meta_filename
# or die "Cannot open $meta_filename";
# my $str = do { local $/=undef; <$fh> };
# close $fh or die;
#
# # if ($str !~ /\.\.\.$/) {
# # $str .= "...";
# # }
# my @lines = split /\n/, $str;
# push @lines, "...";
# use Data::Dumper;
# print Dumper(\@lines);
#
# # { local $,="\n"; print @lines,"\n"; }
exit 0;
X11-Protocol-Other-28/xt/0-Test-Pod.t 0000755 0001750 0001750 00000001751 11655356337 014751 0 ustar gg gg #!/usr/bin/perl -w
# 0-Test-Pod.t -- run Test::Pod if available
# Copyright 2009, 2010, 2011 Kevin Ryde
# 0-Test-Pod.t is shared by several distributions.
#
# 0-Test-Pod.t is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# 0-Test-Pod.t is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
use 5.004;
use strict;
use Test::More;
# all_pod_files_ok() is new in Test::Pod 1.00
#
eval 'use Test::Pod 1.00; 1'
or plan skip_all => "due to Test::Pod 1.00 not available -- $@";
Test::Pod::all_pod_files_ok();
exit 0;
X11-Protocol-Other-28/Makefile.PL 0000755 0001750 0001750 00000004415 12057221155 014271 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2010, 2011, 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use 5.004;
use strict;
use ExtUtils::MakeMaker;
my %encode_modules =
(
# 1.00 for ksc5601-raw, probably
'Encode' => 1.00,
'Encode::HanExtra' => 0.06, # 0.06 for cns11643-*
);
WriteMakefile
(NAME => 'X11-Protocol-Other',
ABSTRACT => 'Miscellaneous helpers for X11::Protocol connections.',
VERSION_FROM => 'lib/X11/Protocol/Other.pm',
AUTHOR => 'Kevin Ryde ',
LICENSE => 'gpl',
SIGN => 1,
PREREQ_PM => {
'X11::Protocol' => 0,
'Test' => 0, # only for testing
},
MIN_PERL_VERSION => '5.004',
META_MERGE =>
{ resources =>
{ homepage => 'http://user42.tuxfamily.org/x11-protocol-other/index.html',
license => 'http://www.gnu.org/licenses/gpl.html',
},
no_index => { directory=>['devel','xt'] },
optional_features =>
{
maximum_interoperation =>
{ description => 'All the optional things which may be used.',
requires => { %encode_modules,
},
},
maximum_tests =>
{ description => 'Have "make test" do as much as possible.',
requires => {
'Module::Util' => 0, # checking for HanExtra
%encode_modules,
},
},
},
},
);
# MyMakeMakerExtras_Pod_Coverage => [ 'X11::Protocol::Other',
# 'X11::Protocol::GrabServer',
# 'X11::Protocol::WM',
# ],
X11-Protocol-Other-28/examples/ 0002755 0001750 0001750 00000000000 12237274211 014131 5 ustar gg gg X11-Protocol-Other-28/examples/xfixes-selection.pl 0000755 0001750 0001750 00000010552 11657142427 017773 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Usage: perl xfixes-selection.pl
#
# This is an example of using XFixesSelectSelectionInput() to listen for
# changes to selection ownership.
#
# With just the core protocol this sort of thing has to be done by polling
# GetSelectionOwner() periodically. If you're the selection owner you're
# notified of its loss with an event, but third parties like a cut-buffer
# display have to poll.
#
# The key part is merely $X->XFixesSelectSelectionInput() and the
# XFixesSelectionNotify events. The window creation and GetProperty()
# nonsense are only to retrieve the selection contents. If you're
# interested in selection changes then you probably want to fetch the
# selection contents at some point.
#
# The window supplied to XFixesSelectSelectionInput() doesn't have to be a
# client window. It seems to work to give $X->root. Is it's purpose in the
# protocol to let clients dispatch events to a widget? Or have multiple
# independent parts of a program listening or some such?
#
# The only selection data type supported here is "STRING". A real program
# might ask for "TEXT" to read either STRING or COMPOUND_TEXT. The ICCCM
# spec lists a lot of possible types, but how many are usefully generated by
# programs is another matter.
#
use strict;
use X11::Protocol;
use X11::AtomConstants;
# uncomment this to run the ### lines
#use Smart::Comments;
my $X = X11::Protocol->new;
if (! $X->init_extension('XFIXES')) {
print "XFIXES extension not available on the server\n";
exit 1;
}
my $receiver_window = $X->new_rsrc;
$X->CreateWindow ($receiver_window,
$X->root, # parent
'InputOutput', # class
0, # depth, from parent
'CopyFromParent', # visual
0,0, # x,y
1,1, # width,height
0, # border
event_mask => $X->pack_event_mask('PropertyChange'));
$X->XFixesSelectSelectionInput ($receiver_window, $X->atom('PRIMARY'), 0x07);
my %converts_in_progress;
$X->{'event_handler'} = sub {
my (%h) = @_;
### event_handler: \%h
if ($h{'name'} eq 'XFixesSelectionNotify') {
my $subtype = $h{'subtype'};
my $owner = $h{'owner'};
my $selection_atom = $h{'selection'}; # eg. "PRIMARY"
if ($owner ne 'None') { $owner = sprintf('0x%X',$owner); }
printf("%s %s, owner now %s\n",
$X->atom_name($selection_atom),
$subtype,
$owner);
# ask for selection value
if ($subtype eq 'SetSelectionOwner') {
$X->ConvertSelection ($selection_atom, # atom
$X->atom('STRING'), # type
$selection_atom, # destination
$receiver_window, # destination
$h{'time'});
$converts_in_progress{$selection_atom} = 1;
}
} elsif ($h{'name'} eq 'PropertyNotify'
&& $h{'state'} eq 'NewValue'
# only the selection property receives, not other property changes
&& $converts_in_progress{$h{'atom'}}) {
# selection value received
my ($value, $type, $format, $bytes_after)
= $X->GetProperty ($receiver_window,
$h{'atom'}, # property
'AnyPropertyType', # type
0, # offset
60/4, # length limit, in 4-byte chunks
1); # delete, now have received
### $value
print " value: \"",
$value,
($bytes_after ? " ..." : ""), # if longer than requested size
"\"\n";
}
};
for (;;) {
$X->handle_input;
}
exit 0;
X11-Protocol-Other-28/examples/dbe-info.pl 0000644 0001750 0001750 00000003564 11567443715 016173 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Usage: perl dbe-info.pl
#
# Print some info from the DOUBLE-BUFFER extension.
#
use 5.004;
use strict;
use X11::Protocol;
my $X = X11::Protocol->new;
if (! $X->init_extension('DOUBLE-BUFFER')) {
print "DOUBLE-BUFFER not available on the server\n";
exit 0;
}
my ($major, $minor) = $X->DbeGetVersion (1,0);
print "DOUBLE-BUFFER extension version $major.$minor\n";
# Check just the default screen, by giving the $X->{'root'} window
#
my $root_visual = $X->root_visual;
my ($info_aref) = $X->DbeGetVisualInfo ($X->root);
my %hash = @$info_aref;
print "Default screen root visual $root_visual ",
($hash{$root_visual} ? "has" : "doesn't have"),
" double buffering\n";
# Print info about all screens, by passing no drawables to DbeGetVisualInfo().
#
my @info_aref_list = $X->DbeGetVisualInfo;
foreach my $screen (0 .. $#info_aref_list) {
print "Screen number $screen\n";
my $info_aref = $info_aref_list[$screen];
for (my $i = 0; $i < @$info_aref; ) {
my $visual_id = $info_aref->[$i++];
my $dp_aref = $info_aref->[$i++];
my ($depth, $perflevel) = @$dp_aref;
print " visual $visual_id depth $depth performance $perflevel\n";
}
}
exit 0;
X11-Protocol-Other-28/examples/xinerama-info.pl 0000755 0001750 0001750 00000003633 11657142601 017233 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Usage: perl xinerama-info.pl
#
# Print some information from the XINERAMA extension, including the layout
# of monitors making up the screen.
#
use 5.004;
use strict;
use X11::Protocol;
my $X = X11::Protocol->new;
if (! $X->init_extension('XINERAMA')) {
print "No XINERAMA on the server\n";
exit 0;
}
my ($major, $minor) = $X->PanoramiXQueryVersion (99,99);
print "Xinerama extension version $major.$minor\n";
my $flag = $X->PanoramiXGetState ($X->root);
print "state $flag\n";
my $count = $X->PanoramiXGetScreenCount ($X->root);
print "$count physical monitors\n";
foreach my $i (0 .. $count-1) {
my ($width, $height) = $X->PanoramiXGetScreenSize ($X->root, $i);
print " monitor $i size ${width}x${height}\n";
}
if (($major <=> 1 || $minor <=> 1) >= 0) {
# Xinerama 1.1 available
my $active = $X->XineramaIsActive ();
print "is active $active\n";
my @rectangles = $X->XineramaQueryScreens ();
if (@rectangles) {
print "rectangular areas\n";
foreach my $i (0 .. $#rectangles) {
my ($x, $y, $width, $height) = @{$rectangles[$i]};
print " monitor $i rectangle at $x,$y size ${width}x${height}\n";
}
} else {
print "no rectangular areas\n";
}
}
exit 0;
X11-Protocol-Other-28/examples/xfixes-cursor-image.pl 0000755 0001750 0001750 00000015766 12174426601 020411 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011, 2012, 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Usage: perl xfixes-cursor-image.pl
#
# This is an example of getting the mouse pointer cursor image with XFIXES.
#
# $X->XFixesGetCursorImage() retrieves the cursor image. CursorNotify
# events report when the image changes. A change is normally due to moving
# into a window with a different "cursor" attribute, but may also be a
# pointer grab, or even an animated changing cursor from the RENDER
# extension. See cursor-font-anim.pl for some fun with an animated root
# window cursor.
#
# The only painful thing is that XFixesGetCursorImage() gives 8-bit RGBA, so
# it's necessary to allocate colours etc to display that in a window. In
# the code here the image is drawn to a pixmap, then that pixmap drawn to
# the window under Expose.
#
# $X->XFixesGetCursorImage() isn't done in the "event_handler" code because
# it's a round-trip request and waiting for the reply might read new events
# and call the event_handler recursively. If badly lagged and continually
# receiving CursorNotify then that could be a very deep recursion, or make a
# mess of the drawing code. So the event_handler just notes a fresh
# XFixesGetCursorImage() is required and that's done in the main loop after
# $X->handle_input().
#
# With only the core X protocol there's no good way to get the current
# cursor or its image. The cursor attribute on a window can't be read back
# with GetWindowAttributes(), and all the area copying things such as
# GetImage() ignore the cursor.
#
# Things Not Done:
#
# The display window is a fixed 63x63 and the image positioned so the
# hotspot is always at 31,31. This fits a cursor of up to 32x32. A real
# program might centre the hotspot in the current window size (listening to
# ConfigureNotify), and might make the pixmap only the size of the cursor
# then draw it at the right place.
#
# The ChangeGC() plus PolyPoint() for each pixel is a bit wasteful. Better
# would be to send all the pixels in one PutImage(), but building the
# server's required bit units, byte order and padding is a bit like hard
# work.
#
# The alpha channel in the cursor image is only used to draw or not draw
# each pixel. It could be combined with the grey window background without
# too much trouble. What's the right multiplication for alpha weighting?
# In core protocol the cursor pixels are always fully-opaque or
# fully-transparent, but XFIXES can make partial-transparent cursors.
#
use 5.004;
use strict;
use X11::Protocol;
use X11::AtomConstants;
use X11::Protocol::WM;
# uncomment this to run the ### lines
#use Smart::Comments;
my $X = X11::Protocol->new;
if (! $X->init_extension('XFIXES')) {
print "XFIXES extension not available on the server\n";
exit 1;
}
my $colormap = $X->default_colormap;
# rgb8_to_pixel() takes colour components 0 to 255 and returns a pixel value
# suitable for $window and $pixmap. Black and white pixel values from the
# $X screen info are pre-loaded, other colours have to be allocated.
#
my %allocated_pixels = ('0.0.0' => $X->black_pixel,
'255.255.255' => $X->white_pixel);
sub rgb8_to_pixel {
my ($red, $green, $blue) = @_;
my $key = "$red.$green.$blue";
my $pixel = $allocated_pixels{$key};
if (! defined $pixel) {
($pixel) = $X->AllocColor ($colormap,
$red * 0x101, $green * 0x101, $blue * 0x101);
$allocated_pixels{$key} = $pixel;
}
return $pixel;
}
# grey colour
my ($background_pixel) =$X->AllocColor ($colormap, 0x9000,0x9000,0x9000);
my $window = $X->new_rsrc;
$X->CreateWindow ($window,
$X->root, # parent
'InputOutput', # class
$X->root_depth, # depth
'CopyFromParent', # visual
0,0, # x,y
63,63, # w,h initial size
0, # border
background_pixel => $background_pixel,
event_mask => $X->pack_event_mask('Exposure'),
);
X11::Protocol::WM::set_wm_name ($X, $window, 'Current Cursor'); # title
X11::Protocol::WM::set_wm_icon_name ($X, $window, 'Cursor');
X11::Protocol::WM::set_wm_client_machine_from_syshostname ($X, $window);
X11::Protocol::WM::set_net_wm_pid ($X, $window);
my $pixmap = $X->new_rsrc;
$X->CreatePixmap ($pixmap,
$window,
$X->root_depth,
63,63); # width,height
my $gc = $X->new_rsrc;
$X->CreateGC ($gc, $pixmap,
# don't want NoExpose events when copying from $pixmap
graphics_exposures => 0);
my $want_get_image = 1;
my $current_cursor_serial = -1;
$X->{'event_handler'} = sub {
my (%h) = @_;
### event_handler: \%h
if ($h{'name'} eq 'XFixesCursorNotify') {
if ($h{'cursor_serial'} != $current_cursor_serial) {
$want_get_image = 1;
}
} elsif ($h{'name'} eq 'Expose') {
$X->CopyArea ($pixmap, $window, $gc,
0,0, # src x,y
63,63, # src w,h
0,0); # dst x,y
}
};
$X->XFixesSelectCursorInput ($window, 1);
$X->MapWindow($window);
for (;;) {
$X->handle_input;
if ($want_get_image) {
my ($root_x,$root_y, $width,$height, $xhot,$yhot, $serial, $cursor_pixels)
= $X->XFixesGetCursorImage;
$current_cursor_serial = $serial;
$X->ChangeGC ($gc, foreground => $background_pixel);
$X->PolyFillRectangle ($pixmap, $gc, [0,0, 63,63]);
my $pos = 0;
foreach my $y (0 .. $height-1) {
foreach my $x (0 .. $width-1) {
my $argb = unpack 'L', substr($cursor_pixels,$pos,4);
my $alpha = ($argb >> 24) & 0xFF;
my $red = ($argb >> 16) & 0xFF;
my $green = ($argb >> 8) & 0xFF;
my $blue = $argb & 0xFF;
$pos += 4;
if ($alpha >= 128) { # opaque, ie. not transparent
my $pixmap_pixel = rgb8_to_pixel($red, $green, $blue);
$X->ChangeGC ($gc, foreground => $pixmap_pixel);
$X->PolyPoint ($pixmap, $gc, 'Origin',
# hotspot at position x=31,y=31 in the display
$x + 31-$xhot,
$y + 31-$yhot);
}
}
}
$X->CopyArea ($pixmap, $window, $gc,
0,0, # src x,y
63,63, # src w,h
0,0); # dst x,y
# print "Cursor size ${width}x${height}\n";
}
}
exit 0;
X11-Protocol-Other-28/examples/damage-duplicate.pl 0000755 0001750 0001750 00000022011 12026535306 017652 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011, 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Usage: perl damage-duplicate.pl
# perl damage-duplicate.pl --id 0x120000f
#
# This is an example of duplicating the contents of a window in real-time by
# listening for changes to it with the DAMAGE extension.
#
# A new $window toplevel displays the contents of a $source window. The key
# feature of the damage extension is that it reports when $source changes.
# Without that a duplicating program like this would have to re-copy every 1
# second or something like that.
#
# The source window can be given as an XID with the "--id" command line
# option, otherwise an X11::Protocol::ChooseWindow is run so you can click
# on a window like xwininfo does.
#
# Details:
#
# In the event_handler() code care is taken not to do anything which reads a
# reply. This is because reading the reply may also read and process other
# events, which would call event_handler() recursively and possibly
# endlessly. Any event handler should bear that in mind. In this program
# the danger would be that if the $source window is changing rapidly and so
# causing a new DamageNotify event to come very soon after each
# DamageSubtract().
#
# The $gc used for copying has "graphics_expose" off, which means any parts
# not available in the source window are cleared to the destination
# background colour. This happens when the source is overlapped etc by
# other windows.
#
# In the core protocol there's no easy way to get content from $source when
# it's overlapped, since the server generally doesn't keep the contents or
# generate expose events for obscured parts of windows.
#
# If the "Composite" extension is available then it retains content of
# overlapped windows. CompositeRedirectWindow() in the setups is all that's
# needed to have full $source contents available for the CopyArea()s.
#
# For simplicity the entire source area is copied whenever it changes. In a
# more sophisticated program the "$parts_region" of changes from the damage
# object could be a clip mask for the CopyArea(). Changes outside the
# duplicated area would then still go back and forward as DamageNotify and
# CopyArea, but the server would see from the clip region no actual drawing
# required.
#
# If $window is bigger than the $source then the excess is cleared. Some
# care is taken to clear only the excess area, not the whole of $window,
# since the latter way would make it flash to black and then to the copied
# $source. On a fast screen you might not notice, but on a slow screen or
# if the server is bogged down then such flashing is very unattractive.
#
# Shortcomings:
#
# The created $window is always on the same screen as $source and uses the
# same depth, visual and colormap. Doing so means a simple CopyArea
# suffices to copy the contents across.
#
# If source and destination were different depth, visual or colormap then
# pixel colour conversions would be required. If the destination was on a
# different server or different screen then some data transfers with
# GetImage() and PutImage() would be needed as well as pixel conversions.
# (As usual X11::Protocol::Ext::MIT_SHM might do that through shared memory
# if the program is on the same machine as the server.)
#
# Duplicating the root window is specifically disallowed. The problem is
# that a draw to $window is a change to the root window contents, so
# generates another DamageNotify, which does another draw, etc, in an
# infinite loop. It might work if attention was paid to what parts of the
# root had changed. Changes to the part of the root which is unobscured
# parts of $window will be due to the duplicating drawing and so don't
# require any further drawing.
#
BEGIN { require 5 }
use strict;
use Getopt::Long;
use X11::AtomConstants;
use X11::CursorFont;
use X11::Protocol;
use X11::Protocol::WM;
# uncomment this to run the ### lines
#use Smart::Comments;
my $X = X11::Protocol->new (':0');
if (! $X->init_extension('DAMAGE')) {
print "DAMAGE extension not available on the server\n";
exit 1;
}
#------------------------------------------------------------------------------
# command line
my $source; # source window to duplicate
my $verbose = 1;
GetOptions ('id=s' => \$source,
'verbose+' => \$verbose)
or exit 1;
#------------------------------------------------------------------------------
# source window, from command line or chosen
my $popup_time;
if (defined $source) {
# command line --id=XID
$source = oct($source); # oct() for hex 0xA0000F style as well as decimal
} else {
require X11::Protocol::ChooseWindow;
print "Click on a window to duplicate ...\n";
$source = X11::Protocol::ChooseWindow->choose (X => $X);
print " got it\n";
}
if ($verbose) {
printf "Source window %d (0x%X)\n", $source, $source;
}
if ($source == $X->root) {
print "Cannot duplicate root window\n";
exit 1;
}
#------------------------------------------------------------------------------
# use the Composite extension, if available, to keep the contents of $source
# if it's overlapped by other windows.
if ($X->init_extension('Composite')) {
$X->CompositeRedirectWindow ($source, 'Automatic');
}
#------------------------------------------------------------------------------
my %source_geom = $X->GetGeometry($source);
my %source_attr = $X->GetWindowAttributes($source);
# create new output window to show a duplicate of $source
# same depth, visual, colormap
my $window = $X->new_rsrc;
$X->CreateWindow ($window,
$X->root, # parent
'InputOutput', # class
$source_geom{'depth'},
$source_attr{'visual'},
0,0, # x,y
100,100, # w,h initial size
0, # border
colormap => $source_attr{'colormap'},
background_pixel => $X->black_pixel,
event_mask => $X->pack_event_mask('Exposure'),
);
X11::Protocol::WM::set_wm_class ($X, $window,
'damage-duplicate', 'DamageDuplicate');
X11::Protocol::WM::set_wm_name ($X, $window, 'Duplicate Window'); # title
X11::Protocol::WM::set_wm_icon_name ($X, $window, 'Duplicate');
X11::Protocol::WM::set_wm_client_machine_from_syshostname ($X, $window);
X11::Protocol::WM::set_net_wm_pid ($X, $window);
X11::Protocol::WM::set_net_wm_user_time($X, $window, $popup_time);
$X->MapWindow ($window);
# select ConfigureNotify from $source, to know when it resizes
$X->ChangeWindowAttributes
($source,
event_mask => $X->pack_event_mask('StructureNotify'));
# the damage object to monitor $source
# creating this gives DamageNotify events
my $damage = $X->new_rsrc;
$X->DamageCreate ($damage, $source, 'NonEmpty');
my $gc = $X->new_rsrc;
$X->CreateGC ($gc, $window,
subwindow_mode => 'IncludeInferiors',
# no "graphics exposures", don't want GraphicsExpose events if
# a part of the $X->CopyArea is obscured
graphics_exposures => 0);
sub event_handler {
my (%h) = @_;
my $name = $h{'name'};
### event_handler()
### $name
if ($name eq 'ConfigureNotify') {
# $source has resized
### height: $h{'height'}
my $width = $h{'width'}; # of $source
my $height = $h{'height'};
# clear any excess if $source has shrunk
$X->ClearArea ($window, $width,0, 0,0); # to left of $width
$X->ClearArea ($window, 0,$height, 0,0); # below $height
# copy any extra if $source has expanded
$X->CopyArea ($source, $window, $gc,
0,0, # src x,y
$h{'width'},$h{'height'}, # src w,h
0,0); # dst x,y
} elsif ($name eq 'DamageNotify') {
# $source has been drawn into
my $rect = $h{'geometry'};
my ($root_x, $root_y, $width, $height) = @$rect;
### $rect
$X->DamageSubtract ($damage, 'None', 'None');
$X->CopyArea ($source, $window, $gc,
0,0, # src x,y
$width,$height,
0,0); # dst x,y
} elsif ($name eq 'Expose') {
# our $window revealed, draw it
$X->CopyArea ($source, $window, $gc,
$h{'x'},$h{'y'}, # src x,y
$h{'width'},$h{'height'}, # src w,h
$h{'x'},$h{'y'}); # dst x,y
}
}
$X->{'event_handler'} = \&event_handler;
for (;;) {
$X->handle_input;
}
exit 0;
X11-Protocol-Other-28/examples/mit-screen-saver-external.pl 0000644 0001750 0001750 00000022646 12025563627 021511 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Usage: perl mit-screen-saver-external.pl
#
# This is an example of an external screen saver using the MIT-SCREEN-SAVER
# extension (X11::Protocol::Ext::MIT_SCREEN_SAVER).
#
# MitScreenSaverSetAttributes() sets up the program to be an external saver
# and defines the saver window attributes for when the saver turns on.
# MitScreenSaverSelectInput() sets up to listen for when the saver does in
# fact turn on. Then redraw() is a moving blob in the saver window while
# active.
#
#
# Drawing:
#
# redraw() is done on a timer at $frame_rate many times per second. An
# IO::Select is used to wait for either an event from the server or the
# desired time. When the saver is off there's no timeout, just wait for
# events.
#
# The timeout ought to be the time from now until the next draw is due, and
# in theory the time ought to be only until the blob moves by a whole pixel.
# But it's much easier to consider a draw every select(). This is normally
# fine since there shouldn't be many events from the server and so most
# selects end for time not for input.
#
# The main loop also listens to STDIN for "f" from the user to force the
# screen saver on, so you don't have to wait to see the demo. In a real
# program you'd probably ignore STDIN since the program would usually run in
# the background with stdin either closed at startup or ignored.
#
# An error handler guards against the saver turning off during drawing.
# When the saver turns off the saver window cannot be used and drawing to it
# results in Drawable or Window errors.
#
# An error handler is necessary. Errors from drawing can't be avoided by
# checking the saver state. Even if the saver is On when the drawing
# requests are sent out it might be off by the time those requests reach the
# server.
#
# The drawing isn't very sophisticated, but does try to reduce flashing by
# clearing only the newly revealed background part of the window when moving
# the blob. A fancier program could draw a new frame to a pixmap and then
# copy that to the screen, or similar with the DOUBLE-BUFFER extension if
# available (X11::Protocol::Ext::DOUBLE_BUFFER).
#
# Incidentally the saver window doesn't have to be the full screen. It can
# be something in the middle of the screen, leaving some normal screen
# content around the edges (which will update as normal if any clients are
# drawing, such as a clock).
#
#
# Another Screen Saver Running:
#
# The error handler notices an Access error from
# MitScreenSaverSetAttributes() which occurs if there's another external
# saver program running already. MitScreenSaverSetAttributes() doesn't have
# a reply when successful, so only the error packet says it didn't work.
# A round-trip QueryPointer ensures any error is detected before going into
# the main loop.
#
# Xlib XScreenSaverSaverRegister() has a scheme where a running saver
# program identifies itself by an XID stored in an "_MIT_SCREEN_SAVER_ID"
# property on the root window. That allows an existing saver to be forcibly
# killed ($X->KillClient()) if desired, though whether that's a good idea
# when starting a new saver is another matter. There's nothing in
# X11::Protocol::Ext::MIT_SCREEN_SAVER for that as yet. Some care might be
# needed when owning that property not to leave behind a bogus XID if killed
# (because that XID could be assigned to another client). Perhaps
# SetCloseDownMode() to preserve an identifying pixmap.
#
#
# Other Ways to Do It:
#
# For reference, the xscreensaver program has other ways to do a saver, as
# described in the comments at the start of its xscreensaver.c. In addition
# to MIT-SCREEN-SAVER it can detect idleness with the old (and perhaps no
# longer available) XIdle extension, or with the SCREEN_SAVER on SGI Irix,
# and can even try some slightly nasty keypress events and polling the mouse
# pointer position. And then it normally prefers to blank with an
# override-redirect window covering the screen.
#
# Apparently xscreensaver struck server bugs in the MIT-SCREEN-SAVER
# extension and for that reason recommends XIdle or SGI SCREEN_SAVER in its
# config.h.in. Recent X.org servers don't seem to crash, and the note in
# config.h.in about trouble "fading" with MIT-SCREEN-SAVER might be due to
# setting a background_pixel colour in the way done in the code here. If
# you omit that then like other windows the saver window leaves existing
# screen content unchanged when it's mapped. (And from there could be
# manipulated with colormap trickery, or perhaps RENDER extension merging,
# or even some GetImage/PutImage.)
#
use strict;
use IO::Select;
use X11::Protocol;
use List::Util 'min';
use Time::HiRes 'usleep';
use POSIX 'fmod';
my $frame_rate = 20;
my $seconds_per_trip = 60;
my $X = X11::Protocol->new;
if (! $X->init_extension('MIT-SCREEN-SAVER')) {
print STDERR "MIT-SCREEN-SAVER extension not available\n";
exit 1;
}
my $orig_error_handler = $X->{'error_handler'};
local $X->{'error_handler'} = sub {
my ($X, $data) = @_;
my ($type, $seq, $info, $minor_op, $major_op) = unpack 'xCSLSC', $data;
$type = $X->interp('Error',$type);
$major_op = $X->interp('Request',$major_op);
if ($type eq 'Access') {
# could check $major_op is the saver extension opcode and $minor_op is
# MitScreenSaverSetAttributes
#
print STDERR "Another screen saver is running\n";
exit 1;
} elsif (($type eq 'Window' || $type eq 'Drawable')
&& ($major_op eq 'ClearArea' || $major_op eq 'PolyFillRectangle')) {
# screen saver turned off during drawing, ignore errors from the drawing
# requests
} else {
goto $orig_error_handler;
}
};
# listen for MitScreenSaverNotify
$X->MitScreenSaverSelectInput ($X->root, 0x01);
# screen saver window same depth as root
#
$X->MitScreenSaverSetAttributes
($X->root,
'InputOutput', # class
0, # depth, from parent
'CopyFromParent', # visual
0,0, # x,y
$X->width_in_pixels,
$X->height_in_pixels,
0, # border
background_pixel => $X->black_pixel,
);
# round-trip query so as to get any Access error from
# MitScreenSaverSetAttributes() before printing the startup message below
#
$X->QueryPointer ($X->root);
my $gc = $X->new_rsrc;
$X->CreateGC ($gc, $X->root, foreground => $X->white_pixel);
my %saver_notify = (state => 'Off');
sub saver_is_active {
return $saver_notify{'state'} eq 'On'
&& $saver_notify{'kind'} eq 'External';
}
$X->{'event_handler'} = sub {
my (%h) = @_;
if ($h{'name'} eq 'MitScreenSaverNotify') {
%saver_notify = %h;
}
};
# width and height of a single pixel
my $pixel_width_mm = $X->width_in_millimeters / $X->width_in_pixels;
my $pixel_height_mm = $X->height_in_millimeters / $X->height_in_pixels;
my $blob_width = int ($X->width_in_pixels / 20);
my $blob_height = int ($blob_width * ($pixel_height_mm / $pixel_width_mm));
my $blob_x_limit = $X->width_in_pixels - $blob_width;
# middle of the screen vertically
my $blob_y = int (($X->height_in_pixels - $blob_height) / 2);
# Return $x of current desired blob position. Time $seconds_per_trip
# corresponds to across and back, which is 2*$blob_x_limit pixels.
sub blob_x {
my $t = Time::HiRes::time();
my $x = int (2 * $blob_x_limit * fmod($t / $seconds_per_trip, 1));
if ($x >= $blob_x_limit) {
$x = 2*$blob_x_limit-1 - $x;
}
return $x;
}
my $last_blob_x = 0; # last drawn position
sub redraw {
return unless saver_is_active();
my $window = $saver_notify{'window'};
my $blob_x = blob_x();
my ($clear_x, $clear_width);
if ($blob_x > $last_blob_x) {
$clear_x = $last_blob_x;
$clear_width = min ($blob_width, $blob_x - $last_blob_x);
} else {
$clear_width = min ($blob_width, $last_blob_x - $blob_x);
$clear_x = $last_blob_x + $blob_width - $clear_width;
}
if ($clear_width) {
$X->ClearArea ($window, $clear_x,$blob_y, $clear_width,$blob_height);
}
$X->PolyFillRectangle ($window, $gc,
[$blob_x, $blob_y, $blob_width-1, $blob_height-1]);
$last_blob_x = $blob_x;
}
sub handle_stdin {
my $line = ;
if (! defined $line || $line =~ /^q(uit)?/i) {
exit 0;
}
if ($line =~ /^f(orce)?/i) {
print "Force screen saver on ...\n";
# Sleep to wait for the key release from the user pressing Return.
# Could a fancier program check for all keys released ?
sleep 1;
$X->ForceScreenSaver ('Activate');
}
}
my $X_fh = $X->{'connection'}->fh;
my $select = IO::Select->new ($X_fh, \*STDIN);
print "Waiting for idle, type \"f Return\" to force it.\n";
print "Type \"q Return\" to exit.\n";
for (;;) {
$X->flush;
my $timeout = (saver_is_active() ? 1/$frame_rate : 0);
foreach my $readable ($select->can_read($timeout)) {
if ($readable == $X_fh) {
$X->handle_input;
} elsif ($readable == \*STDIN) {
handle_stdin();
}
}
redraw();
}
exit 0;
X11-Protocol-Other-28/examples/xresource-print.pl 0000755 0001750 0001750 00000005255 11657143015 017651 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Usage: perl xresource-print.pl
#
# This is an example printing the resource counts and pixmap bytes used for
# all clients.
#
# The only subtle part is $X->robust_req() which is used in case a client
# disconnects in between the XResourceQueryClients() list and then querying
# each for their usage. It's only a short time between, but error checking
# is a good idea when dealing with things belonging to other clients.
#
# An eval{} around a plain $X->XResourceQueryClientResources() is another
# way to do it. Such an eval might also catch error replies queued up from
# earlier asynchronous requests. There's none in this case, but it's the
# nature of the protocol to only get back errors later on.
#
# For reference, in X11::Protocol 0.56 an $X->{'error_handler'} isn't very
# good for continuing processing things with replies. If the handler merely
# prints a message and returns then something fishy happens, giving an empty
# reply to the unpacking which then often throws an error (unpack of no data
# is an error).
#
use 5.004;
use strict;
use X11::Protocol;
my $X = X11::Protocol->new;
if (! $X->init_extension('X-Resource')) {
print "X-Resource extension not available on the server\n";
exit 0;
}
my @clients = $X->XResourceQueryClients;
foreach my $client (@clients) {
my ($xid_base, $xid_mask) = @$client;
printf "client 0x%X is using\n", $xid_base;
my $ret = $X->robust_req('XResourceQueryClientResources', $xid_base);
if (ref $ret) {
my @resources = @$ret;
while (@resources) {
my $atom = shift @resources;
my $count = shift @resources;
my $atom_name = $X->atom_name($atom);
printf "%6d %s\n", $count, $atom_name;
}
} else {
print " error getting client resources\n";
}
$ret = $X->robust_req ('XResourceQueryClientPixmapBytes', $xid_base);
if (ref $ret) {
my ($bytes) = @$ret;
printf "%6s PixmapBytes\n", $bytes;
} else {
print " error getting pixmap bytes\n";
}
print "\n";
}
exit 0;
X11-Protocol-Other-28/examples/cursor-font-anim.pl 0000644 0001750 0001750 00000004231 11657140276 017677 0 ustar gg gg #!/usr/bin/perl
# Copyright 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Usage: perl cursor-font-anim.pl
#
# This is a bit of nonsense using the RENDER extension to make an annoying
# animated cursor for the root window, cycling through each of the standard
# cursor font shapes.
#
# The size of the X11::CursorFont module @CURSOR_NAME array is used for how
# many cursors are available in the cursor font.
#
# When you get sick of this put it back to something sensible with for
# instance
#
# xsetroot -cursor_name left_ptr
#
use strict;
use X11::Protocol;
use X11::CursorFont '@CURSOR_NAME';
my $X = X11::Protocol->new;
if (! $X->init_extension('RENDER')) {
print "RENDER extension not available on the server\n";
exit 1;
}
my $cursor_font = $X->new_rsrc;
$X->OpenFont ($cursor_font, "cursor");
my @cursors;
for (my $i = 0; $i < @CURSOR_NAME; $i+=2) {
my $cursor = $X->new_rsrc;
$X->CreateGlyphCursor ($cursor,
$cursor_font, # font
$cursor_font, # mask font
$i, # glyph number
$i+1, # and its mask
0,0,0, # foreground, black
0xFFFF, 0xFFFF, 0xFFFF); # background, white
push @cursors, $cursor;
}
print "total ",scalar(@cursors)," cursors animated";
my $milliseconds = 500;
my $cursor = $X->new_rsrc;
$X->RenderCreateAnimCursor ($cursor, map { [$_,$milliseconds] } @cursors);
$X->ChangeWindowAttributes ($X->root, cursor => $cursor);
exit 0;
X11-Protocol-Other-28/examples/dbe-swap.pl 0000755 0001750 0001750 00000006212 11567443741 016205 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Usage: perl dbe-swap.pl
#
# This is a simple example of double buffer swapping for drawing. In the
# loop below drawing is done to the back buffer then swapped to the front to
# display.
#
# The drawing shows alternatively a circle and square. The new figure is
# drawn to the back buffer and then swapped to the front so it changes
# immediately, without a separate clear and draw which the user might see as
# a flash or flicker. Of course a circle or square will draw fast enough
# that double buffering is hardly needed, but for more complex contents can
# benefit.
#
# When a window gets an "expose", as happens here on the initial MapWindow,
# the back buffer is cleared to the window background the same as the window
# itself. So if the buffer is allocated before the first expose then
# there's no need to explicitly erase the back buffer.
#
# In a realistic program of course you'd listen and read events from the
# server in between drawing, and might work in at least one server
# round-trip between drawing so as to wait if the server is under a heavy
# load etc. (Or wait if no synchronizing reply is received for a certain
# time or number of frames, etc.)
#
use strict;
use X11::Protocol;
my $X = X11::Protocol->new;
if (! $X->init_extension('DOUBLE-BUFFER')) {
print "DOUBLE-BUFFER not available on the server\n";
exit 1;
}
my $visual = $X->root_visual;
my ($info_aref) = $X->DbeGetVisualInfo ($X->root);
my %hash = @$info_aref;
if (! $hash{$visual}) {
print "DOUBLE-BUFFER not available for root visual\n";
exit 1;
}
my $window = $X->new_rsrc;
$X->CreateWindow ($window,
$X->root, # parent
'InputOutput', # class
0, # depth, from parent
'CopyFromParent', # visual
0,0, # x,y
50,50, # width,height
0, # border
background_pixel => $X->black_pixel);
my $gc = $X->new_rsrc;
$X->CreateGC ($gc, $window, foreground => $X->white_pixel);
my $buffer = $X->new_rsrc;
$X->DbeAllocateBackBufferName ($window, $buffer, 'Background');
$X->MapWindow ($window);
sleep 1;
for (;;) {
$X->PolyRectangle ($buffer, $gc, [ 10,10, 29,29 ]);
$X->DbeSwapBuffers ($window, 'Background');
$X->flush;
sleep 1;
$X->PolyArc ($buffer, $gc, [7,7, 35,35, 0, 360*64]);
$X->DbeSwapBuffers ($window, 'Background');
$X->flush;
sleep 1;
}
exit 0;
X11-Protocol-Other-28/examples/xresource-pairwise.pl 0000755 0001750 0001750 00000004200 11556522246 020332 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
# Usage: perl xresource-pairwise.pl
#
# This is an example using mapp() from List::Pairwise to step through the
# XResourceQueryClientResources() return list, in this case for the
# resources of the current client -- creating a few so something shows up
# (or ought to).
#
use strict;
use X11::Protocol;
use List::Pairwise 'mapp';
my $X = X11::Protocol->new;
if (! $X->init_extension('X-Resource')) {
print "X-Resource extension not available on the server\n";
exit 0;
}
my $window = $X->new_rsrc;
$X->CreateWindow ($window,
$X->root, # parent
'InputOutput',
0, # depth, from parent
'CopyFromParent', # visual
0,0, # x,y
100,100, # width,height
0); # border
my $pixmap = $X->new_rsrc;
$X->CreatePixmap ($pixmap,
$X->root,
$X->root_depth,
100,100); # width,height
$X->GrabKey ($X->max_keycode - 2, # random keycode
0, # modifiers
$X->root,
0, # owner events
'Asynchronous', 'Asynchronous');
mapp {
# $a is atom, $b is count
print $X->atom_name($a), " $b\n";
} $X->XResourceQueryClientResources($X->resource_id_base);
print "PixmapBytes ",
$X->XResourceQueryClientPixmapBytes($X->resource_id_base),"\n";
exit 0;
X11-Protocol-Other-28/inc/ 0002755 0001750 0001750 00000000000 12237274211 013064 5 ustar gg gg X11-Protocol-Other-28/inc/my_pod2html 0000755 0001750 0001750 00000007507 12175610062 015256 0 ustar gg gg #!/usr/bin/perl
# my_pod2html -- convert POD to HTML, with some mangling
# Copyright 2009, 2010, 2011, 2013 Kevin Ryde
# my_pod2html is shared by several distributions.
#
# my_pod2html is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# my_pod2html is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this file. If not, see .
use strict;
use warnings;
#use Smart::Comments;
my $pod2html = MyPod2HTML->new;
#
and
both too big, in mozilla at least
$pod2html->html_h_level(3);
$pod2html->parse_from_file(@ARGV);
exit 0;
package MyPod2HTML;
use base 'Pod::Simple::HTML';
our $VERSION = 1;
use constant DEBUG => 0;
my %table =
('apt-file' => 'http://packages.debian.org/apt-file',
'apt-cache' => 'http://packages.debian.org/apt',
'apt-rdepends' => 'http://packages.debian.org/apt-rdepends',
'gtk-options' => 'http://manpages.ubuntu.com/manpages/jaunty/man7/gtk-options.7.html',
'xsetroot' => 'http://www.x.org/archive/X1'.'1R7.5/doc/man/man1/xsetroot.1.html',
'leafnode' => 'http://leafnode.sourceforge.net',
'lynx' => 'http://lynx.isc.org/',
'feed2imap' => 'http://home.gna.org/feed2imap',
# disguise from grep
'rss'.'2email' => 'http://rss'.'2email.infogami.com',
'rssdrop' => 'http://search.cpan.org/dist/rssdrop/',
'toursst' => 'http://packages.debian.org/etch/toursst',
'netrc' => 'http://linux.die.net/man/5/netrc',
# no online man pages apparently at http://man-db.nongnu.org/
'man' => 'http://ftp.parisc-linux.org/cgi-bin/man/man2html?man+1',
'lexgrog' => 'http://ftp.parisc-linux.org/cgi-bin/man/man2html?lexgrog+1',
'apropos' => 'http://ftp.parisc-linux.org/cgi-bin/man/man2html?apropos+1',
);
sub resolve_man_page_link {
my ($self, $to, $frag) = @_;
$to = "$to"; # Pod::Simple::LinkSection object
### $to
if (my ($page, $section) = ($to =~ /(.*)\(\d+\)$/)) {
### $page
if (my $url = $table{$page}) {
return $url;
}
}
return shift->SUPER::resolve_man_page_link (@_);
}
sub resolve_pod_link_by_table {
my ($self, $to, $section) = @_;
my $url;
if (defined $to) {
if ($to eq 'AptPkg') {
$url = 'http://packages.debian.org/libapt-pkg-perl';
}
if ($to =~ /^Glib::Ex::(SourceIds|SignalIds|FreezeNotify|TieProperties)/) {
$url = "http://user42.tuxfamily.org/glib-ex-ob"."jectbits/$1.html";
}
if ($to eq 'Gtk2::Ex::Widget'.'Cursor') {
$url = 'http://user42.tuxfamily.org/gtk2-ex-widget'.'cursor/Widget'.'Cursor.html';
}
if ($to eq 'Ti'.'e:'.':TZ') {
$url = 'http://user42.tuxfamily.org/ti'.'e-'.'tz/TZ.html';
}
if ($to eq 'Time:'.':TZ') {
$url = 'http://user42.tuxfamily.org/ti'.'e-'.'tz/Time-'.'TZ.html';
}
if ($to =~ /^(Glib|Gtk2)($|::(?!Ex::))/) {
$to =~ s{::}{/};
$url = "http://gtk2-perl.sourceforge.net/doc/pod/$to.html"
}
if (defined $url) {
return ($url . (defined $section && $section ne '' ? "#$section" : ''));
}
}
return $self->SUPER::resolve_pod_link_by_table($to, $section);
}
# sub do_pod_link {
# my($self, $link) = @_;
# if (DEBUG) {
# print "\nlink tag=",$link->tagname," type=",$link->attr('type'),"\n";
# print " to=",$link->attr('to')||'[none]',"\n";
# print " section=",$link->attr('section')||'[none]',"\n";
# }
#
# my $to = $link->attr('to') || ''; # undef if internal link
#
# return $self->SUPER::do_pod_link($link);
# }
X11-Protocol-Other-28/devel/ 0002755 0001750 0001750 00000000000 12237274211 013412 5 ustar gg gg X11-Protocol-Other-28/devel/xinerama.pl 0000644 0001750 0001750 00000004155 11555412567 015570 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use strict;
use X11::Protocol;
use lib 'devel', '.';
# uncomment this to run the ### lines
use Smart::Comments;
$ENV{DISPLAY} = ":102";
{
my $X = X11::Protocol->new ($ENV{DISPLAY} || ':0');
### root: $X->{'root'}
{ my @query = $X->QueryExtension('XINERAMA');
### @query
}
$X->QueryPointer($X->{'root'}); # sync
$X->init_extension('XINERAMA') or die $@;
$X->QueryPointer($X->{'root'}); # sync
{ my @version = $X->PanoramiXQueryVersion (99,99);
### PanoramiXQueryVersion: @version
}
$X->QueryPointer($X->{'root'}); # sync
my @state = $X->PanoramiXGetState ($X->{'root'});
### PanoramiXGetState: @state
$X->QueryPointer($X->{'root'}); # sync
my @count = $X->PanoramiXGetScreenCount ($X->{'root'});
### PanoramiXGetScreenCount: @count
$X->QueryPointer($X->{'root'}); # sync
my ($count) = @count;
{
my @size = $X->PanoramiXGetScreenSize ($X->{'root'}, 999999);
### PanoramiXGetScreenSize: @size
}
foreach my $monitor (0 .. $count+5) {
### $monitor
my @size = $X->PanoramiXGetScreenSize ($X->{'root'}, $monitor);
### PanoramiXGetScreenSize: @size
$X->QueryPointer($X->{'root'}); # sync
}
my @active = $X->XineramaIsActive ();
### XineramaIsActive: @active
$X->QueryPointer($X->{'root'}); # sync
my @query = $X->XineramaQueryScreens ($X->{'root'});
### XineramaQueryScreens: @query
$X->QueryPointer($X->{'root'}); # sync
exit 0;
}
X11-Protocol-Other-28/devel/xf86vidmode.pl 0000644 0001750 0001750 00000003036 11711330002 016075 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use 5.004;
use strict;
use X11::Protocol;
# uncomment this to run the ### lines
use Smart::Comments;
use lib 'devel/lib';
$ENV{'DISPLAY'} ||= ':0';
{
my $X = X11::Protocol->new;
$X->init_extension('XFree86-VidModeExtension') or die $@;
$X->QueryPointer($X->{'root'}); # sync
### init_extension() ok ...
{
my @version = $X->XF86VidModeQueryVersion;
### @version
}
{
my @modeline = $X->XF86VidModeGetModeLine(0);
### @modeline
}
{
my @monitor = $X->XF86VidModeGetMonitor(0);
### @monitor
# my ($vendor, $model, $hsyncs, $vsyncs, $bandwidth) = @monitor;
exit 0;
}
{
my @modeline = $X->XF86VidModeGetAllModeLines(0);
### @modeline
}
$X->XF86VidModeSetClientVersion(2,2);
{
my @modeline = $X->XF86VidModeGetAllModeLines(0);
### @modeline
}
exit 0;
}
X11-Protocol-Other-28/devel/exe-xi-info.c 0000644 0001750 0001750 00000004760 11706711724 015720 0 ustar gg gg /* Copyright 2012 Kevin Ryde
This file is part of X11-Protocol-Other.
X11-Protocol-Other is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your option) any
later version.
X11-Protocol-Other is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along
with X11-Protocol-Other. If not, see .
*/
#include
#include
#include
#include
int
main (void)
{
Display *display;
int ndevices, i, j, k;
XDeviceInfo *infos;
char *display_name = getenv("DISPLAY");
if (! display_name) {
display_name = ":0";
}
display = XOpenDisplay (display_name);
if (! display) {
printf ("no DISPLAY\n");
abort ();
}
infos = XListInputDevices (display, &ndevices);
if (! infos) {
printf ("XInputExtension not available\n");
abort ();
}
printf ("%p\n", infos);
for (i = 0; i < ndevices; i++) {
XDeviceInfo *info = infos + i;
printf ("id %ld type %lu use %d num_classes %d %s\n",
info->id,
info->type,
info->use,
info->num_classes,
info->name);
XAnyClassPtr classinfo = info->inputclassinfo;
for (j = 0; j < info->num_classes; j++) {
printf (" class %ld\n", classinfo->class);
if (classinfo->class == KeyClass) {
XKeyInfo *keyinfo = (XKeyInfo *) classinfo;
} else if (classinfo->class == ButtonClass) {
XButtonInfo *ptrinfo = (XButtonInfo *) classinfo;
} else if (classinfo->class == ValuatorClass) {
XValuatorInfo *valinfo = (XValuatorInfo *) classinfo;
printf (" num_axes %d mode %d motion_buffer %lu\n",
valinfo->num_axes,
valinfo->mode,
valinfo->motion_buffer);
XAxisInfoPtr axes = valinfo->axes;
for (k = 0; k < valinfo->num_axes; k++) {
printf (" resolution %d min %d max %d\n",
axes[k].resolution,
axes[k].min_value,
axes[k].max_value);
}
}
classinfo = (XAnyClassPtr) ((char *) classinfo + classinfo->length);
}
}
return 0;
}
X11-Protocol-Other-28/devel/exe-sync.c 0000644 0001750 0001750 00000004604 12214463427 015317 0 ustar gg gg /* Copyright 2013 Kevin Ryde
This file is part of X11-Protocol-Other.
X11-Protocol-Other is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your option)
any later version.
X11-Protocol-Other is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along
with X11-Protocol-Other. If not, see . */
#include
#include
#include
#include
#include
int
main (void)
{
{
Display *display = XOpenDisplay(NULL);
if (! display) { abort (); }
int major = 3;
int minor = 1;
XSyncInitialize(display, &major, &minor);
XSyncValue value;
XSyncIntToValue(&value, 0);
XSyncCounter counter = XSyncCreateCounter(display, value);
static XSyncWaitCondition wait_list[1];
XSyncIntToValue(&value, 123);
wait_list[0].trigger.counter = counter;
wait_list[0].trigger.value_type = XSyncAbsolute;
wait_list[0].trigger.wait_value = value;
wait_list[0].trigger.test_type = XSyncPositiveTransition;
printf ("XSyncAwait call\n");
XSyncAwait(display, wait_list, 1);
printf ("XSyncAwait return\n");
printf ("XSync call\n");
XSync(display, 0);
printf ("XSync return\n");
return 0;
}
{
Display *display = XOpenDisplay (NULL);
if (! display) { abort (); }
int major = 3;
int minor = 1;
XSyncInitialize(display, &major, &minor);
XSyncValue value;
XSyncIntToValue(&value, 0);
XSyncCounter counter = XSyncCreateCounter(display, value);
static XSyncWaitCondition wait_list[1];
XSyncIntToValue(&value, 123);
wait_list[0].trigger.counter = counter;
wait_list[0].trigger.value_type = XSyncAbsolute;
wait_list[0].trigger.wait_value = value;
wait_list[0].trigger.test_type = XSyncPositiveTransition;
printf ("XSyncAwait call\n");
XSyncAwait(display, wait_list, 1);
printf ("XSyncAwait return\n");
printf ("XSync call\n");
XSync(display, 0);
printf ("XSync return\n");
return 0;
}
}
X11-Protocol-Other-28/devel/wm-state-exercise.pl 0000644 0001750 0001750 00000015531 12233053754 017323 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use strict;
use FindBin;
use File::Spec;
my $script = File::Spec->catfile($FindBin::Bin,$FindBin::Script);
use X11::Protocol;
use X11::AtomConstants;
use X11::Protocol::WM;
if (@ARGV) {
open STDOUT, '>>', '/tmp/wm-state-exercise.out' or die;
open STDERR, '>>&', \*STDOUT;
$| = 1;
print "\n\n\n-------------------------------------------------------------\n";
my $wm = $ARGV[0];
my $pid = fork();
if ($pid) {
# parent
sleep 5;
} else {
exec $wm or die $!;
}
my $display = $ENV{"DISPLAY"};
my $window = $ENV{"WINDOWID"};
my $X = X11::Protocol->new($display);
my $root = $X->root;
print "\n$wm $display window=$window\n";
# system("xprop -root >>/tmp/wm-state-exercise.out");
my @supported_atoms;
my %supported_atoms;
{
my ($value, $type, $format, $bytes_after)
= $X->GetProperty ($root,
$X->atom('_NET_SUPPORTED'), # property
X11::AtomConstants::ATOM(), # type
0, # offset
999, # length limit
0); # delete
if ($format == 32) {
@supported_atoms = unpack('L*', $value);
foreach my $atom (@supported_atoms) {
$supported_atoms{$atom} = 1;
}
} else {
print "no _NET_SUPPORTED\n";
}
}
print "supported count ",scalar(@supported_atoms),"\n";
print "supported: ",join(', ',map{$X->atom_name($_)} @supported_atoms),"\n";
# _NET_WM_STATE_HIDDEN
foreach my $state (qw(
_NET_WM_STATE_BELOW
_NET_WM_STATE_ABOVE
_NET_WM_STATE_MODAL
_NET_WM_STATE_STICKY
_NET_WM_STATE_MAXIMIZED_VERT
_NET_WM_STATE_MAXIMIZED_HORZ
_NET_WM_STATE_SHADED
_NET_WM_STATE_SKIP_TASKBAR
_NET_WM_STATE_SKIP_PAGER
_NET_WM_STATE_FULLSCREEN
_NET_WM_STATE_DEMANDS_ATTENTION
)) {
print "$state\n";
my $state_atom = $X->atom($state);
if (! $supported_atoms{$state_atom}) {
print " not supported\n";
next;
}
change(1, $state_atom); # add
$X->flush;
sleep 1;
{
my @states = get_wm_states();
my $found = grep {$_==$state_atom} @states;
if ($found) {
print " add ok\n";
} else {
print " bad, add not set\n";
print " have: ",join(' ',map{$X->atom_name($_)}@states),"\n";
}
}
change(0, $state_atom); # remove
$X->flush;
sleep 1;
{
my @states = get_wm_states();
my $found = grep {$_==$state_atom} @states;
if ($found) {
print " bad, remove still set\n";
print " have: ",join(' ',map{$X->atom_name($_)}@states),"\n";
} else {
print " remove ok\n";
}
}
change(1, $state_atom); # toggle-on
$X->flush;
sleep 1;
{
my @states = get_wm_states();
my $found = grep {$_==$state_atom} @states;
if ($found) {
print " toggle-on ok\n";
} else {
print " bad, toggle-on not set\n";
print " have: ",join(' ',map{$X->atom_name($_)}@states),"\n";
}
}
change(2, $state_atom); # toggle-off
$X->flush;
sleep 1;
{
my @states = get_wm_states();
my $found = grep {$_==$state_atom} @states;
if ($found) {
print " bad, toggle-off still set\n";
print " have: ",join(' ',map{$X->atom_name($_)}@states),"\n";
} else {
print " toggle-off ok\n";
}
}
}
# kill $pid;
print "exit\n";
exit 0;
sub change {
my ($action, $atom) = @_;
X11::Protocol::WM::_send_event_to_wm ($X, $root,
name => 'ClientMessage',
window => $window,
type => $X->atom('_NET_WM_STATE'),
format => 32,
data => pack('L5',
$action,
$atom,
0, # state2
2)); # "user"
}
sub get_wm_states {
my @states;
my ($value, $type, $format, $bytes_after)
= $X->GetProperty ($window,
$X->atom('_NET_WM_STATE'), # property
X11::AtomConstants::ATOM(), # type
0, # offset
999, # length limit
0); # delete
if ($format == 32) {
@states = unpack('L*', $value);
}
return @states;
}
}
unlink '/tmp/wm-state-exercise.out';
foreach my $wm (qw(
/usr/bin/metacity
/usr/bin/jwm
/usr/bin/wmii
/usr/bin/fvwm2
/usr/bin/icewm
mwm
/usr/bin/olwm
/usr/bin/olvwm
/usr/bin/spectrwm
/usr/bin/windowlab
/usr/bin/amiwm
matchbox-window-manager
/usr/bin/awesome
evilwm
/usr/bin/openbox
tvtwm
/usr/bin/9wm
w9wm
/usr/bin/xfwm4
/usr/bin/sapphire
ctwm
/usr/bin/dwm
/usr/bin/startfluxbox
/usr/bin/flwm
/usr/bin/herbstluftwm
/usr/bin/i3
/usr/bin/larswm
/usr/bin/miwm
/usr/bin/oroborus
/usr/bin/wm2
/usr/bin/xmonad
/so/swm/sWM-1.3.6/bin/sWM
twm
vtwm
)) {
# my $command = "xvfb-run -a xterm -e 'echo $wm >>/tmp/xx'";
my $command = "xvfb-run -a xterm -e 'perl $script $wm'";
print "$command\n";
system ($command);
}
X11-Protocol-Other-28/devel/xf86dga.pl 0000644 0001750 0001750 00000006501 12046547556 015233 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use 5.006;
use strict;
use X11::Protocol;
# uncomment this to run the ### lines
use Smart::Comments;
use lib 'devel/lib';
$ENV{'DISPLAY'} ||= ':0';
{
# version 2.0
my $X = X11::Protocol->new;
$X->init_extension('XFree86-DGA') or die $@;
$X->QueryPointer($X->{'root'}); # sync
### init_extension() ok ...
# {
# my @modes = $X->XDGAQueryModes(0);
# ### @modes
# }
{
my @ret = $X->XDGAOpenFramebuffer(0);
### @ret
printf "%X\n", $ret[1];
}
$X->XDGASelectInput(0, $);
### @ret
printf "%X\n", $ret[1];
}
exit 0;
}
{
my $X = X11::Protocol->new;
$X->init_extension('XFree86-DGA') or die $@;
$X->QueryPointer($X->{'root'}); # sync
### init_extension() ok ...
my ($address, $width, $bank_size, $ram_size) = $X->XF86DGAGetVideoLL(0);
my $mmap;
require File::Map;
File::Map::map_file($mmap, '/dev/mem', '+<', $address, 1024**2);
{
my $enable_flags = $X->XF86DGADirectVideo(0, 0b01110);
### enable flags: sprintf '%b', $enable_flags
}
my $size = 1440*50*4;
substr($mmap,0,$size) = "\0"x$size;
substr($mmap,$size,$size) = "\xFF"x$size;
sleep 3;
{
my $disable_flags = $X->XF86DGADirectVideo(0, 0);
### disable flags: sprintf '%b', $disable_flags
}
exit 0;
}
{
my $X = X11::Protocol->new;
$X->init_extension('XFree86-DGA') or die $@;
$X->QueryPointer($X->{'root'}); # sync
### init_extension() ok ...
{
my @version = $X->XF86DGAQueryVersion;
### @version
}
{
# ($address, $width, $bank_size, $ram_size)
my @LL = $X->XF86DGAGetVideoLL(0);
### @LL
printf "%X %X %X %X\n", @LL;
}
{
my @wh = $X->XF86DGAGetViewPortSize(0);
### @wh
}
# {
# $X->XF86DGASetViewPort(0, 200,100, 0);
# my @wh = $X->XF86DGAGetViewPortSize(0);
# ### @wh
# }
{
my $vidpage = $X->XF86DGAGetVidPage(0);
### $vidpage
}
{
$X->XF86DGASetVidPage(0, 0);
$X->QueryPointer($X->{'root'}); # sync
my $vidpage = $X->XF86DGAGetVidPage(0);
### $vidpage
}
{
my $query_flags = $X->XF86DGAQueryDirectVideo(0);
### query flags: sprintf '%X', $query_flags
}
{
my $disable_flags = $X->XF86DGADirectVideo(0, 1);
### disable flags: sprintf '%b', $disable_flags
}
{
my $enable_flags = $X->XF86DGADirectVideo(0, 0b01110);
### enable flags: sprintf '%b', $enable_flags
}
{ my $changed_result = $X->XF86DGAViewPortChanged(0, 1);
### $changed_result
}
{ my $changed_result = $X->XF86DGAViewPortChanged(0, 1);
### $changed_result
}
{
my $disable_flags = $X->XF86DGADirectVideo(0, 0);
### disable flags: sprintf '%b', $disable_flags
}
exit 0;
}
X11-Protocol-Other-28/devel/maybe/ 0002755 0001750 0001750 00000000000 12237274211 014507 5 ustar gg gg X11-Protocol-Other-28/devel/maybe/CursorConstants.pm 0000644 0001750 0001750 00000022504 12214752645 020227 0 ustar gg gg # Copyright 2011, 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
BEGIN { require 5 }
package X11::CursorConstants;
use strict;
use vars '$VERSION';
$VERSION = 10;
# uncomment this to run the ### lines
#use Smart::Comments;
# Generated with:
# (shell-command "perl -n -e '/define XC_([^ ]*).*?([0-9]+)/ and do { printf qq{use constant %-20s => %d;\n}, $1, $2;}' 154;
use constant X_cursor => 0;
use constant arrow => 2;
use constant based_arrow_down => 4;
use constant based_arrow_up => 6;
use constant boat => 8;
use constant bogosity => 10;
use constant bottom_left_corner => 12;
use constant bottom_right_corner => 14;
use constant bottom_side => 16;
use constant bottom_tee => 18;
use constant box_spiral => 20;
use constant center_ptr => 22;
use constant circle => 24;
use constant clock => 26;
use constant coffee_mug => 28;
use constant cross => 30;
use constant cross_reverse => 32;
use constant crosshair => 34;
use constant diamond_cross => 36;
use constant dot => 38;
use constant dotbox => 40;
use constant double_arrow => 42;
use constant draft_large => 44;
use constant draft_small => 46;
use constant draped_box => 48;
use constant exchange => 50;
use constant fleur => 52;
use constant gobbler => 54;
use constant gumby => 56;
use constant hand1 => 58;
use constant hand2 => 60;
use constant heart => 62;
use constant icon => 64;
use constant iron_cross => 66;
use constant left_ptr => 68;
use constant left_side => 70;
use constant left_tee => 72;
use constant leftbutton => 74;
use constant ll_angle => 76;
use constant lr_angle => 78;
use constant man => 80;
use constant middlebutton => 82;
use constant mouse => 84;
use constant pencil => 86;
use constant pirate => 88;
use constant plus => 90;
use constant question_arrow => 92;
use constant right_ptr => 94;
use constant right_side => 96;
use constant right_tee => 98;
use constant rightbutton => 100;
use constant rtl_logo => 102;
use constant sailboat => 104;
use constant sb_down_arrow => 106;
use constant sb_h_double_arrow => 108;
use constant sb_left_arrow => 110;
use constant sb_right_arrow => 112;
use constant sb_up_arrow => 114;
use constant sb_v_double_arrow => 116;
use constant shuttle => 118;
use constant sizing => 120;
use constant spider => 122;
use constant spraycan => 124;
use constant star => 126;
use constant target => 128;
use constant tcross => 130;
use constant top_left_arrow => 132;
use constant top_left_corner => 134;
use constant top_right_corner => 136;
use constant top_side => 138;
use constant top_tee => 140;
use constant trek => 142;
use constant ul_angle => 144;
use constant umbrella => 146;
use constant ur_angle => 148;
use constant watch => 150;
use constant xterm => 152;
1;
__END__
=for stopwords Xlib glyph Ryde
=head1 NAME
X11::CursorConstants - cursor font glyph constants
=head1 SYNOPSIS
use X11::CursorConstants;
my $glyphnum = X11::CursorConstants::crosshair; # is 34
=head1 DESCRIPTION
This is the glyphs of the X11 "cursor" font as Perl constant subrs. The
cursor font is the usual way to create mouse pointer cursors of various
standard shapes.
The subr names are per the Xlib F, without
the C prefixes. Each glyph is a character for the foreground shape,
and the next character is the background mask.
X11::CursorConstants::fleur, # glyph
X11::CursorConstants::fleur + 1, # and its mask
So for example to create a "crosshair" cursor,
my $cursor_font = $X->new_rsrc;
$X->OpenConstants ($cursor_font, "cursor");
my $cursor = $X->new_rsrc;
$X->CreateGlyphCursor
($cursor,
$cursor_font, # font
$cursor_font, # mask font
X11::CursorConstants::crosshair, # glyph
X11::CursorConstants::crosshair + 1, # and its mask
0,0,0, # foreground, black
0xFFFF,0xFFFF,0xFFFF); # background, white
The images can be viewed with the C font display program,
xfd -fn cursor
=head1 CONSTANTS
There's no exporting, since it's unlikely more than a handful will be
needed, and usually only in one or two places each. The full list is
=cut
# List generated by
# (shell-command "perl -n -e '/define XC_([^ ]*).*?([0-9]+)/ and do { printf qq{ %-20s %3d\n}, $1, $2;}' is how many glyphs plus their masks
are in the font, ie. characters C<0> to C exist.
=head1 SEE ALSO
L,
L,
L
L,
L
F and listed in the Xlib manual appendix B
(F).
Xlib Xmu C
=head1 HOME PAGE
L
=head1 LICENSE
Copyright 2011, 2013 Kevin Ryde
X11-Protocol-Other is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any later
version.
X11-Protocol-Other is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
X11-Protocol-Other. If not, see .
=cut
X11-Protocol-Other-28/devel/encode-xlib.c 0000644 0001750 0001750 00000004270 11601324005 015737 0 ustar gg gg /* Copyright 2011 Kevin Ryde
This file is part of X11-Protocol-Other.
X11-Protocol-Other is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your option)
any later version.
X11-Protocol-Other is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along
with X11-Protocol-Other. If not, see . */
#include
#include
#include
#include
#include
#include
#include
int
main (void)
{
Display *display;
display = XOpenDisplay(NULL);
printf ("display %p\n", display);
{
FILE *fp = fopen ("encode-xlib.utf8","r");
if (! fp) { printf ("cannot open\n"); abort(); }
char buf[500000];
size_t len = fread (buf, 1, 1000000, fp);
fclose (fp);
buf[len] = '\0';
static char *ulist[2];
static XTextProperty text_prop;
int ret;
ulist[0] = buf;
ret = Xutf8TextListToTextProperty (display,
ulist,
1,
XCompoundTextStyle,
&text_prop);
printf ("ret %d\n", ret);
if (ret >= 0) {
printf ("text encoding %lu\n", text_prop.encoding);
printf ("text encoding %s\n", XGetAtomName(display,text_prop.encoding));
printf ("text format %d\n", text_prop.format);
printf ("text nitems %lu\n", text_prop.nitems);
printf ("text value: ");
/* for (i = 0; i < text_prop.nitems; i++) { */
/* printf (" %02X", text_prop.value[i]); */
/* } */
/* printf ("\n"); */
FILE *fp = fopen ("encode-emacs23xc.ctext","w");
if (! fp) { printf ("cannot open\n"); abort(); }
fwrite (text_prop.value, text_prop.nitems, 1, fp);
fclose(fp);
}
return 0;
}
return 0;
}
X11-Protocol-Other-28/devel/icon-window.pl 0000644 0001750 0001750 00000004007 11546161750 016210 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use 5.004;
use strict;
use X11::Protocol;
use X11::Protocol::WM;
# uncomment this to run the ### lines
use Smart::Comments;
{
my $X = X11::Protocol->new;
my $window = $X->new_rsrc;
$X->CreateWindow ($window,
$X->root, # parent
'InputOutput',
0, # depth, from parent
'CopyFromParent', # visual
0,0, # x,y
100,100, # width,height
0, # border
background_pixel => $X->black_pixel,
);
my $icon_window = $X->new_rsrc;
$X->CreateWindow ($icon_window,
$X->root, # parent
'InputOutput',
0, # depth, from parent
'CopyFromParent', # visual
0,0, # x,y
32,32, # width,height
0, # border
background_pixel => $X->white_pixel,
);
X11::Protocol::WM::set_wm_hints($X,$window,
input => 1,
icon_window => $icon_window,
);
$X->MapWindow($window);
while (1) {
$X->handle_input;
}
exit 0;
}
X11-Protocol-Other-28/devel/cursor-colour.pl 0000644 0001750 0001750 00000006465 11555441427 016605 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use strict;
use X11::Protocol;
use X11::AtomConstants;
use lib 'devel', '.';
# uncomment this to run the ### lines
#use Smart::Comments;
my $X = X11::Protocol->new;
if (! $X->init_extension('XFIXES')) {
print "XFIXES extension not available on the server\n";
exit 1;
}
my $bitmap1 = $X->new_rsrc;
$X->CreatePixmap ($bitmap1,
$X->root,
1,
32,32);
my $bitmap2 = $X->new_rsrc;
$X->CreatePixmap ($bitmap2,
$X->root,
1,
32,32);
my $gc_on = $X->new_rsrc;
$X->CreateGC ($gc_on, $bitmap1,
foreground => 1,
background => 0);
my $gc_off = $X->new_rsrc;
$X->CreateGC ($gc_off, $bitmap1,
foreground => 0,
background => 1);
$X->PolyFillRectangle ($bitmap1, $gc_off, [0,0, 32,32]);
$X->PolyFillRectangle ($bitmap1, $gc_on, [3,3, 5,5]);
$X->PolyFillRectangle ($bitmap2, $gc_on, [0,0, 32,32]);
# $X->PolyFillRectangle ($bitmap2, $gc_off, [16,0, 2,32]);
$X->PolyFillRectangle ($bitmap2, $gc_off, [0,2, 32,2]);
my $cursor = $X->new_rsrc;
$X->CreateCursor ($cursor, $bitmap1, $bitmap2,
0,0xAAAA,0,
0,0x5555,0,
# 0,0,0xFFFF,
# 0xFFFF,0,0,
# 128, 0, 0,
# 0, 128, 0,
0,0);
$X->ChangeWindowAttributes ($X->root,
cursor => $cursor);
my $window = $X->new_rsrc;
$X->CreateWindow ($window,
$X->root, # parent
'InputOutput', # class
$X->root_depth, # depth
'CopyFromParent', # visual
0,0, # x,y
64,64, # w,h initial size
0, # border
background_pixel => $X->black_pixel,
event_mask => $X->pack_event_mask('Exposure'),
);
$X->ChangeProperty($window,
X11::AtomConstants::WM_NAME, # property
X11::AtomConstants::STRING, # type
8, # byte format
'Replace',
'Current Cursor'); # window title
$X->MapWindow($window);
for (;;) {
$X->handle_input;
{
my ($rootx,$rooty, $width,$height, $xhot,$yhot, $serial, $pixels)
= $X->XFixesGetCursorImage ();
my @words = unpack 'L*', $pixels;
foreach my $y (0 .. $height-1) {
my @row = splice @words, 0,$width;
delete @row[5 .. $#row];
print map {sprintf '%08X ',$_} @row;
print "\n";
}
}
}
exit 0;
X11-Protocol-Other-28/devel/XFree86_DGA-2.t 0000644 0001750 0001750 00000031171 12045645663 015613 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
BEGIN { require 5 }
use strict;
use X11::Protocol;
use Test;
use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }
END { MyTestHelpers::diag ("END"); }
# uncomment this to run the ### lines
#use Smart::Comments;
my $test_count = (tests => 21)[1];
plan tests => $test_count;
require X11::Protocol;
MyTestHelpers::diag ("X11::Protocol version ", X11::Protocol->VERSION);
my $have_extension = 0;
my $display = $ENV{'DISPLAY'};
if (! defined $display) {
foreach (1 .. $test_count) {
skip ('No DISPLAY set', 1, 1);
}
exit 0;
}
# pass display arg so as not to get a "guess" warning
my $X;
if (! eval { $X = X11::Protocol->new ($display); }) {
MyTestHelpers::diag ('Cannot connect to X server -- ',$@);
foreach (1 .. $test_count) {
skip ('Cannot connect to X server', 1, 1);
}
exit 0;
}
$X->QueryPointer($X->{'root'}); # sync
my ($major_opcode, $first_event, $first_error)
= $X->QueryExtension('XFree86-DGA');
{
if (! defined $major_opcode) {
foreach (1 .. $test_count) {
skip ('QueryExtension() no XFree86-DGA on the server', 1, 1);
}
exit 0;
}
MyTestHelpers::diag ("XFree86-DGA extension opcode=$major_opcode event=$first_event error=$first_error");
}
if (! $X->init_extension ('XFree86-DGA')) {
die "QueryExtension says XFree86-DGA avaiable, but init_extension() failed";
}
$X->QueryPointer($X->root); # sync
{
my $want_major = 2;
my $want_minor = 0;
my ($server_major, $server_minor) = $X->XF86DGAQueryVersion();
MyTestHelpers::diag ("XF86DGAQueryVersion() got server version $server_major.$server_minor");
if ((($want_major <=> $server_major) || ($want_minor <=> $server_minor))
< 0) {
foreach (1 .. $test_count) {
skip ("QueryVersion() no XFree86-DGA $want_major.$want_minor on the server", 1, 1);
}
exit 0;
}
}
END {
if ($have_extension) {
MyTestHelpers::diag ("cleanup, XF86DGADirectVideo disable");
local $X->{'error_handler'} = sub {
my ($X, $data) = @_;
my ($type, $seq, $info, $minor_op, $major_op) = unpack 'xCSLSC', $data;
MyTestHelpers::diag (" ignore error in cleanup: ",$type);
};
$X->XF86DGADirectVideo (0, 0); # disable
$X->QueryPointer($X->root); # sync
MyTestHelpers::diag (" done XF86DGADirectVideo disable");
}
}
$have_extension = 1;
#------------------------------------------------------------------------------
# _hilo_to_card64()
ok (X11::Protocol::Ext::XFree86_DGA::_hilo_to_card64(0,1),
1);
ok (X11::Protocol::Ext::XFree86_DGA::_hilo_to_card64(0,0x8000_0000),
2147483648);
ok (X11::Protocol::Ext::XFree86_DGA::_hilo_to_card64(0,0xFFFF_FFFF),
4294967295);
ok (X11::Protocol::Ext::XFree86_DGA::_hilo_to_card64(0x8000_0000,3) . '',
'9223372036854775811');
ok (X11::Protocol::Ext::XFree86_DGA::_hilo_to_card64(0x1234_5678, 0x8765_4321) . '',
'1311768467139281697');
ok (X11::Protocol::Ext::XFree86_DGA::_hilo_to_card64(0xFFFF_FFFF, 0xFFFF_FFFF) . '',
'18446744073709551615');
#------------------------------------------------------------------------------
my $screen_num = MyTestHelpers::X11_chosen_screen_number($X);
my $direct_video_available;
{
my $flags = $X->XF86DGAQueryDirectVideo(0);
MyTestHelpers::diag ("XF86DGAQueryDirectVideo flags=$flags in hex ",
sprintf('%X',$flags));
ok ($flags =~ /^\d+$/, 1);
$direct_video_available = $flags & 1;
}
$X->QueryPointer($X->root); # sync
my $skip_if_no_direct_video;
if (! $direct_video_available) {
$skip_if_no_direct_video = 'no direct video available';
}
#------------------------------------------------------------------------------
# XDGASetClientVersion()
$X->XDGASetClientVersion(2,0);
$X->QueryPointer($X->root); # sync
#------------------------------------------------------------------------------
# XDGAQueryModes()
my $first_mode;
{
my @ret;
if ($direct_video_available) {
@ret = $X->XDGAQueryModes($screen_num);
}
skip ($skip_if_no_direct_video,
scalar(@ret) & 1, 0);
$first_mode = $ret[0];
}
#------------------------------------------------------------------------------
# XF86DGADirectVideo() enable
my $enabled = 1;
{
my $orig_error_handler = $X->{'error_handler'};
local $X->{'error_handler'} = sub {
my ($X, $data) = @_;
### error handler
### $data
my ($type, $seq, $info, $minor_op, $major_op) = unpack 'xCSLSC', $data;
my $typename = $X->interp('Error',$type);
if ($typename =~ /^XF86DGA/) {
MyTestHelpers::diag ("XF86DGADirectVideo error $typename");
$enabled = 0;
} else {
goto $orig_error_handler;
}
};
MyTestHelpers::diag ("XF86DGADirectVideo attempt ...");
$X->XF86DGADirectVideo($screen_num, 0x02);
$X->QueryPointer($X->root); # sync
MyTestHelpers::diag ("XF86DGADirectVideo done");
}
my $skip_if_not_enabled;
if ($enabled) {
MyTestHelpers::diag ('DirectVideo enabled');
} else {
MyTestHelpers::diag ('DirectVideo not enabled');
$skip_if_not_enabled = 'skip due to DirectVideo not enabled';
}
#------------------------------------------------------------------------------
# XDGAQueryModes()
#------------------------------------------------------------------------------
# XDGASetMode()
#------------------------------------------------------------------------------
# XDGASetViewport()
if ($enabled) { # Must activate first.
$X->XDGASetViewport($screen_num, 0,0, 0);
$X->QueryPointer($X->root); # sync
}
#------------------------------------------------------------------------------
# XDGAInstallColormap()
if ($enabled) { # Must activate first.
my $colormap = $X->default_colormap;
$X->XDGAInstallColormap($screen_num, $colormap);
$X->QueryPointer($X->root); # sync
}
#------------------------------------------------------------------------------
# XDGASelectInput()
if ($enabled) { # Must activate first.
$X->XDGASelectInput($screen_num,0);
$X->QueryPointer($X->root); # sync
}
#------------------------------------------------------------------------------
# XDGAFillRectangle()
if ($enabled) { # Must activate first.
$X->XDGAFillRectangle($screen_num, 0,0, 16,16, 0);
$X->QueryPointer($X->root); # sync
}
#------------------------------------------------------------------------------
# XDGACopyArea()
if ($enabled) { # Must activate first.
$X->XDGACopyArea($screen_num,
16,0, # src
16,16, # w,h
0,0); # dst
$X->QueryPointer($X->root); # sync
}
#------------------------------------------------------------------------------
# XDGACopyTransparentArea()
# FIXME: what is the key?
# Only if DGA_BLIT_RECT_TRANS ?
#
# if ($enabled) { # Must activate first.
# $X->XDGACopyTransparentArea($screen_num,
# 32,0, # src
# 16,16, # w,h
# 32,16, # dst
# 0); # key
# $X->QueryPointer($X->root); # sync
# }
#------------------------------------------------------------------------------
# XDGAGetViewportStatus()
{
my @ret;
if ($direct_video_available) {
@ret = $X->XDGAGetViewportStatus($screen_num);
MyTestHelpers::diag ("XDGAGetViewportStatus ", join(', ',@ret));
}
skip ($skip_if_no_direct_video,
scalar(@ret), 1);
# my ($device_name, $addr, $size, $offset, $extra) = @ret;
$X->QueryPointer($X->root); # sync
}
#------------------------------------------------------------------------------
# XDGASync()
if ($enabled) { # Must activate first.
$X->XDGASync($screen_num);
$X->QueryPointer($X->root); # sync
}
#------------------------------------------------------------------------------
# XDGAOpenFramebuffer()
{
my @ret;
if ($direct_video_available) {
@ret = $X->XDGAOpenFramebuffer($screen_num);
MyTestHelpers::diag ("XDGAOpenFramebuffer ", join(', ',@ret));
}
skip ($skip_if_no_direct_video,
scalar(@ret), 5);
# my ($device_name, $addr, $size, $offset, $extra) = @ret;
$X->QueryPointer($X->root); # sync
}
#------------------------------------------------------------------------------
# XDGACloseFramebuffer()
if ($direct_video_available) {
$X->XDGACloseFramebuffer($screen_num);
$X->QueryPointer($X->root); # sync
}
#------------------------------------------------------------------------------
# XDGAChangePixmapMode()
{
my @ret;
if ($direct_video_available) {
@ret = $X->XDGAChangePixmapMode($screen_num,0,0);
$X->QueryPointer($X->root); # sync
}
skip ($skip_if_no_direct_video,
scalar(@ret), 2);
}
#------------------------------------------------------------------------------
# XDGACreateColormap()
if ($enabled) {
my $colormap = $X->new_rsrc;
my $alloc = 0;
$X->XDGACreateColormap ($screen_num, $colormap, $first_mode, $alloc);
$X->QueryPointer($X->root); # sync
$X->FreeColormap($colormap);
$X->QueryPointer($X->root); # sync
}
#------------------------------------------------------------------------------
# XDGASetClientVersion()
#------------------------------------------------------------------------------
# XDGASetClientVersion()
#------------------------------------------------------------------------------
# XDGASetClientVersion()
#------------------------------------------------------------------------------
# XDGASetClientVersion()
#------------------------------------------------------------------------------
exit 0;
__END__
# XF86DGAGetVidPage
{
my $page = '';
if ($direct_video_available) {
$page = $X->XF86DGAGetVidPage(0);
MyTestHelpers::diag ("XF86DGAGetVidPage ", $page);
}
skip ($skip_if_no_direct_video,
$page =~ /^\d+$/, 1);
}
$X->QueryPointer($X->root); # sync
#------------------------------------------------------------------------------
# XF86DGADirectVideo
my $enabled = 1;
{
my $orig_error_handler = $X->{'error_handler'};
local $X->{'error_handler'} = sub {
my ($X, $data) = @_;
### error handler
### $data
my ($type, $seq, $info, $minor_op, $major_op) = unpack 'xCSLSC', $data;
my $typename = $X->interp('Error',$type);
if ($typename =~ /^XF86DGA/) {
MyTestHelpers::diag ("XF86DGADirectVideo error $typename");
$enabled = 0;
} else {
goto $orig_error_handler;
}
};
MyTestHelpers::diag ("XF86DGADirectVideo attempt ...");
$X->XF86DGADirectVideo(0, 0x02);
$X->QueryPointer($X->root); # sync
MyTestHelpers::diag ("XF86DGADirectVideo done");
}
my $skip_if_not_enabled;
if ($enabled) {
MyTestHelpers::diag ('DirectVideo enabled');
} else {
MyTestHelpers::diag ('DirectVideo not enabled');
$skip_if_not_enabled = 'skip due to DirectVideo not enabled';
}
#------------------------------------------------------------------------------
# XF86DGAGetVidPage / XF86DGASetVidPage
{
my $old_page = $X->XF86DGAGetVidPage(0);
my $new_page = 0;
my $got_page;
if ($enabled) {
$X->XF86DGASetVidPage (0, 0);
$got_page = $X->XF86DGAGetVidPage(0);
}
skip ($skip_if_not_enabled,
$got_page, $new_page,
'XF86DGASetVidPage page');
}
$X->QueryPointer($X->root); # sync
#------------------------------------------------------------------------------
# XF86DGASetViewPort
{
if ($enabled) {
$X->XF86DGASetViewPort(0, 0,0);
$X->QueryPointer($X->root); # sync
}
skip ($skip_if_not_enabled,
1,1, 'XF86DGAInstallColormap');
}
#------------------------------------------------------------------------------
# XF86DGAInstallColormap
{
my $colormap = $X->default_colormap;
if ($enabled) {
$X->XF86DGAInstallColormap(0, $colormap);
}
skip ($skip_if_not_enabled,
1,1, 'XF86DGAInstallColormap');
}
$X->QueryPointer($X->root); # sync
#------------------------------------------------------------------------------
# XF86DGAViewPortChanged
{
my $bool = 'x';
if ($enabled) {
$bool = $X->XF86DGAViewPortChanged(0);
MyTestHelpers::diag ("XF86DGAViewPortChanged ", $bool);
}
skip ($skip_if_not_enabled,
$bool =~ /^\d+$/, 1,
'XF86DGAViewPortChanged return');
}
$X->QueryPointer($X->root); # sync
#------------------------------------------------------------------------------
exit 0;
X11-Protocol-Other-28/devel/encode-run.el 0000644 0001750 0001750 00000010663 11601324031 015765 0 ustar gg gg ;; Copyright 2011 Kevin Ryde
;;
;; This file is part of X11-Protocol-Other.
;;
;; X11-Protocol-Other is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 3, or (at your option) any
;; later version.
;;
;; X11-Protocol-Other is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
;; Public License for more details.
;;
;; You should have received a copy of the GNU General Public License along
;; with X11-Protocol-Other. If not, see .
(mapcar (lambda (c) (format "%02x" c))
(encode-coding-char (decode-char 'ucs #x2572) 'compound-text))
;; #x2572
("1b" "24" "28" ;; GL 94^N
"47" ;; cns11643-7
"23" "4d") [2 times]
Esc $(G#M
;; 65509 FFE5
("1b" "24" "28" ;; GL 94^N
"41" ;; GB2312 942 chars
"23" "24")
Esc $(A#$
(mapcar (lambda (c) (format "%02x" c))
(encode-coding-string
(concat (decode-coding-string (string-make-unibyte
(string #xAB)) 'iso-8859-1)
(decode-coding-string (string-make-unibyte
(string #xAB)) 'iso-8859-2)
(decode-coding-string (string-make-unibyte
(string #xAB)) 'iso-8859-3)
(decode-coding-string (string-make-unibyte
(string #xAB)) 'iso-8859-4)
(decode-coding-string (string-make-unibyte
(string #xAB)) 'iso-8859-7)
(decode-coding-string (string-make-unibyte
(string #xAB)) 'iso-8859-6)
(decode-coding-string (string-make-unibyte
(string #xAB)) 'iso-8859-8)
(decode-coding-string (string-make-unibyte
(string #xAB)) 'iso-8859-5)
(decode-coding-string (string-make-unibyte
(string #xAB)) 'iso-8859-9)
)
'compound-text)
)
# Esc [ - F
(with-temp-buffer
(insert-file-contents "/tmp/x.utf8" nil)
(set-buffer-file-coding-system 'compound-text-with-extensions)
(write-file "/tmp/x.ctext"))
(with-temp-buffer
(dotimes (i #x2FA1)
(unless (or (< i 32)
(and (>= i #x7F) (<= i #x9F))
(and (>= i #xD800) (<= i #xDFFF))
(and (>= i #xFDD0) (<= i #xFDEF))
(and (>= i #xFFFE) (<= i #xFFFF))
(and (>= i #x1FFFE) (<= i #x1FFFF)))
(let* ((c (decode-char 'ucs i))
(str (encode-coding-char c
'ctext
;; 'compound-text-with-extensions
)))
(when str
(setq str (mapconcat (lambda (c)
(format "%02X" c))
str " "))
(insert (format "U+%04X = %s\n" i str))))))
(set-buffer-file-coding-system 'compound-text-with-extensions)
(set-buffer-file-coding-system 'utf-8)
(write-file (format "%s%d.txt"
(if (featurep 'xemacs) "xemacs" "emacs")
emacs-major-version)))
(insert (decode-coding-string (string-make-unibyte (string #x1B #x2D #x46 #xAA))
'compound-text))
(insert (decode-coding-string (string-make-unibyte (string #xAA))
'iso-8859-7))
(insert (decode-coding-string (string #x7E)
'japanese-iso-8bit))~
(with-temp-buffer
(set-buffer-file-coding-system 'ctext)
(insert (decode-coding-string (string #x1B #x28 #x4A #x7E) 'ctext))
(describe-char (point-min)))
(insert #x203E)
(progn
(switch-to-buffer "x")
(erase-buffer)
(require 'cl)
(loop for i from #x20 to #xFF
do
(let* ((str (decode-coding-string (string #x1B #x28 #x49
#x1B #x29 #x49
i) 'ctext))
(u (and (length str)
(encode-char (aref str 0) 'ucs))))
(insert (format "%02X %s %02X\n" i str (or u -1)))))
(goto-char (point-min))
(set-buffer-file-coding-system 'compound-text))
X11-Protocol-Other-28/devel/XFree86_VidModeExtension.t 0000644 0001750 0001750 00000022426 11711325637 020303 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use lib 'devel/lib';
$ENV{'DISPLAY'} ||= ":0";
BEGIN { require 5 }
use strict;
use X11::Protocol;
use Test;
use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }
END { MyTestHelpers::diag ("END"); }
# uncomment this to run the ### lines
#use Smart::Comments;
my $test_count = (tests => 21)[1];
plan tests => $test_count;
require X11::Protocol;
MyTestHelpers::diag ("X11::Protocol version ", X11::Protocol->VERSION);
my $have_extension = 0;
my $display = $ENV{'DISPLAY'};
if (! defined $display) {
foreach (1 .. $test_count) {
skip ('No DISPLAY set', 1, 1);
}
exit 0;
}
# pass display arg so as not to get a "guess" warning
my $X;
if (! eval { $X = X11::Protocol->new ($display); }) {
MyTestHelpers::diag ('Cannot connect to X server -- ',$@);
foreach (1 .. $test_count) {
skip ('Cannot connect to X server', 1, 1);
}
exit 0;
}
$X->QueryPointer($X->{'root'}); # sync
my ($major_opcode, $first_event, $first_error)
= $X->QueryExtension('XFree86-VidModeExtension');
{
if (! defined $major_opcode) {
foreach (1 .. $test_count) {
skip ('QueryExtension() no XFree86-VidModeExtension on the server', 1, 1);
}
exit 0;
}
MyTestHelpers::diag ("XFree86-VidModeExtension extension opcode=$major_opcode event=$first_event error=$first_error");
}
require X11::Protocol::Ext::XFree86_VidModeExtension;
if (! $X->init_extension ('XFree86-VidModeExtension')) {
die "QueryExtension says XFree86-VidModeExtension avaiable, but init_extension() failed";
}
$X->QueryPointer($X->root); # sync
#------------------------------------------------------------------------------
# "XF86VidMode" errors
{
ok ($X->num('Error','XF86VidModeBadClock'), $first_error);
ok ($X->num('Error','XF86VidModeBadHTimings'), $first_error+1);
ok ($X->num('Error','XF86VidModeBadVTimings'), $first_error+2);
ok ($X->num('Error','XF86VidModeModeUnsuitable'), $first_error+3);
ok ($X->num('Error','XF86VidModeExtensionDisabled'), $first_error+4);
ok ($X->num('Error','XF86VidModeClientNotLocal'), $first_error+5);
ok ($X->num('Error','XF86VidModeZoomLocked'), $first_error+6);
ok ($X->num('Error',$first_error), $first_error);
ok ($X->num('Error',$first_error+6), $first_error+6);
ok ($X->interp('Error',$first_error), 'XF86VidModeBadClock');
ok ($X->interp('Error',$first_error+1), 'XF86VidModeBadHTimings');
ok ($X->interp('Error',$first_error+2), 'XF86VidModeBadVTimings');
ok ($X->interp('Error',$first_error+3), 'XF86VidModeModeUnsuitable');
ok ($X->interp('Error',$first_error+4), 'XF86VidModeExtensionDisabled');
ok ($X->interp('Error',$first_error+5), 'XF86VidModeClientNotLocal');
ok ($X->interp('Error',$first_error+6), 'XF86VidModeZoomLocked');
{
local $X->{'do_interp'} = 0;
ok ($X->interp('Error',$first_error), $first_error);
ok ($X->interp('Error',$first_error+3), $first_error+3);
}
}
#------------------------------------------------------------------------------
# XF86VidModeQueryVersion
{
my @ret = $X->XF86VidModeQueryVersion;
MyTestHelpers::diag ("server XFree86_VidModeExtension version ", join('.',@ret));
ok (scalar(@ret), 2);
}
$X->QueryPointer($X->root); # sync
#------------------------------------------------------------------------------
# XF86VidModeGetModeLine
{
my @ret = $X->XF86VidModeGetModeLine(0);
MyTestHelpers::diag ("XF86VidModeGetModeLine ",
join(' ',@ret[0..$#ret-2])); # not "private" bytes
ok ($ret[0], 'dotclock');
ok ($ret[1] =~ /^\d+$/, 1);
ok ($ret[-2], 'private');
}
$X->QueryPointer($X->root); # sync
# #------------------------------------------------------------------------------
# # XF86VidModeGetVideoLL
# #
# # Have seen an x.org server on solaris give flags=1 from
# # XF86VidModeQueryDirectVideo() but then error XF86VidModeNoDirectVideoMode from an
# # attempt at XF86VidModeGetVideoLL(). So watch for an error here, not just from
# # $direct_video_available.
#
# {
# my $error;
# my $orig_error_handler = $X->{'error_handler'};
# local $X->{'error_handler'} = sub {
# my ($X, $data) = @_;
# ### error handler
# ### $data
#
# my ($type, $seq, $info, $minor_op, $major_op) = unpack 'xCSLSC', $data;
# my $typename = $X->interp('Error',$type);
# if ($typename =~ /^XF86VidMode/) {
# MyTestHelpers::diag ("XF86VidModeGetVideoLL error $typename");
# $error = $typename;
# $direct_video_available = 0;
# $skip_if_no_direct_video = 'error from XF86VidModeGetVideoLL';
# die "longjmp out to eval";
# } else {
# goto $orig_error_handler;
# }
# };
#
# my @ret;
# if ($direct_video_available) {
# if (eval {
# @ret = $X->XF86VidModeGetVideoLL(0);
# 1;
# }) {
# MyTestHelpers::diag ("XF86VidModeGetVideoLL ", join(', ',@ret));
# MyTestHelpers::diag (" in hex ", join(', ',map{sprintf '%X',$_}@ret));
# }
# }
# my $skip_if_error = (defined $error
# ? 'due to XF86VidModeGetVideoLL error reply'
# : undef);
# skip ($skip_if_error,
# scalar(@ret), 4);
# }
# $X->QueryPointer($X->root); # sync
#
#
# #------------------------------------------------------------------------------
# # XF86VidModeGetViewPortSize
#
# {
# my @ret;
# if ($direct_video_available) {
# @ret = $X->XF86VidModeGetViewPortSize(0);
# MyTestHelpers::diag ("XF86VidModeGetViewPortSize ", join(', ',@ret));
# }
# skip ($skip_if_no_direct_video,
# scalar(@ret), 2);
# }
# $X->QueryPointer($X->root); # sync
#
#
# #------------------------------------------------------------------------------
# # XF86VidModeGetVidPage
#
# {
# my $page = '';
# if ($direct_video_available) {
# $page = $X->XF86VidModeGetVidPage(0);
# MyTestHelpers::diag ("XF86VidModeGetVidPage ", $page);
# }
# skip ($skip_if_no_direct_video,
# $page =~ /^\d+$/, 1);
# }
# $X->QueryPointer($X->root); # sync
#
#
# #------------------------------------------------------------------------------
# # XF86VidModeDirectVideo
#
# my $enabled = 1;
# {
# my $orig_error_handler = $X->{'error_handler'};
# local $X->{'error_handler'} = sub {
# my ($X, $data) = @_;
# ### error handler
# ### $data
#
# my ($type, $seq, $info, $minor_op, $major_op) = unpack 'xCSLSC', $data;
# my $typename = $X->interp('Error',$type);
# if ($typename =~ /^XF86VidMode/) {
# MyTestHelpers::diag ("XF86VidModeDirectVideo error $typename");
# $enabled = 0;
# } else {
# goto $orig_error_handler;
# }
# };
#
# MyTestHelpers::diag ("XF86VidModeDirectVideo attempt ...");
# $X->XF86VidModeDirectVideo(0, 0x02);
# $X->QueryPointer($X->root); # sync
# MyTestHelpers::diag ("XF86VidModeDirectVideo done");
# }
#
# my $skip_if_not_enabled;
# if ($enabled) {
# MyTestHelpers::diag ('DirectVideo enabled');
# } else {
# MyTestHelpers::diag ('DirectVideo not enabled');
# $skip_if_not_enabled = 'skip due to DirectVideo not enabled';
# }
#
# #------------------------------------------------------------------------------
# # XF86VidModeGetVidPage / XF86VidModeSetVidPage
#
# {
# my $old_page = $X->XF86VidModeGetVidPage(0);
# my $new_page = 0;
# my $got_page;
# if ($enabled) {
# $X->XF86VidModeSetVidPage (0, 0);
# $got_page = $X->XF86VidModeGetVidPage(0);
# }
# skip ($skip_if_not_enabled,
# $got_page, $new_page,
# 'XF86VidModeSetVidPage page');
# }
# $X->QueryPointer($X->root); # sync
#
# #------------------------------------------------------------------------------
# # XF86VidModeSetViewPort
#
# {
# if ($enabled) {
# $X->XF86VidModeSetViewPort(0, 0,0);
# $X->QueryPointer($X->root); # sync
# }
# skip ($skip_if_not_enabled,
# 1,1, 'XF86VidModeInstallColormap');
# }
#
# #------------------------------------------------------------------------------
# # XF86VidModeInstallColormap
#
# {
# my $colormap = $X->default_colormap;
# if ($enabled) {
# $X->XF86VidModeInstallColormap(0, $colormap);
# }
# skip ($skip_if_not_enabled,
# 1,1, 'XF86VidModeInstallColormap');
# }
# $X->QueryPointer($X->root); # sync
#
#
# #------------------------------------------------------------------------------
# # XF86VidModeViewPortChanged
#
# {
# my $bool = 'x';
# if ($enabled) {
# $bool = $X->XF86VidModeViewPortChanged(0);
# MyTestHelpers::diag ("XF86VidModeViewPortChanged ", $bool);
# }
# skip ($skip_if_not_enabled,
# $bool =~ /^\d+$/, 1,
# 'XF86VidModeViewPortChanged return');
# }
# $X->QueryPointer($X->root); # sync
#------------------------------------------------------------------------------
exit 0;
X11-Protocol-Other-28/devel/wm-icon-size.pl 0000644 0001750 0001750 00000004706 12045124000 016260 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011, 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use 5.004;
use strict;
use X11::Protocol;
use X11::Protocol::WM;
# uncomment this to run the ### lines
use Smart::Comments;
# icewm
# jwm
# mwm
# olwm, olvwm
{
my $X = X11::Protocol->new;
my $root = $X->root;
my ($root_root, $root_parent, @toplevels) = $X->QueryTree($root);
foreach my $frame (@toplevels) {
printf "%X frame ", $frame;
{
my %geom = $X->GetGeometry($frame);
print "$geom{'x'},$geom{'y'}, $geom{'width'},$geom{'height'}";
}
print "\n";
my $window = X11::Protocol::WM::frame_window_to_client($X,$frame);
if (! $window) {
printf " no client\n", $frame;
next;
}
printf " %X ", $window;
{
my ($value, $type, $format, $bytes_after)
= $X->GetProperty($window, $X->atom('WM_NAME'), $X->atom('STRING'), 0, 999, 0);
print $value//'undef';
}
my %hints = X11::Protocol::WM::get_wm_hints($X,$window);
{
my %geom = $X->GetGeometry($frame);
print " $geom{'width'},$geom{'height'}";
}
print "\n";
{
my $icon_pixmap = $hints{'icon_pixmap'}||0;
printf " pixmap %X ", $icon_pixmap;
if ($icon_pixmap) {
my %geom = $X->GetGeometry($icon_pixmap);
print "$geom{'width'},$geom{'height'}";
}
print "\n";
}
{
my $icon_window = $hints{'icon_window'}||0;
printf " window %X\n", $icon_window;
}
}
exit 0;
}
{
my $X = X11::Protocol->new;
my ($value, $type, $format, $bytes_after)
= $X->GetProperty ($X->root,
X11::AtomConstants::WM_ICON_SIZE(),
0, # AnyPropertyType
0, # offset
999, # length
0); # delete;
### $value
exit 0;
}
X11-Protocol-Other-28/devel/kill-client.pl 0000644 0001750 0001750 00000002663 11533015353 016161 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2010, 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use 5.010;
use strict;
use warnings;
use X11::Protocol;
# uncomment this to run the ### lines
use Smart::Comments;
{
my $X = X11::Protocol->new;
my $X2 = X11::Protocol->new;
my $pixmap2 = $X2->new_rsrc;
$X2->CreatePixmap ($pixmap2,
$X2->{'root'},
$X2->{'root_depth'},
1,1); # width,height
{ my @q2 = $X2->QueryPointer($X2->{'root'}); # sync
### @q2
}
$X->KillClient($pixmap2);
{ my @q = $X->QueryPointer($X->{'root'}); # sync
### @q
}
sleep 1;
for (1 .. 1000) {
eval { $X2->UngrabServer; };
$X2->flush;
}
$X2->flush;
# { my @q2 = $X2->QueryPointer($X2->{'root'}); # sync
# ### @q2
# }
exit 0;
}
X11-Protocol-Other-28/devel/tog-cup.pl 0000644 0001750 0001750 00000003261 11707067066 015336 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011, 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use lib 'devel/lib';
$ENV{'DISPLAY'} ||= ':0';
use strict;
use X11::Protocol;
# uncomment this to run the ### lines
use Smart::Comments;
{
my $X = X11::Protocol->new;
$X->init_extension('TOG-CUP') or die $@;
$X->QueryPointer($X->{'root'}); # sync
{
my @version = $X->CupQueryVersion (99,99);
### @version
}
foreach (1 .. 80) { $X->QueryPointer($X->{'root'}); }
{
my @colors = $X->CupGetReservedColormapEntries (0);
### seq: $X->{'sequence_num'}
### @colors
$X->QueryPointer($X->{'root'}); # sync
}
my $visual = 0x20; # $X->root_visual;
my $rootwin = $X->root;
### $visual
### $rootwin
my $colormap = $X->new_rsrc;
$X->CreateColormap ($colormap, $visual, $rootwin, "None");
$X->QueryPointer($X->{'root'}); # sync
{
my @colors = $X->CupStoreColors ($colormap, 0, 1, 2, 3, 4);
### @colors
}
exit 0;
}
{
require Data::HexDump::XXD;
print scalar(Data::HexDump::XXD::xxd("z" x 17));
exit 0;
}
X11-Protocol-Other-28/devel/dri2.pl 0000644 0001750 0001750 00000010360 12046113274 014604 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use lib 'devel/lib';
$ENV{'DISPLAY'} ||= ":0";
use strict;
use X11::Protocol;
# uncomment this to run the ### lines
use Smart::Comments;
my $X = X11::Protocol->new;
my $window = $X->new_rsrc;
$X->CreateWindow ($window,
$X->root, # parent
'InputOutput',
0, # depth, from parent
'CopyFromParent', # visual
0,0, # x,y
100,100, # width,height
0, # border
background_pixel => $X->black_pixel,
);
$X->MapWindow ($window);
### $window
$X->init_extension('DRI2') or die $@;
{
my @version = $X->DRI2QueryVersion (1,3);
### @version
}
{
my @auth = $X->DRI2Authenticate($window,123);
### @auth
}
{
my @connect = $X->DRI2Connect($window,'DRI');
### @connect
}
# {
# my @connect = $X->DRI2Connect($window,'VDPAU');
# ### @connect
# }
{
my @buffers = $X->DRI2GetBuffers($window,2);
### @buffers
$X->QueryPointer($X->{'root'}); # sync
}
{
my @counters = $X->DRI2GetMSC($window);
### @counters
$X->QueryPointer($X->{'root'}); # sync
}
exit 0;
$X->flush;
sleep 1;
{
$X->WarpPointer ('None', $window, 0,0,0,0, 10,10);
### ButtonPress ...
$X->SetPointerMapping(3, 2, 1, 4 .. 10);
$X->Dri2FakeInput ([ name => 'ButtonPress',
detail => 1 ]);
$X->Dri2FakeInput (name => 'ButtonRelease',
time => 2000,
detail => 1);
$X->SetPointerMapping(1 .. 10);
for (;;) {
$X->handle_input;
}
exit 0;
}
{
### MotionNotify ...
$X->Dri2FakeInput ({ name => 'MotionNotify',
detail => 0,
root_x => 20,
root_y => 20,
});
for (;;) {
$X->handle_input;
}
exit 0;
}
# my $window = $X->root;
# my $status = $X->GrabPointer
# ($window, # window
# 0, # owner events
# $X->pack_event_mask('ButtonPress','ButtonRelease','PointerMotion'),
# 'Synchronous', # pointer mode
# 'Asynchronous', # keyboard mode
# 0, # confine window
# 0, # cursor
# 0); # time
# ### $status
# $X->QueryPointer($X->{'root'}); # sync
#
# $X->AllowEvents ('SyncPointer', 'CurrentTime');
# $X->QueryPointer($X->{'root'}); # sync
# $X->ChangeWindowAttributes
# ($window,
# event_mask => $X->pack_event_mask('ButtonPress','ButtonRelease'));
# $X->QueryPointer($X->{'root'}); # sync
$X->flush;
sleep 1;
$X->Dri2FakeInput ($X->pack_event
(name => 'ButtonPress',
detail => 3,
time => 0,
root => 0,
event => 0,
child => 'None',
root_x => 0,
root_y => 0,
event_x => 0,
event_y => 0,
state => 0,
same_screen => 0));
$X->flush;
sleep 10;
$X->Dri2FakeInput ($X->pack_event
(name => 'ButtonRelease',
detail => 3,
time => 0,
root => 0,
event => 0,
child => 'None',
root_x => 0,
root_y => 0,
event_x => 0,
event_y => 0,
state => 0,
same_screen => 0));
for (;;) {
$X->handle_input;
}
exit 0;
X11-Protocol-Other-28/devel/pointer-mapping.pl 0000644 0001750 0001750 00000001663 11600504770 017063 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2010, 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
BEGIN { require 5 }
use strict;
use X11::Protocol;
# uncomment this to run the ### lines
use Smart::Comments;
{
my $X = X11::Protocol->new (':0');
my @ret = $X->GetPointerMapping;
### @ret
exit 0;
}
X11-Protocol-Other-28/devel/xtest.pl 0000644 0001750 0001750 00000010316 12022023023 015076 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011, 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use lib 'devel/lib';
use strict;
use X11::Protocol;
# uncomment this to run the ### lines
use Smart::Comments;
my $X = X11::Protocol->new (':0');
$X->{'event_handler'} = sub {
my %h = @_;
### %h
# $X->AllowEvents ('SyncPointer', $h{'time'});
};
$X->init_extension('XTEST') or die $@;
{ my @version = $X->XTestGetVersion (2,1);
### @version
}
$X->QueryPointer($X->{'root'}); # sync
my $window = $X->new_rsrc;
$X->CreateWindow ($window,
$X->root, # parent
'InputOutput',
0, # depth, from parent
'CopyFromParent', # visual
0,0, # x,y
100,100, # width,height
0, # border
background_pixel => $X->black_pixel,
event_mask => $X->pack_event_mask('ButtonPress','ButtonRelease','PointerMotion'),
);
$X->MapWindow ($window);
$X->flush;
sleep 1;
{
$X->WarpPointer ('None', $window, 0,0,0,0, 10,10);
### fake ButtonPress ...
my @pointer_mapping = $X->GetPointerMapping;
my $last_button = scalar(@pointer_mapping);
$X->SetPointerMapping(3, 2, 1, 4 .. $last_button);
### with buttons remapped ...
$X->XTestFakeInput ([ name => 'ButtonPress',
detail => 1 ]);
$X->XTestFakeInput (name => 'ButtonRelease',
time => 2000,
detail => 1);
### restore buttons mapping ...
$X->SetPointerMapping(1 .. $last_button);
for (;;) {
$X->handle_input;
}
exit 0;
}
{
### MotionNotify ...
$X->XTestFakeInput (name => 'MotionNotify',
detail => 0,
root_x => 20,
root_y => 20,
);
for (;;) {
$X->handle_input;
}
exit 0;
}
# my $window = $X->root;
# my $status = $X->GrabPointer
# ($window, # window
# 0, # owner events
# $X->pack_event_mask('ButtonPress','ButtonRelease','PointerMotion'),
# 'Synchronous', # pointer mode
# 'Asynchronous', # keyboard mode
# 0, # confine window
# 0, # cursor
# 0); # time
# ### $status
# $X->QueryPointer($X->{'root'}); # sync
#
# $X->AllowEvents ('SyncPointer', 'CurrentTime');
# $X->QueryPointer($X->{'root'}); # sync
# $X->ChangeWindowAttributes
# ($window,
# event_mask => $X->pack_event_mask('ButtonPress','ButtonRelease'));
# $X->QueryPointer($X->{'root'}); # sync
$X->flush;
sleep 1;
$X->XTestFakeInput ($X->pack_event
(name => 'ButtonPress',
detail => 3,
time => 0,
root => 0,
event => 0,
child => 'None',
root_x => 0,
root_y => 0,
event_x => 0,
event_y => 0,
state => 0,
same_screen => 0));
$X->flush;
sleep 10;
$X->XTestFakeInput ($X->pack_event
(name => 'ButtonRelease',
detail => 3,
time => 0,
root => 0,
event => 0,
child => 'None',
root_x => 0,
root_y => 0,
event_x => 0,
event_y => 0,
state => 0,
same_screen => 0));
for (;;) {
$X->handle_input;
}
exit 0;
X11-Protocol-Other-28/devel/dpms.pl 0000644 0001750 0001750 00000001732 11552415457 014723 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use strict;
use X11::Protocol;
# uncomment this to run the ### lines
use Smart::Comments;
my $X = X11::Protocol->new(':0');
$X->init_extension('DPMS') or die;
my @ret = $X->DPMSInfo('DPMSModeOff');
### @ret
$X->DPMSForceLevel('DPMSModeOff');
exit 0;
X11-Protocol-Other-28/devel/scroll-new-window.pl 0000644 0001750 0001750 00000006563 12102036212 017335 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use strict;
use Time::HiRes;
use X11::Protocol;
use X11::Protocol::WM;
use lib 'devel', '.';
# uncomment this to run the ### lines
use Smart::Comments;
{
my $X = X11::Protocol->new (':0');
$X->{'event_handler'} = sub {
my (%h) = @_;
### event_handler: \%h
};
my $window = $X->new_rsrc;
$X->CreateWindow ($window,
$X->root, # parent
'InputOutput',
0, # depth, from parent
'CopyFromParent', # visual
0,0, # x,y
100,100, # width,height
0, # border
background_pixel => $X->black_pixel,
event_mask => $X->pack_event_mask('ButtonPress',
'ButtonMotion',
'PointerMotion',
'EnterWindow',
'LeaveWindow',
'FocusChange',
'OwnerGrabButton',
),
);
$X->MapWindow ($window);
$X->flush;
my $target = time() + 2;
for (;;) {
Time::HiRes::usleep(100);
while (fh_readable ($X->{'connection'}->fh)) {
### handle_input
$X->handle_input;
}
if (defined $target && time() > $target) {
$target = undef;
my %p = $X->QueryPointer($X->root);
### %p
my $x = $p{'root_x'};
my $y = $p{'root_y'};
my $win2 = $X->new_rsrc;
$X->CreateWindow ($win2,
$X->root, # parent
'InputOutput',
0, # depth, from parent
'CopyFromParent', # visual
$x-30,$y-30, # x,y
60,60, # width,height
0, # border
background_pixel => $X->black_pixel,
);
X11::Protocol::WM::set_wm_normal_hints ($X, $win2,
user_position => 1,
user_size => 1,
);
$X->MapWindow ($win2);
$X->flush;
}
}
exit 0;
}
sub fh_readable {
my ($fh) = @_;
require IO::Select;
my $s = IO::Select->new;
$s->add($fh);
my @ready = $s->can_read(1);
return scalar(@ready);
}
X11-Protocol-Other-28/devel/exe-xv-info.c 0000644 0001750 0001750 00000003507 11707617661 015741 0 ustar gg gg /* Copyright 2012 Kevin Ryde
This file is part of X11-Protocol-Other.
X11-Protocol-Other is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your option) any
later version.
X11-Protocol-Other is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along
with X11-Protocol-Other. If not, see .
*/
#include
#include
#include
#include
int
main (void)
{
char *display_name = getenv("DISPLAY");
if (! display_name) {
display_name = ":0";
}
Display *display = XOpenDisplay (display_name);
if (! display) {
printf ("no DISPLAY\n");
abort ();
}
Window window = DefaultRootWindow(display);
unsigned nadap;
XvAdaptorInfo *padap;
{
int status = XvQueryAdaptors (display, window, &nadap, &padap);
if (status) {
printf ("XvQueryAdaptors fail\n");
abort ();
}
}
printf ("nadap %u padap %p\n", nadap, padap);
unsigned a;
for (a = 0; a < nadap; a++) {
padap++;
unsigned i;
for (i = 0; i < padap[0].num_ports; i++) {
XvPortID port = padap[0].base_id + i;
printf ("port %u\n", port);
unsigned nenc;
XvEncodingInfo *penc;
{
int status = XvQueryEncodings (display, port, &nenc, &penc);
if (status) {
printf ("XvQueryEncodings fail\n");
abort ();
}
}
printf ("nenc %u penc %p\n", nenc, penc);
}
}
return 0;
}
X11-Protocol-Other-28/devel/encode-dump.c 0000644 0001750 0001750 00000014562 11601537157 015771 0 ustar gg gg /* Copyright 2011 Kevin Ryde
This file is part of X11-Protocol-Other.
X11-Protocol-Other is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your option)
any later version.
X11-Protocol-Other is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along
with X11-Protocol-Other. If not, see . */
#include
#include
#include
#include
#include
#include
#include
#include
#include
int
main (void)
{
Display *display;
setlocale (LC_ALL, NULL);
setlocale (LC_ALL, "ar_IN.UTF-8");
setlocale (LC_ALL, "en_AU.ISO-8859-1");
display = XOpenDisplay(NULL);
printf ("display %p\n", display);
{
/* static char ustr[] = "\xCB\x9A"; */
/* static char ustr[] = "\xE2\x80\xBE"; */ /* U+203E overline */
/* static char ustr[] = "\xE4\xB8\x80"; *//* U+4E00 */
iconv_t ic;
uint32_t ucs = 0x9F9C;
char *inbuf;
static char ustr[16];
char *outbuf;
size_t inleft, outlen, iret, ulen;
static char *ulist[2];
static XTextProperty text_prop;
int ret;
int i;
ic = iconv_open("utf-8","utf-32le");
if (ic == (iconv_t) -1) { perror("iconv_open"); abort(); }
for (ucs = 0x100; ucs <= 0x2F1AD; ucs++) {
inbuf = (char *) &ucs;
inleft = 4;
outbuf = ustr;
outlen = sizeof(ustr)-1;
iret = iconv (ic, &inbuf, &inleft, &outbuf, &outlen);
if (iret == -1) {
continue;
perror("iconv"); abort();
}
if (iret != 0) { printf("iret %u\n", iret); abort(); }
ulen = outbuf - ustr;
ustr[ulen] = '\0';
ulist[0] = ustr;
ret = Xutf8TextListToTextProperty (display,
ulist,
1,
XCompoundTextStyle,
&text_prop);
if (ret != 0) {
continue;
}
if (text_prop.value[1] != 0x24) {
continue;
}
if (text_prop.value[3] < 0x46) {
continue;
}
printf ("ret %d\n", ret);
if (ret >= 0) {
printf ("ucs 0x%04X ustr [len %u] ", ucs, ulen);
for (i = 0; i < ulen; i++) {
printf (" %02X", (unsigned) (unsigned char) ustr[i]);
}
printf ("\n");
printf ("text encoding %lu\n", text_prop.encoding);
printf ("text encoding %s\n", XGetAtomName(display,text_prop.encoding));
printf ("text format %d\n", text_prop.format);
printf ("text nitems %lu\n", text_prop.nitems);
printf ("text value: ");
for (i = 0; i < text_prop.nitems; i++) {
printf (" %02X", text_prop.value[i]);
}
printf ("\n");
break;
}
}
return 0;
}
{
static char ctext[] = "\x1B\x28\x4A\x7E";
/* "\x1B\x28\x49\x7C\x7D"; */
static XTextProperty text_prop;
int ret;
char **tlist;
int tcount;
int i;
text_prop.encoding = XInternAtom(display,"COMPOUND_TEXT",0);
text_prop.format = 8;
text_prop.nitems = strlen(ctext);
text_prop.value = (unsigned char *) ctext;
ret = Xutf8TextPropertyToTextList (display,
&text_prop,
&tlist,
&tcount);
printf (" Xutf8TextPropertyToTextList ret %d\n", ret);
printf (" got utf8 ");
for (i = 0; i < strlen(tlist[0]); i++) {
printf (" %02X", (int) (unsigned char) tlist[0][i]);
}
printf ("\n");
return 0;
}
{
const char *str = XDefaultString();
int i;
printf ("XDefaultString [len %d] ", strlen(str));
for (i = 0; i < strlen(str); i++) {
printf (" %02X", (int) (unsigned char) str[i]);
}
printf ("\n");
printf ("\"Success\" is %d\n", Success);
}
{
FILE *fp = fopen ("encode-emacs23.utf8","r");
if (! fp) { printf ("cannot open\n"); abort(); }
char buf[500000];
size_t len = fread (buf, 1, 500000, fp);
fclose (fp);
buf[len] = '\0';
static char *ulist[2];
static XTextProperty text_prop;
int ret;
ulist[0] = buf;
ret = Xutf8TextListToTextProperty (display,
ulist,
1,
XCompoundTextStyle,
&text_prop);
printf ("ret %d\n", ret);
if (ret >= 0) {
printf ("text encoding %lu\n", text_prop.encoding);
printf ("text encoding %s\n", XGetAtomName(display,text_prop.encoding));
printf ("text format %d\n", text_prop.format);
printf ("text nitems %lu\n", text_prop.nitems);
printf ("text value: ");
/* for (i = 0; i < text_prop.nitems; i++) { */
/* printf (" %02X", text_prop.value[i]); */
/* } */
/* printf ("\n"); */
FILE *fp = fopen ("encode-emacs23xc.ctext","w");
if (! fp) { printf ("cannot open\n"); abort(); }
fwrite (text_prop.value, text_prop.nitems, 1, fp);
fclose(fp);
}
return 0;
}
{
static wchar_t wstr[2];
static wchar_t *wlist[2];
static XTextProperty text_prop;
int ret;
wchar_t c;
int i;
for (c = 32; c < 1000; c++) {
wstr[0] = c;
wlist[0] = wstr;
ret = XwcTextListToTextProperty (display,
wlist,
1,
XCompoundTextStyle,
&text_prop);
printf ("c=%d ret %d\n", c, ret);
if (ret == 0) {
printf ("text encoding %lu\n", text_prop.encoding);
printf ("text encoding %s\n", XGetAtomName(display,text_prop.encoding));
printf ("text format %d\n", text_prop.format);
printf ("text nitems %lu\n", text_prop.nitems);
printf ("text value: ");
for (i = 0; i < text_prop.nitems; i++) {
printf (" %02X", text_prop.value[i]);
}
printf ("\n");
}
}
return 0;
}
return 0;
}
X11-Protocol-Other-28/devel/atoms.pl 0000644 0001750 0001750 00000007015 11566333102 015072 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2010, 2011 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
BEGIN { require 5 }
use strict;
# uncomment this to run the ### lines
use Smart::Comments;
{
package X11::AtomPredefined;
use vars '%atom', '%atom_name', '@atom_name';
%atom =
(
# (shell-command "perl -n -e '/define XA_([^ ]*).*?([0-9]+)/ and printf q{ %-19s => %d,\n}, $1, $2' 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,
);
%atom_name = reverse %atom;
while (my ($name, $number) = each %atom) {
### $name
### $number
if ($name ne 'LAST_PREDEFINED') {
$atom_name[$number] = $name;
}
}
}
print $X11::AtomPredefined::atom{'PIXMAP'},"\n";
print $X11::AtomPredefined::atom_name{20},"\n";
print $X11::AtomPredefined::atom_name[20],"\n";
print $X11::AtomPredefined::atom_name[68],"\n";
X11-Protocol-Other-28/devel/exe-screensaver-info.c 0000644 0001750 0001750 00000004002 11706711700 017577 0 ustar gg gg /* Copyright 2011, 2012 Kevin Ryde
This file is part of X11-Protocol-Other.
X11-Protocol-Other is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your option) any
later version.
X11-Protocol-Other is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along
with X11-Protocol-Other. If not, see .
*/
#include
#include
#include
#include
/* cf. ProcScreenSaverQueryInfo()
http://cgit.freedesktop.org/xorg/xserver/tree/Xext/saver.c#n719
*/
int
main (void)
{
Display *display;
Window rootwin;
int event_base, error_base;
XScreenSaverInfo info;
char *display_name = getenv("DISPLAY");
if (! display_name) {
display_name = ":0";
}
display = XOpenDisplay (display_name);
if (! display) {
printf ("no DISPLAY\n");
abort ();
}
rootwin = DefaultRootWindow (display);
if (! XScreenSaverQueryExtension (display, &event_base, &error_base)) {
printf ("screensaver not available\n");
abort ();
}
/* if (! XForceScreenSaver (display, ScreenSaverActive)) { */
/* printf ("cannot force screensaver on\n"); */
/* abort (); */
/* } */
/* XFlush (display); */
/* sleep(1); */
if (! XScreenSaverQueryInfo (display, rootwin, &info)) {
printf ("cannot QueryInfo\n");
abort();
}
printf ("state %d\n", info.state);
printf ("til_or_since %lu\n", info.til_or_since);
printf ("til_or_since as signed %ld\n", info.til_or_since);
if (! XForceScreenSaver (display, ScreenSaverReset)) {
printf ("cannot force screensaver off again\n");
abort ();
}
XFlush (display);
return 0;
}
X11-Protocol-Other-28/devel/dbe.pl 0000644 0001750 0001750 00000006725 11707506676 014527 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2011, 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use strict;
use X11::Protocol;
# uncomment this to run the ### lines
use Smart::Comments;
$ENV{'DISPLAY'} ||= ':0';
{
my $X = X11::Protocol->new;
$X->init_extension('DOUBLE-BUFFER') or die;
# {
# my @version = $X->DbeGetVersion (99,99);
# ### @version
# }
# # $X->QueryPointer($X->{'root'}); # sync
{
### DbeGetVisualInfo send ...
my $window = $X->root;
my $seq = $X->send('DbeGetVisualInfo',$window);
sleep 1;
### $seq
### sync ...
# foreach (1..7) {
# $X->send('GetAtomName',3);
# }
# # $X->{'connection'}->give("\0"x16384);
# $X->flush;
#
# $X->QueryPointer($X->{'root'});
for (;;) {
### X handle_input ...
$X->handle_input;
}
exit 0;
}
{
### DbeGetVisualInfo ...
### seq: $X->{'sequence_num'}
my @infos = $X->DbeGetVisualInfo($X->root);
### @infos
}
$X->QueryPointer($X->{'root'}); # sync
exit 0;
}
{
my $X = X11::Protocol->new (':0');
$X->{'event_handler'} = sub {
my (%h) = @_;
### event_handler: \%h
};
$X->init_extension('DOUBLE-BUFFER') or die $@;
$X->QueryPointer($X->{'root'}); # sync
my $width = 100;
my $height = 100;
my $window = $X->new_rsrc;
$X->CreateWindow ($window,
$X->root, # parent
'InputOutput',
0, # depth, from parent
'CopyFromParent', # visual
0,0, # x,y
$width,$height,
0, # border
background_pixel => $X->black_pixel,
);
$X->MapWindow ($window);
sleep 1;
my $gc = $X->new_rsrc;
$X->CreateGC ($gc, $window,
foreground => 0xFF00FF,
background => 0);
my $buffer = $X->new_rsrc;
$X->DbeAllocateBackBufferName ($window, $buffer, 'Copied');
$X->QueryPointer($X->{'root'}); # sync
$X->PolyFillRectangle ($buffer, $gc, [10,10, $width,$height]);
$X->QueryPointer($X->{'root'}); # sync
sleep 1;
$X->DbeSwapBuffers ($window, 'Copied');
$X->QueryPointer($X->{'root'}); # sync
sleep 1;
{
my @attr = $X->DbeGetBackBufferAttributes ($buffer);
### @attr
$X->QueryPointer($X->{'root'}); # sync
}
$X->DestroyWindow ($window);
$X->QueryPointer($X->{'root'}); # sync
{
my @attr = $X->DbeGetBackBufferAttributes ($buffer);
### @attr
$X->QueryPointer($X->{'root'}); # sync
}
$X->DbeDellocateBackBufferName ($buffer);
$X->PolyFillRectangle ($buffer, $gc, [0,0, $width,$height]);
$X->QueryPointer($X->{'root'}); # sync
exit 0;
}
sub atom_name_maybe {
my ($X, $atom) = @_;
my $ret = $X->robust_req ('GetAtomName', $atom);
if (ref $ret) {
return @$ret;
}
return '[not-atom]';
}
X11-Protocol-Other-28/devel/setroot.pl 0000644 0001750 0001750 00000012536 12236002761 015451 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2010, 2011, 2012, 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use 5.010;
use strict;
use warnings;
use X11::Protocol;
use X11::AtomConstants;
use Smart::Comments;
{
require X11::Protocol::XSetRoot;
{
X11::Protocol::XSetRoot->set_background
(
# root => 0xC00003,
color => '#F0FF00FFF0FF',
# color => sprintf('#%06X', rand(0x1000000)),
# pixel => 0xFFFFFF,
# pixel => 0xFF0000,
# allocated_pixels => 1,
# pixmap => 0,
use_esetroot => 1,
);
# now don't use $X11_protocol_object connection any more
}
{
my $X = X11::Protocol->new;
my %attr = $X->GetWindowAttributes($X->root);
### %attr
}
exit 0;
}
{
require X11::Protocol::XSetRoot;
{
my $X = X11::Protocol->new;
# my $colormap = $X->{'default_colormap'};
# my @ret = $X->AllocNamedColor($colormap, 'white');
# ### @ret
my $width = 100;
my $height = 100;
my $pixmap = $X->new_rsrc;
$X->CreatePixmap ($pixmap,
$X->{'root'},
$X->{'root_depth'},
$width,$height);
### pixmap: sprintf '%#X', $pixmap
my $white_pixel = $X->{'white_pixel'};
my $black_pixel = $X->{'black_pixel'};
### $white_pixel;
### $black_pixel
my $gc = $X->new_rsrc;
$X->CreateGC ($gc, $pixmap, foreground => $white_pixel);
$X->PolyFillRectangle ($pixmap, $gc, [0,0, $width,$height]);
$X->ChangeGC($gc, foreground => $black_pixel);
my $width_half = int($width *.3);
my $height_half = int($height *.3);
$X->PolyFillRectangle ($pixmap, $gc, [0,0, $width_half,$height_half]);
$X->PolyFillRectangle ($pixmap, $gc,
[$width_half,$height_half,
$width-$width_half,$height-$height_half]);
$X->FreeGC($gc);
X11::Protocol::XSetRoot->set_background
(X => $X,
pixmap => $pixmap,
use_esetroot => 1);
}
{
my $X = X11::Protocol->new;
my ($value, $type, $format, $bytes_after)
= $X->GetProperty($X->root,
$X->atom('_XROOTPMAP_ID'),
0, # AnyPropertyType
0, # offset
1, # length
0); # delete
if ($type == X11::AtomConstants::PIXMAP() && $format == 32) {
my $pixmap = unpack 'L', $value;
### _XROOTPMAP_ID: sprintf '%#X', $pixmap
my %geom = $X->GetGeometry($pixmap);
### %geom
}
}
exit 0;
}
{
# SetCloseDownMode while server grabbed
require X11::Protocol::WM;
my $X = X11::Protocol->new (':1');
$X->GrabServer;
my $pixmap = $X->new_rsrc;
$X->CreatePixmap ($pixmap,
$X->root,
$X->root_depth,
4,4); # width,height
printf "pixmap %X\n", $pixmap;
$X->SetCloseDownMode('RetainPermanent');
$X->flush;
exit 0;
}
{
require X11::Protocol::WM;
my $X = X11::Protocol->new;
my $root = $X->root;
### $root
my $vroot = X11::Protocol::WM::root_to_virtual_root($X,$root);
### $vroot
exit 0;
}
{
my $X = X11::Protocol->new;
$X->FreePixmap(0);
### sync: $X->QueryPointer($X->{'root'})
exit 0;
}
{
my $X = X11::Protocol->new;
my $rootwin = $X->{'root'};
my $atom = $X->atom('_SETROOT_ID');
my ($value, $type, $format, $bytes_after)
= $X->GetProperty ($rootwin, $atom,
0, # AnyPropertyType
0, # offset
1, # length
0); # delete;
### GetProperty: $X->atom_name($atom)
### $value
### $type
### $format
### $bytes_after
if ($type == X11::AtomConstants::PIXMAP && $format == 32) {
my $resource_pixmap = unpack 'L', $value;
### resource_pixmap: sprintf('%#X', $resource_pixmap)
### robust: $X->robust_req('KillClient',$resource_pixmap)
}
exit 0;
}
# Esetroot.c
# get _XROOTPMAP_ID
# get ESETROOT_PMAP_ID
# if equal then KillClient
#
# set _XROOTPMAP_ID
# set ESETROOT_PMAP_ID
# XSetCloseDownMode
#
#
# ENHANCE-ME: Don't intern atoms if they doesn't already exist.
sub _kill_current_esetroot {
my ($class, $X, $root) = @_;
### XSetRoot kill_current()
$root ||= $X->{'root'};
}
# {
# my ($value, $type, $format, $bytes_after)
# = $X->GetProperty($root,
# $X->atom('_XROOTPMAP_ID'),
# 0, # AnyPropertyType
# 0, # offset
# 1, # length
# 1); # delete
# if ($type == X11::AtomConstants::PIXMAP() && $format == 32) {
# my $pixmap = unpack 'L', $value;
# unless ($pixmap) { # watch out for $xid==0 for none maybe
# return;
# }
# }
# }
X11-Protocol-Other-28/devel/exe-xv.c 0000644 0001750 0001750 00000001742 11707352214 014775 0 ustar gg gg /* Copyright 2012 Kevin Ryde
This file is part of X11-Protocol-Other.
X11-Protocol-Other is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your option) any
later version.
X11-Protocol-Other is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along
with X11-Protocol-Other. If not, see .
*/
#include
#include
#include
int
main (void)
{
printf ("sizeof(xvEncodingInfo) %u\n",
sizeof(xvEncodingInfo));
printf ("sz_xvEncodingInfo %u\n",
sz_xvEncodingInfo);
printf ("\n");
return 0;
}
X11-Protocol-Other-28/devel/XInputExtension.t 0000644 0001750 0001750 00000015225 11706656024 016734 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2012 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
use lib 'devel/lib';
$ENV{'DISPLAY'} ||= ":0";
BEGIN { require 5 }
use strict;
use X11::Protocol;
use Test;
use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }
END { MyTestHelpers::diag ("END"); }
# uncomment this to run the ### lines
#use Smart::Comments;
my $test_count = (tests => 90)[1];
plan tests => $test_count;
require X11::Protocol;
MyTestHelpers::diag ("X11::Protocol version ", X11::Protocol->VERSION);
my $display = $ENV{'DISPLAY'};
if (! defined $display) {
foreach (1 .. $test_count) {
skip ('No DISPLAY set', 1, 1);
}
exit 0;
}
# pass display arg so as not to get a "guess" warning
my $X;
if (! eval { $X = X11::Protocol->new ($display); }) {
MyTestHelpers::diag ('Cannot connect to X server -- ',$@);
foreach (1 .. $test_count) {
skip ('Cannot connect to X server', 1, 1);
}
exit 0;
}
$X->QueryPointer($X->{'root'}); # sync
my ($major_opcode, $first_event, $first_error)
= $X->QueryExtension('XInputExtension');
{
if (! defined $major_opcode) {
foreach (1 .. $test_count) {
skip ('QueryExtension() no XInputExtension on the server', 1, 1);
}
exit 0;
}
MyTestHelpers::diag ("XInputExtension extension opcode=$major_opcode event=$first_event error=$first_error");
}
if (! $X->init_extension ('XInputExtension')) {
die "QueryExtension says XInputExtension avaiable, but init_extension() failed";
}
$X->QueryPointer($X->root); # sync
# #------------------------------------------------------------------------------
# # "XInputExtension" error
#
# {
# ok ($X->num('Error','Counter'), $first_error);
# ok ($X->num('Error','Alarm'), $first_error+1);
# ok ($X->num('Error',$first_error), $first_error);
# ok ($X->num('Error',$first_error+1), $first_error+1);
# ok ($X->interp('Error',$first_error), 'Counter');
# ok ($X->interp('Error',$first_error), 'Alarm');
# {
# local $X->{'do_interp'} = 0;
# ok ($X->interp('Error',$first_error), $first_error);
# ok ($X->interp('Error',$first_error+1), $first_error+1);
# }
# }
#
#
# #------------------------------------------------------------------------------
# # XInputExtensionReportLevel enum
#
# {
# ok ($X->num('XInputExtensionReportLevel','RawRectangles'), 0);
# ok ($X->num('XInputExtensionReportLevel','DeltaRectangles'), 1);
# ok ($X->num('XInputExtensionReportLevel','BoundingBox'), 2);
# ok ($X->num('XInputExtensionReportLevel','NonEmpty'), 3);
#
# ok ($X->num('XInputExtensionReportLevel',0), 0);
# ok ($X->num('XInputExtensionReportLevel',1), 1);
# ok ($X->num('XInputExtensionReportLevel',2), 2);
# ok ($X->num('XInputExtensionReportLevel',3), 3);
#
# ok ($X->interp('XInputExtensionReportLevel',0), 'RawRectangles');
# ok ($X->interp('XInputExtensionReportLevel',1), 'DeltaRectangles');
# ok ($X->interp('XInputExtensionReportLevel',2), 'BoundingBox');
# ok ($X->interp('XInputExtensionReportLevel',3), 'NonEmpty');
# }
#------------------------------------------------------------------------------
# XInputExtensionGetExtensionVersion
{
my @ret = $X->XInputExtensionGetExtensionVersion;
MyTestHelpers::diag ("server XInputExtension version ", join('.',@ret));
ok (scalar(@ret), 2);
}
{
my @ret = $X->XInputExtensionGetExtensionVersion ("XInputExtension");
MyTestHelpers::diag ("server XInputExtension version ", join('.',@ret));
ok (scalar(@ret), 2);
}
$X->QueryPointer($X->root); # sync
# #------------------------------------------------------------------------------
# # XInputExtensionCreateCounter / XInputExtensionDestroyCounter
#
# {
# my $counter = $X->new_rsrc;
# $X->XTestCreateCounter ($counter, 123);
#
# my $value = $X->XTestGetCounter ($counter);
# ok ($value, 123);
#
# $X->XTestDestroyCounter ($counter);
# $X->QueryPointer($X->root); # sync
# ok (1, 1, 'XTestCreate / XTestDestroy');
# }
#
# # #------------------------------------------------------------------------------
# # # XInputExtensionNotify event
# #
# # {
# # my $aref = $X->{'ext'}->{'XInputExtension'};
# # my ($request_num, $event_num, $error_num, $obj) = @$aref;
# #
# # my $more;
# # foreach $more (0, 1) {
# # my $time;
# # foreach $time ('CurrentTime', 103) {
# # my %input = (# can't use "name" on an extension event, at least in 0.56
# # # name => "XInputExtensionNotify",
# # synthetic => 1,
# # code => $event_num,
# # sequence_number => 100,
# # damage => 101,
# # drawable => 102,
# # level => 'BoundingBox',
# # more => $more,
# # time => $time,
# # area => [-104,-105,106,107],
# # geometry => [108,109,110,111]);
# # my $data = $X->pack_event(%input);
# # ok (length($data), 32);
# #
# # my %output = $X->unpack_event($data);
# # ### %output
# #
# # ok ($output{'code'}, $input{'code'});
# # ok ($output{'name'}, 'XInputExtensionNotify');
# # ok ($output{'synthetic'}, $input{'synthetic'});
# # ok ($output{'damage'}, $input{'damage'});
# # ok ($output{'drawable'}, $input{'drawable'});
# # ok ($output{'level'}, $input{'level'});
# # ok ($output{'more'}, $input{'more'});
# # ok ($output{'time'}, $input{'time'});
# #
# # ok ($output{'area'}->[0], $input{'area'}->[0]);
# # ok ($output{'area'}->[1], $input{'area'}->[1]);
# # ok ($output{'area'}->[2], $input{'area'}->[2]);
# # ok ($output{'area'}->[3], $input{'area'}->[3]);
# #
# # ok ($output{'geometry'}->[0], $input{'geometry'}->[0]);
# # ok ($output{'geometry'}->[1], $input{'geometry'}->[1]);
# # ok ($output{'geometry'}->[2], $input{'geometry'}->[2]);
# # ok ($output{'geometry'}->[3], $input{'geometry'}->[3]);
# # }
# # }
# # }
#
#
# #------------------------------------------------------------------------------
exit 0;
X11-Protocol-Other-28/devel/Encode-X11-xlib2.c 0000644 0001750 0001750 00000006202 11601323770 016335 0 ustar gg gg /* Copyright 2011 Kevin Ryde
This file is part of X11-Protocol-Other.
X11-Protocol-Other is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your option)
any later version.
X11-Protocol-Other is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along
with X11-Protocol-Other. If not, see . */
#include
#include
#include
#include
#include
#include
int
main (void)
{
Display *display;
static XTextProperty text_prop;
FILE *fp;
char buf[128];
int good = 1;
int count = 0;
display = XOpenDisplay(NULL);
if (! display) { printf ("cannot open DISPLAY\n"); abort(); }
fp = fopen ("../tempfile.txt","r");
if (! fp) { printf ("cannot open tempfile.utf8\n"); abort(); }
while (fgets (buf, 128, fp)) {
char *part;
int blen = 0;
int u;
char bytes[128];
int ret;
char **tlist;
int tcount;
char utf8[128];
int utf8len = 0;
count++;
part = strtok (buf, " ");
u = strtol (part, NULL, 0);
/* printf ("U+%04X\n", u); */
while ((part = strtok (NULL, " "))) {
bytes[blen++] = strtol (part, NULL, 16);
}
bytes[blen] = '\0';
/* printf ("blen %d\n", blen); */
fgets (buf, 128, fp);
part = strtok (buf, " ");
utf8[utf8len++] = strtol (part, NULL, 16);
while ((part = strtok (NULL, " "))) {
utf8[utf8len++] = strtol (part, NULL, 16);
}
utf8[utf8len] = '\0';
text_prop.encoding = XInternAtom(display,"COMPOUND_TEXT",0);
text_prop.format = 8;
text_prop.nitems = blen;
text_prop.value = (unsigned char *) bytes;
ret = Xutf8TextPropertyToTextList (display,
&text_prop,
&tlist,
&tcount);
if (ret != Success) {
int i;
printf ("U+%04X\n", u);
printf (" Xutf8TextPropertyToTextList ret %d\n", ret);
printf (" bytes ");
for (i = 0; i < blen; i++) {
printf (" %02X", (int) (unsigned char) bytes[i]);
}
printf ("\n");
continue;
}
if (strcmp (utf8, tlist[0]) != 0) {
int i;
printf ("U+%04X\n", u);
printf (" Xutf8TextPropertyToTextList different\n");
printf (" got utf8 ");
for (i = 0; i < strlen(tlist[0]); i++) {
printf (" %02X", (int) (unsigned char) tlist[0][i]);
}
printf ("\n");
printf (" want utf8 ");
for (i = 0; i < utf8len; i++) {
printf (" %02X", (int) (unsigned char) utf8[i]);
}
printf ("\n");
}
}
printf ("total count %d\n", count);
if (! good) {
abort();
}
return 0;
}
/* printf ("text nitems %lu\n", text_prop.nitems); */
/* printf ("text value: "); */
X11-Protocol-Other-28/devel/lib/ 0002755 0001750 0001750 00000000000 12237274211 014160 5 ustar gg gg X11-Protocol-Other-28/devel/lib/X11/ 0002755 0001750 0001750 00000000000 12237274211 014531 5 ustar gg gg X11-Protocol-Other-28/devel/lib/X11/Protocol/ 0002755 0001750 0001750 00000000000 12237274211 016332 5 ustar gg gg X11-Protocol-Other-28/devel/lib/X11/Protocol/Ext/ 0002755 0001750 0001750 00000000000 12237274211 017072 5 ustar gg gg X11-Protocol-Other-28/devel/lib/X11/Protocol/Ext/SYNC.t 0000644 0001750 0001750 00000032224 12215160756 020040 0 ustar gg gg #!/usr/bin/perl -w
# Copyright 2012, 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
BEGIN { require 5 }
use strict;
use X11::Protocol;
use Test;
use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }
END { MyTestHelpers::diag ("END"); }
# uncomment this to run the ### lines
# use Smart::Comments;
my $test_count = (tests => 158)[1];
plan tests => $test_count;
require X11::Protocol;
MyTestHelpers::diag ("X11::Protocol version ", X11::Protocol->VERSION);
my $display = $ENV{'DISPLAY'};
if (! defined $display) {
foreach (1 .. $test_count) {
skip ('No DISPLAY set', 1, 1);
}
exit 0;
}
# pass display arg so as not to get a "guess" warning
my $X;
if (! eval { $X = X11::Protocol->new ($display); }) {
MyTestHelpers::diag ('Cannot connect to X server -- ',$@);
foreach (1 .. $test_count) {
skip ('Cannot connect to X server', 1, 1);
}
exit 0;
}
$X->QueryPointer($X->{'root'}); # sync
my ($major_opcode, $first_event, $first_error)
= $X->QueryExtension('SYNC');
{
if (! defined $major_opcode) {
foreach (1 .. $test_count) {
skip ('QueryExtension() no SYNC on the server', 1, 1);
}
exit 0;
}
MyTestHelpers::diag ("SYNC extension opcode=$major_opcode event=$first_event error=$first_error");
}
if (! $X->init_extension ('SYNC')) {
die "QueryExtension says SYNC avaiable, but init_extension() failed";
}
$X->QueryPointer($X->root); # sync
#------------------------------------------------------------------------------
# Helpers.
# Return $b << $n, with $b converted to a Math::BigInt for the shift.
# No "<<" operator in old Math::BigInt, so this is implemented with "**".
sub big_leftshift {
my ($b, $n) = @_;
require Math::BigInt;
return Math::BigInt->new("$b") * Math::BigInt->new(2) ** $n;
}
#------------------------------------------------------------------------------
# _hilo_to_int64()
# Note explicit stringizing to cope with old Math::BigInt.
MyTestHelpers::diag ("_INT_BITS() is ", X11::Protocol::Ext::SYNC::_INT_BITS());
{ my $ret = X11::Protocol::Ext::SYNC::_hilo_to_int64(0,1);
$ret = "$ret";
$ret =~ s/^\+//;
ok ($ret == 1, 1);
}
{ my $ret = X11::Protocol::Ext::SYNC::_hilo_to_int64(0,0x8000_0000);
$ret = "$ret";
$ret =~ s/^\+//;
ok ($ret, '2147483648');
}
{ my $ret = X11::Protocol::Ext::SYNC::_hilo_to_int64(0,0xFFFF_FFFF);
$ret = "$ret";
$ret =~ s/^\+//;
ok ($ret, '4294967295');
}
{ my $ret = X11::Protocol::Ext::SYNC::_hilo_to_int64(0x8000_0000,3);
$ret = "$ret";
$ret =~ s/^\+//;
ok ($ret, '-9223372036854775805');
}
{ my $ret = X11::Protocol::Ext::SYNC::_hilo_to_int64(0x1234_5678, 0x8765_4321);
$ret = "$ret";
$ret =~ s/^\+//;
ok ($ret, '1311768467139281697');
}
{ my $ret = X11::Protocol::Ext::SYNC::_hilo_to_int64(0xFFFF_FFFF, 0xFFFF_FFFF);
$ret = "$ret";
$ret =~ s/^\+//;
ok ($ret == -1, 1);
}
#------------------------------------------------------------------------------
# _int64_to_hilo()
{ my @ret = X11::Protocol::Ext::SYNC::_int64_to_hilo(0);
ok (scalar(@ret), 2);
ok ($ret[0] == 0, 1);
ok ($ret[1] == 0, 1);
}
{ my @ret = X11::Protocol::Ext::SYNC::_int64_to_hilo(-1);
ok (scalar(@ret), 2);
ok ($ret[0] == 0xFFFF_FFFF, 1);
ok ($ret[1] == 0xFFFF_FFFF, 1);
}
{ my $sv = big_leftshift(1,32);
my @ret = X11::Protocol::Ext::SYNC::_int64_to_hilo($sv);
ok (scalar(@ret), 2);
ok ($ret[0] == 1, 1);
ok ($ret[1] == 0, 1);
}
{ my $sv = big_leftshift(1,63) - 1;
my @ret = X11::Protocol::Ext::SYNC::_int64_to_hilo($sv);
ok (scalar(@ret), 2);
ok ($ret[0] == 0x7FFF_FFFF, 1);
ok ($ret[1] == 0xFFFF_FFFF, 1);
}
{ # -8000_0000 0000_0000
my $sv = - big_leftshift(1,63);
my @ret = X11::Protocol::Ext::SYNC::_int64_to_hilo($sv);
ok (scalar(@ret), 2);
ok ($ret[0] == 0x8000_0000, 1, "-800..00 hi got $ret[0]");
ok ($ret[1] == 0, 1);
}
{ # -4000_0000 0000_0001
my $sv = - big_leftshift(1,62) - 1;
my ($hi,$lo) = X11::Protocol::Ext::SYNC::_int64_to_hilo($sv);
ok ($hi == 0xBFFF_FFFF, 1);
ok ($lo == 0xFFFF_FFFF, 1);
}
{
# -7FFF_FFFF FFFF_FFFF
my $sv = - big_leftshift(1,63) + 1;
my @ret = X11::Protocol::Ext::SYNC::_int64_to_hilo($sv);
ok (scalar(@ret), 2);
ok ($ret[0] == 0x8000_0000, 1, "-7FF..FF hi got $ret[0]");
ok ($ret[1] == 1, 1, "-7FF..FF lo want 1 got $ret[0]");
MyTestHelpers::diag ("sv=$sv hi=$ret[0] lo=$ret[1]");
}
#------------------------------------------------------------------------------
# errors
{
ok ($X->num('Error','Counter'), $first_error);
ok ($X->num('Error','Alarm'), $first_error+1);
ok ($X->num('Error',$first_error), $first_error);
ok ($X->num('Error',$first_error+1), $first_error+1);
ok ($X->interp('Error',$first_error), 'Counter');
ok ($X->interp('Error',$first_error+1), 'Alarm');
{
local $X->{'do_interp'} = 0;
ok ($X->interp('Error',$first_error), $first_error);
ok ($X->interp('Error',$first_error+1), $first_error+1);
}
}
#------------------------------------------------------------------------------
# SyncTestType enum
ok ($X->num('SyncTestType','PositiveTransition'), 0);
ok ($X->num('SyncTestType','NegativeTransition'), 1);
ok ($X->num('SyncTestType','PositiveComparison'), 2);
ok ($X->num('SyncTestType','NegativeComparison'), 3);
ok ($X->interp('SyncTestType',0), 'PositiveTransition');
ok ($X->interp('SyncTestType',1), 'NegativeTransition');
ok ($X->interp('SyncTestType',2), 'PositiveComparison');
ok ($X->interp('SyncTestType',3), 'NegativeComparison');
#------------------------------------------------------------------------------
# SyncValueType enum
ok ($X->num('SyncValueType','Absolute'), 0);
ok ($X->num('SyncValueType','Relative'), 1);
ok ($X->interp('SyncValueType',0), 'Absolute');
ok ($X->interp('SyncValueType',1), 'Relative');
#------------------------------------------------------------------------------
# SyncAlarmState enum
ok ($X->num('SyncAlarmState','Active'), 0);
ok ($X->num('SyncAlarmState','Inactive'), 1);
ok ($X->num('SyncAlarmState','Destroyed'), 2);
ok ($X->interp('SyncAlarmState',0), 'Active');
ok ($X->interp('SyncAlarmState',1), 'Inactive');
ok ($X->interp('SyncAlarmState',2), 'Destroyed');
#------------------------------------------------------------------------------
# SyncCreateCounter / SyncDestroyCounter
{
my $counter = $X->new_rsrc;
$X->SyncCreateCounter ($counter, 123);
$X->QueryPointer($X->root); # sync
ok (1, 1, 'SyncCreateCounter');
{ my $value = $X->SyncQueryCounter ($counter);
$value = "$value";
$value =~ s/^\+//;
ok ($value, 123);
}
{ my $value;
foreach $value (0, 1, -1,
big_leftshift(1,32),
- big_leftshift(1,32),
big_leftshift(1,63) - 1,
- big_leftshift(1,63),
) {
$X->SyncSetCounter ($counter, $value);
my $got_value = $X->SyncQueryCounter ($counter);
ok ($got_value == $value, 1,
"counter $value got $got_value");
}
}
$X->SyncDestroyCounter ($counter);
$X->QueryPointer($X->root); # sync
ok (1, 1, 'SyncDestroyCounter');
}
#------------------------------------------------------------------------------
# SyncCreateAlarm / SyncDestroyAlarm
{
my $alarm = $X->new_rsrc;
$X->SyncCreateAlarm ($alarm);
$X->SyncDestroyAlarm ($alarm);
$X->QueryPointer($X->root); # sync
ok (1, 1, 'SyncCreateAlarm / SyncDestroyAlarm');
}
#------------------------------------------------------------------------------
# alarm parameters
{
my $counter = $X->new_rsrc;
$X->SyncCreateCounter ($counter, 123);
my $alarm = $X->new_rsrc;
$X->SyncCreateAlarm ($alarm, value => -123);
{ my %h = $X->SyncQueryAlarm ($alarm);
ok ($h{'value'} == -123, 1);
ok ($h{'test_type'} eq 'PositiveComparison', 1);
ok ($h{'value_type'} eq 'Absolute', 1);
ok ($h{'delta'} == 1, 1);
ok ($h{'events'} == 1, 1);
ok ($h{'state'} eq 'Inactive', 1);
# print $h{'delta'},"\n";
# use Devel::Peek;
# Dump($h{'delta'});
}
{
$X->SyncChangeAlarm ($alarm,
test_type => 'NegativeComparison',
delta => -1);
my %h = $X->SyncQueryAlarm ($alarm);
ok ($h{'test_type'}, 'NegativeComparison');
ok ($h{'delta'} == -1, 1);
}
{
$X->SyncChangeAlarm ($alarm,
counter => $counter,
value_type => 'Relative');
my %h = $X->SyncQueryAlarm ($alarm);
ok ($h{'counter'}, $counter);
}
{
$X->SyncChangeAlarm ($alarm, value_type => 'Absolute');
my %h = $X->SyncQueryAlarm ($alarm);
ok ($h{'value_type'}, 'Absolute');
ok ($h{'events'}, 1);
}
{
$X->SyncChangeAlarm ($alarm, events => 0);
my %h = $X->SyncQueryAlarm ($alarm);
ok ($h{'events'}, 0);
}
$X->SyncDestroyAlarm ($alarm);
$X->SyncDestroyCounter ($counter);
$X->QueryPointer($X->root); # sync
}
#------------------------------------------------------------------------------
# SyncCounterNotify event
{
my $aref = $X->{'ext'}->{'SYNC'};
my ($request_num, $event_num, $error_num, $obj) = @$aref;
my $more;
foreach $more (0, 1) {
my $time;
foreach $time ('CurrentTime', 103) {
my %input = (# can't use "name" on an extension event, in
# X11::Protocol 0.56
# name => "SyncCounterNotify",
synthetic => 1,
code => $event_num,
sequence_number => 100,
counter => 101,
wait_value => -123,
counter_value => -256,
time => $time,
count => 6,
destroyed => 1,
);
my $data = $X->pack_event(%input);
ok (length($data), 32);
my %output = $X->unpack_event($data);
### %output
ok ($output{'code'}, $input{'code'});
ok ($output{'name'}, 'SyncCounterNotify');
ok ($output{'synthetic'}, $input{'synthetic'});
ok ($output{'counter'}, $input{'counter'});
ok ($output{'wait_value'}, $input{'wait_value'});
ok ($output{'counter_value'},$input{'counter_value'});
ok ($output{'time'}, $input{'time'});
ok ($output{'count'}, $input{'count'});
ok ($output{'destroyed'}, $input{'destroyed'});
}
}
}
#------------------------------------------------------------------------------
# SyncAlarmNotify event
{
my $aref = $X->{'ext'}->{'SYNC'};
my ($request_num, $event_num, $error_num, $obj) = @$aref;
my $alarm_event_num = $event_num + 1;
my $more;
foreach $more (0, 1) {
my $time;
foreach $time ('CurrentTime', 103) {
my %input = (# can't use "name" on an extension event, in
# X11::Protocol 0.56
# name => "SyncAlarmNotify",
synthetic => 1,
code => $alarm_event_num,
sequence_number => 100,
alarm => 101,
counter_value => -123,
alarm_value => -256,
time => $time,
state => 'Destroyed',
);
my $data = $X->pack_event(%input);
ok (length($data), 32);
my %output = $X->unpack_event($data);
### %output
ok ($output{'code'}, $input{'code'});
ok ($output{'name'}, 'SyncAlarmNotify');
ok ($output{'synthetic'}, $input{'synthetic'});
ok ($output{'alarm'}, $input{'alarm'});
ok ($output{'counter_value'}, $input{'counter_value'});
ok ($output{'alarm_value'}, $input{'alarm_value'});
ok ($output{'time'}, $input{'time'});
ok ($output{'state'}, $input{'state'});
}
}
}
#------------------------------------------------------------------------------
# SyncSetPriority / SyncGetPriority
{
$X->SyncSetPriority(0,123);
ok ($X->SyncGetPriority(0), 123);
$X->SyncSetPriority("None",-123);
ok ($X->SyncGetPriority(0), -123);
$X->SyncSetPriority(0,0);
ok ($X->SyncGetPriority(0), 0);
# second client connection
my $X2 = X11::Protocol->new ($display);
my $pixmap2 = $X2->new_rsrc;
$X2->CreatePixmap($pixmap2, $X2->root, 1, 1,1);
$X2->QueryPointer($X->root); # sync
$X->SyncSetPriority($pixmap2, 456);
ok ($X->SyncGetPriority($pixmap2), 456);
ok ($X2->SyncGetPriority(0), 456);
ok ($X->SyncGetPriority(0), 0);
my $pixmap = $X->new_rsrc;
$X->CreatePixmap($pixmap, $X2->root, 1, 1,1);
ok ($X->SyncGetPriority($pixmap), 0);
$X->FreePixmap($pixmap);
}
#------------------------------------------------------------------------------
exit 0;
X11-Protocol-Other-28/devel/lib/X11/Protocol/Ext/XFree86_VidModeExtension.pm 0000644 0001750 0001750 00000040110 12235642702 024117 0 ustar gg gg # test ...
# Copyright 2011, 2012, 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
BEGIN { require 5 }
package X11::Protocol::Ext::XFree86_VidModeExtension;
use strict;
use Carp;
use X11::Protocol;
use vars '$VERSION', '@CARP_NOT';
$VERSION = 28;
@CARP_NOT = ('X11::Protocol');
# uncomment this to run the ### lines
use Smart::Comments;
# Protocol 0.7:
# /so/x11r6.4/xc/include/extensions/xf86vmstr.h
# protocol
#
# /so/x11r6.4/xc/programs/Xserver/Xext/xf86vmode.c
# server
#
# Protocol 0.8:
# /so/xfree/xfree86-3.3.2.3a/include/extensions/xf86vmstr.h
# protocol
#
# /so/xfree/xfree86-3.3.2.3a/programs/Xserver/Xext/xf86vmode.c
# /so/xfree/xfree86-3.3.2.3a/programs/Xserver/hw/xfree86/common/xf86Cursor.c
# server
#
# /so/xfree/xfree86-3.3.2.3a/lib/Xxf86vm/XF86VMode.c
# /so/xfree/xfree86-3.3.2.3a/include/extensions/xf86vmode.h
# /so/xfree/xfree86-3.3.2.3a/programs/Xserver/hw/xfree86/doc/man/XF86VM.man
# xlib
#
# Protocol 2.0:
# /usr/include/X11/extensions/xf86vm.h
# /usr/include/X11/extensions/xf86vmproto.h
#
# /so/x86vm/libXxf86vm-1.1.1/src/XF86VMode.c
# Xlib
#
# /so/xorg/xorg-server-1.10.0/hw/xfree86/dixmods/extmod/xf86vmode.c
# server source
#
# Other:
# /usr/share/doc/x11proto-core-dev/x11protocol.txt.gz
#
# these not documented yet ...
use constant CLIENT_MAJOR_VERSION => 2;
use constant CLIENT_MINOR_VERSION => 1;
#------------------------------------------------------------------------------
# events
my $XF86VidModeNotify_event
= [ 'xCxxLsssSx16',
'detail',
'time',
'dx',
'dy',
'screen',
'state',
];
#------------------------------------------------------------------------------
# requests
my $reqs =
[
['XF86VidModeQueryVersion', # 0
\&_request_empty,
sub {
my ($X, $data) = @_;
return unpack 'x8SS', $data;
}],
['XF86VidModeGetModeLine', # 1
\&_request_screen16,
do {
my @fields = (qw(dotclock
hdisplay
hsyncstart
hsyncend
htotal
vdisplay
vsyncstart
vsyncend
vtotal
flags
private_size));
sub {
my ($X, $data) = @_;
# use Data::HexDump::XXD;
# print scalar(Data::HexDump::XXD::xxd($data));
# print "\n";
my @values = unpack 'x8LS8LL', $data;
my $private_size = pop @values;
### @values
### $private_size
return ((map { ($fields[$_] => $values[$_]) } 0 .. $#values),
private => substr($data,32,$private_size*4));;
}
},
],
['XF86VidModeModModeLine', # 2
do {
my @fields = (qw(dotclock
hdisplay
hsyncstart
hsyncend
htotal
vdisplay
vsyncstart
vsyncend
vtotal
flags
private_size));
sub {
my ($X, $screen_num, %h) = @_;
my $private = delete $h{'private'};
if (! defined $private) { $private = ''; }
$h{'private_size'} = int((length($private)+3)/4);
my @values = delete @h{@fields}; # hash slice
if (%h) {
croak "XF86VidModeModModeLine unknown field(s): ",join(',',keys %h);
}
return pack ('x8LS8LL'.padded($private),
$screen_num,
@values,
$private);
}
} ],
['XF86VidModeSwitchMode', # 3
sub {
my ($X, $screen_num, $zoom) = @_;
return pack 'SS', $screen_num, $zoom;
},
],
['XF86VidModeGetMonitor', # 4
\&_request_screen16,
sub {
my ($X, $data) = @_;
use Data::HexDump::XXD;
print scalar(Data::HexDump::XXD::xxd($data));
print "\n";
# There was a "bandwidth" field in protocol 0.7 and 0.8 headers, but
# the server never sent it and Xlib never used it.
#
my ($vendor_len, $model_len, $num_hsync, $num_vsync)
= unpack 'x8C4L', $data;
my $pos = 32;
my @hsyncs;
foreach (1 .. $num_hsync) {
my $sync = unpack 'L', substr($data,$pos,4);
$pos += 4;
push @hsyncs, [ $sync & 0xFFFF, $sync >> 16 ]; # lo,hi
}
my @vsyncs;
foreach (1 .. $num_vsync) {
my $sync = unpack 'L', substr($data,$pos,4);
$pos += 4;
push @vsyncs, [ $sync & 0xFFFF, $sync >> 16 ]; # lo,hi
}
my $vendor = substr ($data, $pos, $vendor_len);
$pos += $vendor_len + X11::Protocol::padding($vendor_len);
my $model = substr ($data, $pos, $model_len);
return $vendor, $model, \@hsyncs, \@vsyncs;
},
],
['XF86VidModeLockModeSwitch', # 5
sub {
my ($X, $screen_num, $lock) = @_;
return pack 'SS', $screen_num, $lock;
},
],
['XF86VidModeGetAllModeLines', # 6
\&_request_screen16,
sub {
my ($X, $data) = @_;
### XF86VidModeGetAllModeLines() reply length: length($data)
use Data::HexDump::XXD;
print scalar(Data::HexDump::XXD::xxd($data));
print "\n";
my $self = $X->{'ext'}{'XFree86_VidModeExtension'}->[3];
### $self
my $protocol_2 = ($self->{'set_client_major'} >= 2);
my $protocol_08 = (($self->{'major'} <=> 0 || $self->{'minor'} <=> 8)
>= 0);
my ($num_modes) = unpack 'x8L', $data;
### $num_modes
my $pos = 32;
my @ret;
foreach (1 .. $num_modes) {
### $pos
my %h;
# bigger data format if XF86VidModeSetClientVersion() is 2 or more
if ($protocol_2) {
@h{ # hash slice
qw(dotclock
hdisplay
hsyncstart
hsyncend
htotal
hskew
vdisplay
vsyncstart
vsyncend
vtotal
flags
private_size
)} = unpack 'LS4LS4x4Lx12L', substr($data,$pos,48);
$pos += 48;
} else {
@h{ # hash slice
qw(dotclock
hdisplay
hsyncstart
hsyncend
htotal
vdisplay
vsyncstart
vsyncend
vtotal
flags
private_size
)} = unpack 'LS8L2', substr($data,$pos,28);
$pos += 28;
}
# in protocol 0.7 the server gave a "private_size" field but didn't
# send the actual data, per server code in X11R6.4
# /so/x11r6.4/xc/programs/Xserver/Xext/xf86vmode.c
#
if ($protocol_08) {
my $private_size = 4 * delete $h{'private_size'};
### $private_size
$h{'private'} = substr($data,$pos,$private_size);
$pos += $private_size;
}
push @ret, \%h;
}
return @ret;
}
],
['XF86VidModeAddModeLine', # 7
sub {
my ($X, $screen) = @_;
die;
}],
['XF86VidModeDeleteModeLine', # 8
\&_request_screen16,
],
['XF86VidModeValidateModeLine', # 9
sub {
shift; # ($X, $screen, $n)
return pack 'SS', @_;
},
sub {
my ($X, $data) = @_;
return unpack 'x8L', $data; # (result)
} ],
['XF86VidModeSwitchToMode', # 10
\&_request_screen32, # and more ...
],
['XF86VidModeGetViewPort', # 11
\&_request_screen16,
sub {
my ($X, $data) = @_;
return unpack 'x8LL', $data; # ($x,$y)
} ],
['XF86VidModeSetViewPort', # 12
sub {
shift; # ($X, $screen, $x,$y)
return pack 'SxxLL', @_;
},
],
#---------------------------------------------------------------------------
# protocol 2.0
['XF86VidModeGetDotClocks', # 13
\&_request_screen16,
],
[ 'XF86VidModeSetClientVersion', # 14
sub {
my ($X, $client_major, $client_minor) = @_;
my $self = $X->{'ext'}{'XFree86_VidModeExtension'}->[3];
$self->{'set_client_major'} = $client_major;
return pack 'SS', @_;
},
],
[ 'XF86VidModeSetGamma', # 15
\&_request_card32s ], # ($X, $screen, $colormap)
[ 'XF86VidModeGetGamma', # 16
\&_request_card32s ], # ($X, $screen, $mask)
[ 'XF86VidModeGetGammaRamp', # 17
sub {
shift; # ($X, $screen, $x, $y, $width, $height, $color)
return pack 'LSSSSL', @_;
} ],
[ 'XF86VidModeSetGammaRamp', # 18
sub {
shift; # ($X, $screen, $src_x,$src_y, $width,$height, $dst_x,$dst_y)
return pack 'LS*', @_;
} ],
[ 'XF86VidModeGetGammaRampSize', # 19
sub {
shift;
# ($X, $screen, $src_x,$src_y, $width,$height, $dst_x,$dst_y, $key)
return pack 'LS6L', @_;
} ],
[ 'XF86VidModeGetPermissions', # 20
\&_request_screen16,
],
];
sub new {
my ($class, $X, $request_num, $event_num, $error_num) = @_;
### XF86VidMode new()
# Requests
_ext_requests_install ($X, $request_num, $reqs);
# Errors
_ext_const_error_install ($X, $error_num,
'XF86VidModeBadClock', # 0
'XF86VidModeBadHTimings', # 1
'XF86VidModeBadVTimings', # 2
'XF86VidModeModeUnsuitable', # 3
'XF86VidModeExtensionDisabled', # 4
'XF86VidModeClientNotLocal', # 5
'XF86VidModeZoomLocked', # 6
);
my ($server_major, $server_minor) = $X->XF86VidModeQueryVersion;
return bless { set_client_major => 0,
server_major => $server_major,
server_minor => $server_minor,
}, $class;
}
#------------------------------------------------------------------------------
# generic
sub _request_empty {
# ($X)
if (@_ > 1) {
croak "No parameters in this request";
}
return '';
}
sub _request_screen16 {
shift; # ($X, $screen)
@_ == 1 or croak "Single screen number parameter expected";
return pack 'Sxx', @_;
}
sub _num_none {
my ($xid) = @_;
if (defined $xid && $xid eq "None") {
return 0;
} else {
return $xid;
}
}
sub _ext_requests_install {
my ($X, $request_num, $reqs) = @_;
$X->{'ext_request'}->{$request_num} = $reqs;
my $href = $X->{'ext_request_num'};
my $i;
foreach $i (0 .. $#$reqs) {
$href->{$reqs->[$i]->[0]} = [$request_num, $i];
}
}
sub _ext_const_error_install {
my $X = shift; # ($X, $errname1,$errname2,...)
### _ext_const_error_install: @_
my $error_num = shift;
my $aref = $X->{'ext_const'}{'Error'} # copy
= [ @{$X->{'ext_const'}{'Error'} || []} ];
my $href = $X->{'ext_const_num'}{'Error'} # copy
= { %{$X->{'ext_const_num'}{'Error'} || {}} };
my $i;
foreach $i (0 .. $#_) {
$aref->[$error_num + $i] = $_[$i];
$href->{$_[$i]} = $error_num + $i;
}
}
1;
__END__
=for stopwords XID Ryde
=head1 NAME
X11::Protocol::Ext::XFree86_VidModeExtension - video modes
=head1 SYNOPSIS
use X11::Protocol;
my $X = X11::Protocol->new;
$X->init_extension('XFree86-VidModeExtension')
or print "XFree86-VidModeExtension extension not available";
=head1 DESCRIPTION
The XFree86-VidModeExtension extension ...
=head1 REQUESTS
The following requests are made available with an C, as
per L.
my $is_available = $X->init_extension('XFree86-VidModeExtension');
=head2 XFree86-VidModeExtension 1.0
=over
=item C<($server_major, $server_minor) = $X-EXF86VidModeQueryVersion ()>
Return the DGA protocol version implemented by the server.
=item C<%h = $X-EXF86VidModeGetModeLine ($screen_num)>
Get the current mode of C<$screen_num> (integer 0 upwards). The return is a
list of key/value pairs,
dotclock => integer
hdisplay => integer, horizontal visible pixels
hsyncstart => integer, horizontal sync start
hsyncend => integer, horizontal sync end
htotal => integer, horizontal total pixels
vdisplay => integer, vertical visible pixels
vsyncstart => integer, vertical sync start
vsyncend => integer, vertical sync end
vtotal => integer, vertical total pixels
flags => integer
private => byte string
They can be put into a hash for access to a particular value,
my %h = $X->XF86VidModeGetModeLine(0);
print $h{'hskew'},"\n";
C is extra data from the driver on the screen. Usually it's an
empty string, but for example in the past the S3 Virge driver had some extra
flags and blank delay there. In the current code this is always just a byte
string, no attempt at a decode.
=item C<$X-EXF86VidModeModModeLine ($screen_num, key=Evalue,...)>
Modify the current mode of C<$screen_num> (integer 0 upwards). Key/value
parameters are as per C above.
All fields are mandatory, except for C which is treated as an empty
string if omitted.
Any mode values can be given (not just those listed by
C) but it's generally the caller's
responsibility to ensure they don't exceed the capabilities of the monitor.
=item C<($vendor, $model, $hsyncs_aref, $vsyncs_aref) = $X-EXF86VidModeGetMonitor ($screen_num)>
Get information on the monitor and its capabilities.
C<$vendor> and C<$model> are strings. C<$hsyncs_aref> and C<$hsyncs_aref>
are arrayrefs containing in turn arrayref pairs of low,high permitted sync
amounts,
[ [ 3000, 4500 ],
[ 7200, 8200 ]
]
For reference, past versions of the protocol headers and Xlib docs had a
"bandwidth" field here, but the server never sent it and Xlib never looked
at it.
=item C<$X-EXF86VidModeSwitchMode ($screen_num, $zoom)>
Switch to the next or previous mode on C<$screen_num> (integer 0 upwards).
If C<$zoom> is 1 (or more) to switch to the next mode, or 0 to switch to the
previous mode.
=item C<$X-EXF86VidModeLockModeSwitch ($screen_num, $lock)>
Lock or unlock mode switching on C<$screen_num> (integer 0 upwards). If
C<$lock> is non-zero then mode switching via either the keyboard or the
C request is prevented. If C<$lock> is zero
switching is allowed again.
=item C<$X-EXF86VidModeGetAllModeLines ($screen_num)>
=back
=head1 BUGS
Some versions of the X.org server circa 1.10 had the C field of
C byte swapped as 16-bit instead of 32-bit.
If it's zero this makes no difference, but non-zero might come out wrong for
a client with different endianness than the server.
=over
L
=back
=head1 SEE ALSO
L
=head1 HOME PAGE
L
=head1 LICENSE
Copyright 2011, 2012, 2013 Kevin Ryde
X11-Protocol-Other is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any later
version.
X11-Protocol-Other is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
X11-Protocol-Other. If not, see .
=cut
X11-Protocol-Other-28/devel/lib/X11/Protocol/Ext/XInputExtension.pm 0000644 0001750 0001750 00000045520 12235642702 022562 0 ustar gg gg # in progress
# Copyright 2011, 2012, 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
BEGIN { require 5 }
package X11::Protocol::Ext::XInputExtension;
use strict;
use Carp;
use X11::Protocol;
use vars '$VERSION', '@CARP_NOT';
$VERSION = 28;
@CARP_NOT = ('X11::Protocol');
# uncomment this to run the ### lines
use Smart::Comments;
# /usr/share/doc/x11proto-input-dev/XIproto.txt.gz
# /usr/share/doc/x11proto-input-dev/XI2proto.txt.gz
#
# /usr/include/X11/extensions/XIproto.h
# /usr/include/X11/extensions/XI2proto.h
#
# /usr/include/X11/extensions/XInput2.h
#
# /usr/share/doc/x11proto-core-dev/x11protocol.txt.gz
#
# xinput dumper programs
#
# these not documented yet ...
use constant CLIENT_MAJOR_VERSION => 2;
use constant CLIENT_MINOR_VERSION => 0;
#------------------------------------------------------------------------------
# symbolic constants
my %const_arrays
= (
XIDeviceUse => ['MasterPointer', 'MasterKeyboard',
'SlavePointer', 'SlaveKeyboard',
'FloatingSlave' ],
XIClass => ['Key', 'Button', 'Valuator'],
XIDeviceMode => ['Relative', 'Absolute'],
XIFeedbackClass => ['Kbd', # 0
'Ptr', # 1
'String', # 2
'Integer', # 3
'Led', # 4
'Bell', # 5
],
XIUse => ['Pointer', # 0
'Keyboard', # 1
'ExtensionDevice', # 2
'ExtensionKeyboard', # 3
'ExtensionPointer', # 4
],
XIEventMode => [ 'AsyncThisDevice', # 0 per XI.h
'SyncThisDevice', # 1
'ReplayThisdevice', # 2
'AsyncOtherDevices', # 3
'AsyncAll', # 4
'SyncAll', # 5
]
);
my %const_hashes
= (map { $_ => { X11::Protocol::make_num_hash($const_arrays{$_}) } }
keys %const_arrays);
#------------------------------------------------------------------------------
# requests
my $reqs =
[
undef, # 0
['XIGetExtensionVersion', # 1
sub {
my ($X, $name) = @_;
### XIGetExtensionVersion() ...
if (! defined $name) { $name = "XInputExtension"; }
# my $ret = pack ('Sxx' . X11::Protocol::padded($name),
# length($name), $name);
# ### $ret
# ### len: length($ret)
return pack ('Sxx' . X11::Protocol::padded($name),
length($name), $name);
},
sub {
my ($X, $data) = @_;
return unpack 'x8SS', $data;
# Any interest in holding onto the version?
# my ($server_major, $server_minor) = unpack 'x8SS', $data;
# ### $server_major
# ### $server_minor
# my $self;
# if ($self = $self->{'ext'}{'XInputExtension'}->[3]) {
# $self->{'major'} = $server_major;
# $self->{'minor'} = $server_minor;
# }
# return ($server_major, $server_minor);
}],
['XIListInputDevices', # 2
\&_request_empty,
sub {
my ($X, $data) = @_;
# use Data::HexDump::XXD;
# print scalar(Data::HexDump::XXD::xxd($data));
# print "\n";
my ($num_devices) = unpack 'x8C', $data;
my $pos = 32;
### $num_devices
my @ret;
my @infos;
foreach (1 .. $num_devices) {
### device: $_
### pos: sprintf '%d %#X', $pos, $pos
my ($type_atom, $deviceid, $num_classes, $use, $attached_deviceid)
= unpack 'LCCCC', substr ($data, $pos, 8);
$pos += 8;
my $info = { type => $type_atom,
use => $X->interp('XIUse',$use),
attached_deviceid => $attached_deviceid,
num_classes => $num_classes,
};
push @infos, $info;
push @ret, $deviceid => $info;
}
my $info;
foreach $info (@infos) {
my $num_classes = $info->{'num_classes'};
my @classes;
$info->{'classes'} = \@classes;
foreach (1 .. $num_classes) {
### pos: sprintf '%d %#X', $pos, $pos
my ($class, $class_len) = unpack 'CC', substr ($data, $pos, 2);
my %class_info = (class => $X->interp('XIClass',$class));
push @classes, \%class_info;
### $class
### class interp: $X->interp('XIClass',$class)
### $class_len
### assert: $class_len >= 2
if ($class == 0) { # Key
($class_info{'min_keycode'},
$class_info{'max_keycode'},
$class_info{'num_keys'})
= unpack 'xxCCS', substr ($data, $pos, 6);
} elsif ($class == 1) { # Button
($class_info{'num_buttons'})
= unpack 'xxS', substr ($data, $pos, 4);
} elsif ($class == 2) { # Valuator
my ($num_axes, $mode, $motion_buffer_size)
= unpack 'xxCCL', substr ($data, $pos, 8);
$class_info{'num_axes'} = $num_axes;
$class_info{'mode'} = $X->interp('XIDeviceMode',$mode);
$class_info{'motion_buffer_size'} = $motion_buffer_size;
$class_info{'axes'}
= [ map {
# FIXME: min/max signed or unsigned? Xlib is signed ...
my ($resolution, $min_value, $max_value)
= unpack 'Lll', substr ($data, $pos+12*$_-4, 12);
{ resolution => $resolution,
min_value => $min_value,
max_value => $max_value
}
} 1 .. $num_axes ];
}
$pos += $class_len;
}
}
### names pos: sprintf '%d %#X', $pos, $pos
foreach my $i (1 .. $num_devices) {
my ($name_len) = unpack 'C', substr($data,$pos++,1);
### $name_len
$ret[2*$i-1]->{'name'} = substr($data,$pos,$name_len);
$pos += $name_len;
}
return @ret;
}],
undef, # OpenDevice 3
['XICloseDevice', # 4
sub {
my ($X, $deviceid) = @_;
return pack 'Cxxx', $deviceid;
}],
['XISetDeviceMode', # 5
sub {
my ($X, $deviceid, $mode) = @_;
return pack 'CCxx',
$deviceid, $X->num('XIDeviceMode',$mode);
},
sub {
my ($X, $data) = @_;
# FIXME: decode status value ...
return unpack 'x8C', $data;
}],
undef, # SelectExtensionEvent 6
undef, # GetSelectedExtensionEvents 7
undef, # ChangeDeviceDontPropagateList 8
undef, # GetDeviceDontPropagateList 9
undef, # GetDeviceMotionEvents 10
undef, # ChangeKeyboardDevice 11
undef, # ChangePointerDevice 12
['XIGrabDevice', # 13
sub {
my ($X, $window, $deviceid, $owner_events, $event_class_list,
$this_device_mode, $other_device_mode, $time) = @_;
return pack('LLSCCCCxxC*',
$window,
_num_time($time),
scalar(@$event_class_list), # event_count
$X->num('SyncMode',$this_device_mode),
$X->num('SyncMode',$other_device_mode),
$owner_events,
$deviceid,
map {$X->num('XIEventClass',$_)}
@$event_class_list
)
},
sub {
my ($X, $data) = @_;
my ($status) = unpack 'x8C', $data;
return $X->interp('GrabStatus',$status);
} ],
['XIUngrabDevice', # 14
sub {
my ($X, $deviceid, $time) = @_;
return pack 'LCxxx', _num_time($time), $deviceid;
} ],
undef, # GrabDeviceKey 15
undef, # UngrabDeviceKey 16
undef, # GrabDeviceButton 17
undef, # UngrabDeviceButton 18
['XIAllowDeviceEvents', # 19
sub {
my ($X, $deviceid, $event_mode, $time) = @_;
return pack 'LCCxx',
_num_time($time),
$X->num('XIEventMode',$event_mode),
$deviceid;
} ],
undef, # GetDeviceFocus 20
undef, # SetDeviceFocus 21
undef, # GetFeedbackControl 22
undef, # ChangeFeedbackControl 23
undef, # GetDeviceKeyMapping 24
undef, # ChangeDeviceKeyMapping 25
undef, # GetDeviceModifierMapping 26
undef, # SetDeviceModifierMapping 27
undef, # GetDeviceButtonMapping 28
undef, # SetDeviceButtonMapping 29
undef, # QueryDeviceState 30
undef, # SendExtensionEvent 31
['XIDeviceBell', # 32
sub {
my ($X, $deviceid, $feedbackclass, $feedbackid, $percent) = @_;
return pack 'CCCc', $deviceid, $feedbackclass, $feedbackid, $percent;
} ], #
undef, # SetDeviceValuators 33
undef, # GetDeviceControl 34
undef, # ChangeDeviceControl 35
# -------------------------------------------------------------------------
# XInputExtension version 1.5
undef, # ListDeviceProperties 36
undef, # ChangeDeviceProperty 37
undef, # DeleteDeviceProperty 38
undef, # GetDeviceProperty 39
# -------------------------------------------------------------------------
# XInputExtension version 2.0
undef, # XIQueryPointer 40
undef, # XIWarpPointer 41
undef, # XIChangeCursor 42
undef, # XIChangeHierarchy 43
undef, # XISetClientPointer 44
undef, # XIGetClientPointer 45
undef, # XISelectEvents 46
['XIQueryVersion', # 47
sub {
shift; # ($X, $client_major, $client_minor)
### XIQueryVersion() ...
return pack 'SS', @_;
},
sub {
my ($X, $data) = @_;
return unpack 'x8SS', $data;
# Any interest in holding onto the version?
# my ($server_major, $server_minor) = unpack 'x8SS', $data;
# ### $server_major
# ### $server_minor
# my $self;
# if ($self = $self->{'ext'}{'XI'}->[3]) {
# $self->{'major'} = $server_major;
# $self->{'minor'} = $server_minor;
# }
# return ($server_major, $server_minor);
}],
['XIQueryDevice', # 48
sub {
my ($X, $deviceid) = @_;
### XIQueryDevice() ...
return pack 'Sxx', $deviceid;
},
sub {
my ($X, $data) = @_;
### XIQueryDevice reply ...
my ($num_devices) = unpack 'x8S', $data;
### $num_devices
my $pos = 32;
my @ret;
foreach (1 .. $num_devices) {
### $pos
### data: substr($data,$pos)
my ($deviceid, $use, $attachment, $num_classes, $name_len, $enabled)
= unpack 'SSSSSC', substr ($data, $pos);
$pos += 12;
### $deviceid
### $use
### $attachment
### $num_classes
### $name_len
### $enabled
my $name = substr ($data, $pos, $name_len);
$pos += $name_len + X11::Protocol::padding($name_len);
### $name
my @classes;
foreach (1 .. $num_classes) {
my ($type, $class_len, $sourceid, $num_whatever)
= unpack 'SSSS', substr($data,$pos);
$pos += $class_len*4;
### $type
### $class_len
### $sourceid
### $num_whatever
push @classes, [ $X->interp('XIClass', $type),
$sourceid ];
}
push @ret, [ $deviceid,
$X->interp('XIDeviceUse',$use),
$attachment,
$enabled,
$name,
\@classes ];
}
return @ret;
}],
['XISetFocus', # 49
sub {
my ($X, $window, $deviceid, $time) = @_;
return pack 'LLSxx', _num_none($window), _num_time($time), $deviceid;
} ],
['XIGetFocus', # 50
sub {
my ($X, $deviceid) = @_;
return pack 'Sxx', $deviceid;
},
sub {
my ($X, $data) = @_;
return unpack 'L', $data;
} ],
undef, # XIGrabDevice 51
undef, # XIUngrabDevice 52
['XIAllowEvents', # 53
sub {
my ($X, $deviceid, $mode, $time) = @_; # per $X->AllowEvents() arg order
return pack 'LSCx',
_num_time($time),
$deviceid,
$X->num('AllowEventsMode',$mode);
} ],
undef, # XIPassiveGrabDevice 54
undef, # XIPassiveUngrabDevice 55
undef, # XIListProperties 56
undef, # XIChangeProperty 57
undef, # XIDeleteProperty 58
undef, # XIGetProperty 59
['XIGetSelectedEvents', # 60
\&_request_xids,
sub {
my ($X, $data) = @_;
# pairs of
# uint16_t deviceid; /**< Device id to select for */
# uint16_t mask_len; /**< Length of mask in 4 byte units */
my ($num_masks) = unpack 'x8S', $data;
my @ret;
my $pos = 12;
foreach (1 .. $num_masks) {
my ($deviceid, $mask_len) = unpack 'SS', substr ($data, $pos);
$pos += 4;
my $mask = substr ($data, $pos, $mask_len); # FIXME ... numize bytes
$pos += $mask_len;
push @ret, $deviceid, $mask;
}
return @ret;
}],
];
sub _num_none {
my ($xid) = @_;
if (defined $xid && $xid eq "None") {
return 0;
} else {
return $xid;
}
}
sub _num_time {
my ($time) = @_;
if (defined $time && $time eq "CurrentTime") {
return 0;
} else {
return $time;
}
}
sub _request_empty {
# ($X)
if (@_ > 1) {
croak "No parameters in this request";
}
return '';
}
sub _request_xids {
my $X = shift;
### _request_xids(): @_
return _request_card32s ($X, map {_num_none($_)} @_);
}
sub _request_card32s {
shift;
### _request_card32s(): @_
return pack 'L*', @_;
}
sub new {
my ($class, $X, $request_num, $event_num, $error_num) = @_;
### XInputExtension new() ...
# Constants
%{$X->{'ext_const'}} = (%{$X->{'ext_const'} ||= {}}, %const_arrays);
%{$X->{'ext_const_num'}} = (%{$X->{'ext_const_num'} ||= {}}, %const_hashes);
# Errors
_ext_const_error_install ($X, $error_num,
'Device', # 0
'Event', # 1
'XIMode', # 2
'DeviceBusy', # 3
'XIClass'); # 4
# Requests
_ext_requests_install ($X, $request_num, $reqs);
return bless { }, $class;
}
sub _ext_requests_install {
my ($X, $request_num, $reqs) = @_;
$X->{'ext_request'}->{$request_num} = $reqs;
my $href = $X->{'ext_request_num'};
my $i;
foreach $i (0 .. $#$reqs) {
if (defined $reqs->[$i]) {
$href->{$reqs->[$i]->[0]} = [$request_num, $i];
}
}
}
sub _ext_const_error_install {
my $X = shift; # ($X, $errname1,$errname2,...)
### _ext_const_error_install: @_
my $error_num = shift;
my $aref = $X->{'ext_const'}{'Error'} # copy
= [ @{$X->{'ext_const'}{'Error'} || []} ];
my $href = $X->{'ext_const_num'}{'Error'} # copy
= { %{$X->{'ext_const_num'}{'Error'} || {}} };
my $i;
foreach $i (0 .. $#_) {
$aref->[$error_num + $i] = $_[$i];
$href->{$_[$i]} = $error_num + $i;
}
}
### XInputExtension loaded ...
1;
__END__
=for stopwords XID Ryde
=head1 NAME
X11::Protocol::Ext::XInputExtension - input devices beyond keyboard and pointer
=head1 SYNOPSIS
use X11::Protocol;
my $X = X11::Protocol->new;
$X->init_extension('XInputExtension')
or print "XInputExtension not available";
=head1 DESCRIPTION
The XInputExtension extension ...
=head1 REQUESTS
The following requests are made available with an C, as
per L.
my $is_available = $X->init_extension('XInputExtension');
=head1 XInputExtension 1.5
=over
=item C<$X-EXIAllowDeviceEvents ($deviceid, $event_mode, $time)>
Release some events frozen by a grab on C<$deviceid>. C<$event_mode> can be
"AsyncThisDevice" 0
"SyncThisDevice" 1
"ReplayThisdevice" 2
"AsyncOtherDevices" 3
"AsyncAll" 4
"SyncAll" 5
C<$time> is a server timestamp, or "CurrentTime". If C<$time> is before the
last grab then C is ignored.
=item C<$X-EXIDeviceBell ($deviceid, $feedback_class, $feedback_id, $percent)>
Sound the device bell, in a style similar to the core C.
C<$feedback_class> and C<$feedback_id> identify which bell to ring.
C<$percent> is -100 to +100 relative to the base volume of the bell.
-100 0 +100 $percent
|-----------base----|
0 100 volume used
Percent 0 means the base volume. Positive percent 0 to 100 means a volume
proportionally from base up to 100% volume. Negative percent -100 to 0
means a volume proportionally from 0% (silent) up to the base volume.
percent <= 0 volume = base * (percent+100)/100
so percent=-100 to 0 is volume=0 to base
percent >= 0 volume = base + percent*(100 - base)/100
so percent=0 to +100 is volume=base to 100
=cut
# when percent>=0
# volume = base - [(base * percent) / 100] + percent
# = base + percent - (base*percent)/100
# = base + percent*(1 - base/100)
# = base + percent*(100 - base)/100
=pod
=back
=head1 XInputExtension 2.0
=over
=item C<($server_major, $server_minor) = $X-EXIQueryVersion ($client_major, $client_minor)>
Negotiate a protocol version with the server. C<$client_major> and
C<$client_minor> is what the client would like. The returned
C<$server_major> and C<$server_minor> is what the server will do.
C<$client_major> must be 2 or more or a C error results.
=back
=head1 SEE ALSO
L
F,
F
=head1 HOME PAGE
L
=head1 LICENSE
Copyright 2011, 2012, 2013 Kevin Ryde
X11-Protocol-Other is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any later
version.
X11-Protocol-Other is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
X11-Protocol-Other. If not, see .
=cut
X11-Protocol-Other-28/devel/lib/X11/Protocol/Ext/RANDR.pm 0000644 0001750 0001750 00000037303 12235642702 020304 0 ustar gg gg # pack bits for rotate+reflect ?
# RRSetScreenSize() update millimetres in $X ?
# RRGetScreenInfo not right
# Copyright 2011, 2012, 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
BEGIN { require 5 }
package X11::Protocol::Ext::RANDR;
use strict;
use Carp;
use X11::Protocol;
use vars '$VERSION', '@CARP_NOT';
$VERSION = 28;
@CARP_NOT = ('X11::Protocol');
# uncomment this to run the ### lines
use Smart::Comments;
# /usr/share/doc/x11proto-randr-dev/randrproto.txt.gz
# /so/xorg/xorg-server-1.10.0/randr/rrscreen.c
#
# /usr/include/X11/extensions/randr.h
# /usr/include/X11/extensions/randrproto.h
#
# /usr/include/X11/extensions/Xrandr.h
# Xlib
#
# /usr/share/doc/x11proto-core-dev/x11protocol.txt.gz
#
# these not documented yet ...
use constant CLIENT_MAJOR_VERSION => 1;
use constant CLIENT_MINOR_VERSION => 2;
#------------------------------------------------------------------------------
# symbolic constants
my %const_arrays
= (
RRState => ['NewValue', 'Deleted'],
RRNotifySubtype => ['CrtcChangeNotify',
'OutputChangeNotify',
'OutputPropertyNotify'],
RRSubPixel => ['Unknown',
'HorizontalRGB',
'HorizontalBGR',
'VerticalRGB',
'VerticalBGR',
'None'],
);
my %const_hashes
= (map { $_ => { X11::Protocol::make_num_hash($const_arrays{$_}) } }
keys %const_arrays);
#------------------------------------------------------------------------------
# events
my $RRScreenChangeNotify_event
= [ 'xCxxLLLLSSSSS',
'rotation',
'time',
'config_time',
'root',
'window',
'size_id',
['subpixel','RRSubPixel'],
'width',
'height',
'width_mm',
'height_mm',
];
# version 1.2
my $RRNotify_event
= [ sub {
my $X = shift;
my $data = shift;
### RRNotify unpack: @_[1..$#_]
my $subtype = unpack 'xC', $data;
push @_, subtype => $X->interp('RRNotifySubtype',$subtype);
if ($subtype == 0) {
# CrtcChange
my ($time, $window, $crtc, $mode, $rotation, $x,$y, $width,$height)
= unpack 'xxxxLLLLSxxssSS';
return (@_, # base fields
time => $time,
window => $window,
crtc => $crtc,
mode => $mode,
rotation => $rotation,
x => $x,
y => $y,
width => $width,
height => $height,
);
} elsif ($subtype == 1) {
# OutputChange
my ($time, $config_time, $window, $output, $crtc, $mode,
$rotation, $connection, $subpixel)
= unpack 'xxxxLLLLLLSCC';
return (@_, # base fields
time => $time,
config_time => $config_time,
window => $window,
crtc => $crtc,
mode => $mode,
rotation => $rotation,
connection => $connection,
subpixel => $X->interp('RRSubPixel',$subpixel),
);
} elsif ($subtype == 2) {
# OutputProperty
my ($window, $output, $atom, $time, $state)
= unpack 'xxxxLLLLC';
return (@_, # base fields
window => $window,
output => $output,
atom => $atom,
time => $time,
state => $X->interp('RRState',$state),
);
}
},
sub {
my ($X, %h) = @_;
my $subtype = $X->num('RRNotifySubtype',$h{'subtype'});
my $data;
if ($subtype eq '0') {
# CrtcChange
$data = pack('xCxxLLLLSxxssSS',
$subtype,
$h{'time'},
$h{'window'},
$h{'crtc'},
$h{'mode'},
$h{'rotation'},
$h{'x'},
$h{'y'},
$h{'width'},
$h{'height'});
} elsif ($subtype eq '1') {
# OutputChange
$data = pack('xCxxLLLLLLSCC',
$subtype,
$h{'time'},
$h{'config_time'},
$h{'window'},
$h{'output'},
$h{'crtc'},
$h{'mode'},
$h{'rotation'},
$h{'connection'},
$X->num('RRSubPixel',$h{'subpixel'}));
} elsif ($subtype eq '2') {
# OutputProperty
$data = pack('xCxxLLLLCx11',
$subtype,
$h{'window'},
$h{'output'},
$h{'atom'},
$h{'time'},
$X->num('RRState',$h{'state'}));
} else {
croak "Unrecognised RRNotify subtype $subtype";
}
return ($data,
1); # "do_seq" put in sequence number
} ];
#------------------------------------------------------------------------------
# requests
my $reqs =
[
['RRQueryVersion', # 0
\&_request_card32s, # ($X, $client_major, $client_minor)
sub {
my ($X, $data) = @_;
my ($server_major, $server_minor) = unpack 'x8LL', $data;
### $server_major
### $server_minor
my $self;
if ($self = $self->{'ext'}{'RANDR'}->[3]) {
$self->{'major'} = $server_major;
$self->{'minor'} = $server_minor;
$self->{'protocol_11up'}
= (($server_major <=> 1 || $server_minor <=> 1) >= 0);
}
return ($server_major, $server_minor);
}],
undef, # 1 - OldGetScreenInfo
['RRSetScreenConfig', # 2
sub {
my $X = shift; # ($window, $time, $config_time, $size, $rotation, $rate)
my $self = $X->{'ext'}{'RANDR'}->[3];
return pack(($self->{'protocol_11up'} ? 'LLLSSSxx' : 'LLLSS'),
@_);
},
sub {
my ($X, $data) = @_;
my ($config_status, @rest) # $time, $config_time, $root, $subpixel
= unpack 'xC8LL', $data;
return ($X->interp('RRConfigStatus',$config_status),
@rest
# $time,
# $config_time,
# $root,
# $subpixel);
);
}],
undef, # 3 - OldScreenChangeSelectInput
['RRSelectInput', # 4
sub {
shift; # ($X, $window, $enable)
return pack 'LSxx', @_;
}],
['RRGetScreenInfo', # 5
\&_request_xids,
sub {
my ($X, $data) = @_;
use Data::HexDump::XXD;
print scalar(Data::HexDump::XXD::xxd($data));
print "\n";
my ($rotations,
$root, $time, $config_time,
$num_sizes, $size, $rotation, $rate, $num_rates)
= unpack 'xCx6L3S5', $data;
### $num_sizes
### $num_rates
my $pos = 32;
my @sizes;
foreach (1 .. $num_sizes) {
push @sizes, [ unpack 'S4', substr ($data, $pos, 8) ];
$pos += 8;
}
### rates pos: $pos, sprintf '%#X',$pos
my @rates;
foreach (1 .. $num_sizes) {
my $num_rates = unpack 'S', substr($data,$pos,2);
$pos += 2;
push @rates, [ unpack 'S*', substr($data,$pos,2*$num_rates) ];
}
return (rotations => $rotations,
root => $root,
time => $time,
config_time => $config_time,
size => $size,
rotation => $rotation,
rate => $rate,
sizes => \@sizes,
rates => \@rates,
);
}],
#---------------------------------------------------------------------------
# version 1.2
['RRGetScreenSizeRange', # 6
\&_request_xids,
sub {
my ($X, $data) = @_;
return unpack 'x8S4', $data;
}],
['RRSetScreenSize', # 7
sub {
shift; # ($X, $window, $width,$height, $width_mm,$height_mm)
return pack 'LSSLL', @_;
}],
# RRGetScreenResources 8
# RRGetOutputInfo 9
# RRListOutputProperties 10
# RRQueryOutputProperty 11
# RRConfigureOutputProperty 12
# RRChangeOutputProperty 13
# RRDeleteOutputProperty 14
# RRGetOutputProperty 15
# RRCreateMode 16
# RRDestroyMode 17
# RRAddOutputMode 18
# RRDeleteOutputMode 19
# RRGetCrtcInfo 20
# RRSetCrtcConfig 21
# RRGetCrtcGammaSize 22
# RRGetCrtcGamma 23
# RRSetCrtcGamma 24
#
# version 1.3
#
# RRGetScreenResourcesCurrent 25
# RRSetCrtcTransform 26
# RRGetCrtcTransform 27
['RRGetPanning', # 28
\&_request_card32s, # ($X, $crtc)
sub {
my ($X, $data) = @_;
my @ret = unpack 'xCx6LS8s4', $data;
$ret[0] = $X->interp('RRConfigStatus',$ret[0]); # $config_status
return @ret;
}],
# ($config_status,
# $timestamp,
# $left,
# $top,
# $width,
# $height,
# $track_left,
# $track_top,
# $track_width,
# $track_height,
# $border_left,
# $border_top,
# $border_right,
# $border_bottom) = $X->RRGetPanning
['RRSetPanning', # 29
sub {
shift; # ($X, ...)
return pack 'L2S8s4', @_;
},
sub {
my ($X, $data) = @_;
my ($config_status, $time) = unpack 'xCx6L', $data;
return ($X->interp('RRConfigStatus',$config_status),
$time);
}],
# RRSetPanning ($crtc,
# $time,
# $left,
# $top,
# $width,
# $height,
# $track_left,
# $track_top,
# $track_width,
# $track_height,
# $border_left,
# $border_top,
# $border_right,
# $border_bottom);
# RRSetOutputPrimary 30
# RRGetOutputPrimary 31
];
sub _request_xids {
my $X = shift;
### _request_xids(): @_
return _request_card32s ($X, map {_num_none($_)} @_);
}
sub _request_card32s {
shift;
### _request_card32s(): @_
return pack 'L*', @_;
}
#------------------------------------------------------------------------------
sub new {
my ($class, $X, $request_num, $event_num, $error_num) = @_;
### RANDR new()
# Constants
%{$X->{'ext_const'}} = (%{$X->{'ext_const'} ||= {}}, %const_arrays);
%{$X->{'ext_const_num'}} = (%{$X->{'ext_const_num'} ||= {}}, %const_hashes);
# Requests
_ext_requests_install ($X, $request_num, $reqs);
my ($server_major, $server_minor)
= $X->req ('RRQueryVersion',
CLIENT_MAJOR_VERSION, CLIENT_MINOR_VERSION);
# Events
$X->{'ext_const'}{'Events'}[$event_num] = 'RRScreenChangeNotify';
$X->{'ext_events'}[$event_num] = $RRScreenChangeNotify_event;
if (($server_major <=> 1 || $server_minor <=> 2) >= 0) {
# protocol version 1.2
$event_num++;
$X->{'ext_const'}{'Events'}[$event_num] = 'RRNotify';
$X->{'ext_events'}[$event_num] = $RRNotify_event;
# Errors
_ext_const_error_install ($X, $error_num, 'Output','Crtc','Mode');
}
return bless { major => $server_major,
minor => $server_minor,
}, $class;
}
sub _num_time {
my ($time) = @_;
if (defined $time && $time eq 'CurrentTime') {
return 0;
} else {
return $time;
}
}
sub _num_none {
my ($xid) = @_;
if (defined $xid && $xid eq "None") {
return 0;
} else {
return $xid;
}
}
sub _ext_requests_install {
my ($X, $request_num, $reqs) = @_;
$X->{'ext_request'}->{$request_num} = $reqs;
my $href = $X->{'ext_request_num'};
my $i;
foreach $i (0 .. $#$reqs) {
if ($reqs->[$i]) {
$href->{$reqs->[$i]->[0]} = [$request_num, $i];
}
}
}
sub _ext_const_error_install {
my $X = shift; # ($X, $errname1,$errname2,...)
### _ext_const_error_install: @_
my $error_num = shift;
my $aref = $X->{'ext_const'}{'Error'} # copy
= [ @{$X->{'ext_const'}{'Error'} || []} ];
my $href = $X->{'ext_const_num'}{'Error'} # copy
= { %{$X->{'ext_const_num'}{'Error'} || {}} };
my $i;
foreach $i (0 .. $#_) {
$aref->[$error_num + $i] = $_[$i];
$href->{$_[$i]} = $error_num + $i;
}
}
sub _event_update_X {
my ($X, %event) = @_;
my $window;
if ($event{'name'} eq 'ConfigureNotify') {
$window = $event{'window'};
} elsif ($event{'name'} eq 'RRScreenChangeNotify') {
my $window = $event{'root'};
} else {
return;
}
my $p;
foreach $p ($X, @{$X->{'screens'}}) {
if ($window == $p->{'root'}) {
$p->{'width_in_pixels'} = $event{'width'};
$p->{'height_in_pixels'} = $event{'height'};
if (exists $event{'width_mm'}) {
$p->{'width_in_millimetres'} = $event{'width_mm'};
$p->{'height_in_millimetres'} = $event{'height_mm'};
}
}
}
}
1;
__END__
=for stopwords RANDR XID Ryde
=head1 NAME
X11::Protocol::Ext::RANDR - screen rotation and reflection
=for test_synopsis
=head1 SYNOPSIS
use X11::Protocol;
my $X = X11::Protocol->new;
$X->init_extension('RANDR')
or print "RANDR extension not available";
$X->RRGetScreenInfo ($X->root);
=head1 DESCRIPTION
The RANDR extension ...
=head1 REQUESTS
The following requests are made available with an C, as
per L.
my $is_available = $X->init_extension('RANDR');
=over
=item C<($server_major, $server_minor) = $X-ERRQueryVersion ($client_major, $client_minor)>
Negotiate a protocol version with the server. C<$client_major> and
C<$client_minor> is what the client would like. The returned
C<$server_major> and C<$server_minor> is what the server will do.
The current code supports up to 1.0. The intention is to automatically
negotiate in C if/when necessary.
=back
=head2 Version 1.2
=item C<($min_width,$min_height, $max_width,$max_height) = $X-ERRGetScreenSizeRange ($window)>
Return the minimum and maximum size in pixels of the screen of C<$window>
(an XID).
=item C<$X-ERRSetScreenSize ($window, $width,$height, $width_mm,$height_mm)>
Set the size of the screen of C<$window> (an XID). C<$width>,C<$height> is
the size in pixels. C<$width_mm>,C<$height_mm> is the size in millimetres.
=back
=head1 SEE ALSO
L,
L
=head1 HOME PAGE
L
=head1 LICENSE
Copyright 2011, 2012, 2013 Kevin Ryde
X11-Protocol-Other is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any later
version.
X11-Protocol-Other is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
X11-Protocol-Other. If not, see .
=cut
X11-Protocol-Other-28/devel/lib/X11/Protocol/Ext/SYNC.pm 0000644 0001750 0001750 00000077730 12235642702 020222 0 ustar gg gg # Copyright 2011, 2012, 2013 Kevin Ryde
# This file is part of X11-Protocol-Other.
#
# X11-Protocol-Other is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# X11-Protocol-Other is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with X11-Protocol-Other. If not, see .
BEGIN { require 5 }
package X11::Protocol::Ext::SYNC;
use strict;
use Carp;
use X11::Protocol;
use vars '$VERSION', '@CARP_NOT';
$VERSION = 28;
@CARP_NOT = ('X11::Protocol');
# uncomment this to run the ### lines
# use Smart::Comments;
# /usr/share/doc/x11proto-core-dev/x11protocol.txt.gz
#
# SYNC 3.1
# /usr/share/doc/x11proto-xext-dev/sync.txt.gz
#
# /usr/include/X11/extensions/syncproto.h
# /usr/include/X11/extensions/syncconst.h
# /usr/include/X11/extensions/syncstr.h
#
# /usr/include/X11/extensions/sync.h
# /usr/share/X11/doc/hardcopy/Xext/synclib.PS.gz
# /so/xorg/libXext-1.2.0/src/XSync.c
# /so/xorg/libXext-1.2.0/specs/synclib.xml
# Xlib
# /usr/share/xcb/sync.xml
# xcb
#
# /so/xorg/xorg-server-1.10.0/Xext/sync.c
# server source
#
# X11R7.6 SYNC 3.0, no Fence
# /so/xorg/sync-3.0/sync.txt
# /so/x11r6.4/xc/include/extensions/sync.h
# /so/x11r6.4/xc/include/extensions/syncstr.h
# /so/x11r6.4/xc/programs/Xserver/Xext/sync.c
#
# /so/xfree/xfree86-3.3.2.3a/include/extensions/sync.h
# /so/xfree/xfree86-3.3.2.3a/include/extensions/syncstr.h
# /so/xfree/xfree86-3.3.2.3a/programs/Xserver/Xext/sync.c
#
# /so/x11r2/X.V11R2/lib/X/XSync.c
# Xlib
# these not documented yet ...
use constant CLIENT_MAJOR_VERSION => 3;
use constant CLIENT_MINOR_VERSION => 1;
#------------------------------------------------------------------------------
# symbolic constants
use constant constants_list =>
(
SyncValueType => ['Absolute', 'Relative' ],
SyncTestType => [ 'PositiveTransition','NegativeTransition',
'PositiveComparison','NegativeComparison' ],
SyncAlarmState => ['Active', 'Inactive', 'Destroyed' ],
);
sub _ext_constants_install {
my ($X, $constants_arrayref) = @_;
foreach (my $i = 0; $i <= $#$constants_arrayref; $i+=2) {
my $name = $constants_arrayref->[$i];
my $aref = $constants_arrayref->[$i+1];
$X->{'ext_const'}->{$name} = $aref;
$X->{'ext_const_num'}->{$name} = { X11::Protocol::make_num_hash($aref) };
}
}
#------------------------------------------------------------------------------
# events
use constant events_list =>
(SyncCounterNotify =>
[ sub {
my $X = shift;
my $data = shift;
my ($counter,
$wait_value_hi, $wait_value_lo,
$counter_value_hi,$counter_value_lo,
$time,
$count,
$destroyed)
= unpack 'xxxxLLLLLLSCx', $data;
return
(@_,
counter => $counter,
wait_value => _hilo_to_int64($wait_value_hi,$wait_value_lo),
counter_value => _hilo_to_int64($counter_value_hi,$counter_value_lo),
time => _interp_time($time),
count => $count,
destroyed => $destroyed);
},
sub {
my ($X, %h) = @_;
return (pack('xxxxLLLLLLSCx',
$h{'counter'},
_int64_to_hilo($h{'wait_value'}),
_int64_to_hilo($h{'counter_value'}),
_num_time($h{'time'}),
$h{'count'},
$h{'destroyed'}),
1); # "do_seq" put in sequence number
} ],
SyncAlarmNotify =>
[ sub {
my $X = shift;
my $data = shift;
my ($alarm,
$counter_value_hi,$counter_value_lo,
$alarm_value_hi, $alarm_value_lo,
$time,
$state)
= unpack 'xxxxLLLLLLCx3', $data;
return
(@_,
alarm => $alarm,
counter_value => _hilo_to_int64($counter_value_hi,$counter_value_lo),
alarm_value => _hilo_to_int64($alarm_value_hi,$alarm_value_lo),
time => _interp_time($time),
state => $X->interp('SyncAlarmState',$state));
},
sub {
my ($X, %h) = @_;
return (pack('xxxxLLLLLLCx3',
$h{'alarm'},
_int64_to_hilo($h{'counter_value'}),
_int64_to_hilo($h{'alarm_value'}),
_num_time($h{'time'}),
$X->num('SyncAlarmState',$h{'state'})),
1); # "do_seq" put in sequence number
} ],
);
sub _ext_events_install {
my ($X, $event_num, $events_arrayref) = @_;
foreach (my $i = 0; $i <= $#$events_arrayref; $i += 2) {
my $name = $events_arrayref->[$i];
if (defined (my $already = $X->{'ext_const'}->{'Events'}->[$event_num])) {
carp "Event $event_num $already overwritten with $name";
}
$X->{'ext_const'}->{'Events'}->[$event_num] = $name;
$X->{'ext_events'}->[$event_num] = $events_arrayref->[$i+1]; # pack/unpack
$event_num++;
}
}
#------------------------------------------------------------------------------
my $reqs =
[
# Version 3.0
['SyncInitialize', # 0
sub {
my ($X, $major, $minor) = @_;
return pack 'CCxx', $major, $minor;
},
sub {
my ($X, $data) = @_;
return unpack 'x8CC', $data;
} ],
['SyncListSystemCounters', # 1
\&_request_empty,
sub {
my ($X, $data) = @_;
### SyncListSystemCounters reply(): length($data), $data
my ($ncounters) = unpack 'x8L', $data;
### $ncounters
my @ret;
my $pos = 32;
foreach (1 .. $ncounters) {
### at: $pos, substr($data,$pos)
my ($counter, $resolution_hi, $resolution_lo, $name_len)
= unpack 'LlLS', substr($data,$pos,14); # 4+8+2=14
### elem: [ $counter, $resolution_hi, $resolution_lo, $name_len ]
$pos += 14;
my $name = substr ($data, $pos, $name_len);
$pos += $name_len;
$pos += X11::Protocol::padding($pos);
push @ret, [ $counter,
_hilo_to_int64($resolution_hi,$resolution_lo),
$name ];
}
return @ret;
}],
['SyncCreateCounter', # 2
sub {
my ($X, $counter, $initial) = @_;
return pack 'L3', $counter, _int64_to_hilo($initial);
},
],
['SyncSetCounter', # 3
sub {
my ($X, $counter, $value) = @_;
### SyncSetCounter() ...
return pack 'L3', $counter, _int64_to_hilo($value);
},
],
['SyncChangeCounter', # 4
sub {
my ($X, $counter, $value) = @_;
return pack 'L3', $counter, _int64_to_hilo($value);
},
],
['SyncQueryCounter', # 5
\&_request_card32s, # ($X, $counter)
sub {
my ($X, $data) = @_;
return _hilo_to_int64 (unpack 'x8LL', $data);
},
],
['SyncDestroyCounter', # 6
\&_request_card32s, # ($X, $counter)
],
['SyncAwait', # 7
\&_request_empty,
],
['SyncCreateAlarm', # 8
\&_request_alarm_parameters,
],
['SyncChangeAlarm', # 9
\&_request_alarm_parameters,
],
['SyncQueryAlarm', # 10
\&_request_card32s, # ($X, $alarm)
sub {
my ($X, $data) = @_;
### SyncQueryAlarm() reply ...
# use Data::HexDump::XXD;
# print scalar(Data::HexDump::XXD::xxd($data));
# print "\n";
my ($counter, $value_type, $value_hi,$value_lo,
$test_type, $delta_hi,$delta_lo,
$events, $state)
= unpack 'x8L7CC', $data;
return (counter => $counter,
value => _hilo_to_int64($value_hi,$value_lo),
test_type => $X->interp('SyncTestType',$test_type),
value_type => $X->interp('SyncValueType',$value_type),
delta => _hilo_to_int64($delta_hi,$delta_lo),
events => $events,
state => $X->interp('SyncAlarmState',$state));
} ],
['SyncDestroyAlarm', # 11
\&_request_card32s, # ($X, $alarm)
],
['SyncSetPriority', # 12
sub {
my ($X, $xid, $priority) = @_;
return pack 'Ll', _num_none($xid), $priority;
}],
['SyncGetPriority', # 13
\&_request_xids, # ($X, $xid)
sub {
my ($X, $data) = @_;
return unpack 'x8l', $data;
}],
#------------------------
# version 3.1
['SyncCreateFence', # 14
sub {
my ($X, $fence, $drawable, $initially_triggered) = @_;
return pack 'LLCxxx', $drawable, $fence, $initially_triggered;
}],
['SyncTriggerFence', # 15
\&_request_card32s, # ($X, $fence)
],
['SyncResetFence', # 16
\&_request_card32s, # ($X, $fence)
],
['SyncDestroyFence', # 17
\&_request_card32s, # ($X, $fence)
],
['SyncQueryFence', # 18
\&_request_card32s, # ($X, $fence)
sub {
my ($X, $data) = @_;
return unpack 'x8C', $data;
} ],
['SyncAwaitFence', # 19
\&_request_card32s, # ($X, $fence,...)
],
];
{
my @keys = ('counter',
'value_type',
'value',
'test_type',
'delta',
'events');
my %key_to_conversion = (value => \&_int64_to_hilo,
delta => \&_int64_to_hilo);
my %key_to_interp = (value_type => 'SyncValueType',
test_type => 'SyncTestType');
sub _request_alarm_parameters {
my ($X, $alarm, %h) = @_;
my $mask = 0;
my @args;
my $i;
foreach $i (0 .. $#keys) {
my $key = $keys[$i];
next unless exists $h{$key};
my $arg = delete $h{$key};
$mask |= (1 << $i);
if (my $conversion = $key_to_conversion{$key}) {
push @args, &$conversion($arg);
} else {
if (my $interp = $key_to_interp{$key}) {
$arg = $X->num($interp,$arg);
}
push @args, $arg;
}
}
if (%h) {
croak "Unrecognised alarm parameter(s): ",join(',',keys %h);
}
### $mask
### @args
return pack 'L*', $alarm, $mask, @args;
}
}
#------------------------------------------------------------------------------
sub new {
my ($class, $X, $request_num, $event_num, $error_num) = @_;
### Sync new()
my $self = bless { }, $class;
_ext_requests_install ($X, $request_num, $reqs);
_ext_constants_install ($X, [ $self->constants_list ]);
_ext_events_install ($X, $event_num, [ $self->events_list ]);
# SYNC spec says must initialize or behaviour undefined (though for
# example the X.org server doesn't enforce this). Also we want to know
# whether 3.0 or 3.1 so that the Fence error type can be setup or not.
#
my ($major, $minor) = $X->req('SyncInitialize',
CLIENT_MAJOR_VERSION,
CLIENT_MINOR_VERSION);
$self->{'major'} = $major;
$self->{'minor'} = $minor;
# Errors
_ext_const_error_install ($X, $error_num,
'Counter', # 0
'Alarm', # 1
# Fence new in 3.1
(($major <=> 3 || $minor <=> 1) >= 0
? ('Fence') : ())); # 2
return $self;
}
#------------------------------------------------------------------------------
# generic
sub _num_time {
my ($time) = @_;
if (defined $time && $time eq 'CurrentTime') {
return 0;
} else {
return $time;
}
}
sub _interp_time {
my ($time) = @_;
if ($time == 0) {
return 'CurrentTime';
} else {
return $time;
}
}
sub _num_none {
my ($xid) = @_;
if (defined $xid && $xid eq "None") {
return 0;
} else {
return $xid;
}
}
sub _ext_requests_install {
my ($X, $request_num, $reqs) = @_;
$X->{'ext_request'}->{$request_num} = $reqs;
my $href = $X->{'ext_request_num'};
my $i;
foreach $i (0 .. $#$reqs) {
$href->{$reqs->[$i]->[0]} = [$request_num, $i];
}
}
sub _ext_const_error_install {
my $X = shift; # ($X, $errname1,$errname2,...)
### _ext_const_error_install: @_
my $error_num = shift;
my $aref = $X->{'ext_const'}{'Error'} # copy
= [ @{$X->{'ext_const'}{'Error'} || []} ];
my $href = $X->{'ext_const_num'}{'Error'} # copy
= { %{$X->{'ext_const_num'}{'Error'} || {}} };
my $i;
foreach $i (0 .. $#_) {
$aref->[$error_num + $i] = $_[$i];
$href->{$_[$i]} = $error_num + $i;
}
}
sub _request_empty {
# ($X)
if (@_ > 1) {
croak "No parameters in this request";
}
return '';
}
sub _request_card32s {
shift;
### _request_card32s(): @_
return pack 'L*', @_;
}
sub _request_xids {
my $X = shift;
### _request_xids(): @_
return _request_card32s ($X, map {_num_none($_)} @_);
}
#------------------------------------------------------------------------------
# 64-bits
# -2^64 + $hi*2^32 + $lo
# = 2^32 * (-2^32 + $hi) + $lo
#
# -2^64 + $hi*2^32 + $lo
# = -2^64 + ($hi-2^31+2^31)*2^32 + $lo
# = -2^64 + 2^63 + ($hi-2^31)*2^32 + $lo
# = -2^63 + ($hi-2^31)*2^32 + $lo
#
# Crib: "<<" shift operator turns a negative into a positive, so must shift
# $hi as positive then adjust.
use constant _INT_BITS => do {
# In Perl 5.14.2 with -T taint mode, $lo += -(1<<63) becomes an NV not a
# UV making the int64 return lose precision. $lo is tainted by being a
# value read from the server. Not sure what can be relied on for integer
# arithmetic in taint mode, but for now treat it as 32-bit Perl.
# $n = tainted zero. It's assumed there will be something in %ENV which
# is tainted. Normally everything in %ENV is tainted, but it's not
# uncommon to wash $PATH. Could use Taint::Util::taint(), but don't
# really want to demand that module.
my $n = '0' . join ('', map {defined $_ && substr($_,0,0)} values %ENV);
my $bits = 0;
for (;;) {
$bits++;
$n *= 2;
my $n2 = $n;
$n += 1;
if ($n <= $n2 || $n >= $n2 + 2) {
# floating point round-off, stop
last;
}
if ($bits >= 64) {
# enough good bits for our purposes, stop
last;
}
}
### $bits
# Devel::Peek::Dump ($n);
$bits;
};
if (_INT_BITS >= 64) {
### 64-bit UV ...
eval "\n#line ".(__LINE__+1)." \"".__FILE__."\"\n" . <<'HERE' or die;
sub _hilo_to_int64 {
my ($hi,$lo) = @_;
### _hilo_to_int64() ...
### $hi
### $lo
if ($hi & 0x8000_0000) {
$hi -= 0x8000_0000;
$lo += -(1<<63);
### twos-complement negative to ...
### $hi
### $lo
### lo hex: sprintf '%X', $lo
}
### hi shift: $hi<<1
### result: ($hi << 32) + $lo
return ($hi << 32) + $lo;
}
1;
HERE
} else {
### 32-bit UV (or anything less than 64) ...
eval "\n#line ".(__LINE__+1)." \"".__FILE__."\"\n" . <<'HERE' or die;
use Math::BigInt;
sub _hilo_to_int64 {
my ($hi,$lo) = @_;
# print "_hilo_to_int64() hi=$hi lo=$lo\n";
my $ret = Math::BigInt->new("$hi") * (Math::BigInt->new(2) ** 32) + $lo;
if ($hi & 0x8000_0000) {
$ret -= Math::BigInt->new(2) ** 64;
}
### $ret
return $ret;
}
1;
HERE
}
# NV floats are converted to UV for bitwise ">>" or "&", which would lose
# some of the mantissa if UV==32bits, so use "%".
#
# Divisor 2^32 would be an NV float if UV==32bits, so do two divisions by
# 65536.
#
# Math::BigInt in perl 5.6.0 has a bug in the division where it mis-handles
# the sign of the dividend, giving for example -16 div 8 = -1 rem +7, where
# it should be -2 rem +1 (or perhaps -1 rem -7 if a negative remainder).
# Avoid that by making $sv positive and bit-invert the resulting $hi,$lo.
#
# For reference, Math::BigInt in perl 5.6.0 had int() returning a plain
# string, not a BigInt object, so avoid that.
#
sub _int64_to_hilo {
my ($sv) = @_;
### _int64_to_hilo(): $sv
# print "_int64_to_hilo() sv=$sv ",(ref $sv || '[plain scalar]'),"\n";
my $xor = 0;
if ($sv < 0) {
$sv = -1 - $sv;
$xor = 0xFFFF;
}
($sv, my $lo) = _divrem($sv,65536);
$lo ^= $xor;
($sv, my $lo2) = _divrem($sv,65536);
$lo2 ^= $xor;
$lo += 65536*$lo2;
($sv, my $hi) = _divrem($sv,65536);
$hi ^= $xor;
($sv, my $hi2) = _divrem($sv,65536);
$hi2 ^= $xor;
$hi += 65536*$hi2;
### $hi
### $lo
return ($hi, $lo)
}
sub _divrem {
my ($n, $d) = @_;
my $rem = $n % $d;
return (($n-$rem)/$d, $rem);
}
1;
__END__
=for stopwords SYNC XID Ryde Pre-defined SERVERTIME timestamp IDLETIME BigInts arrayref ie unsatisfy untriggered XIDs builtin ENUM SyncValueType SyncTestType SyncAlarmState
=head1 NAME
X11::Protocol::Ext::SYNC - inter-client synchronization
=head1 SYNOPSIS
use X11::Protocol;
my $X = X11::Protocol->new;
$X->init_extension('SYNC')
or print "SYNC extension not available";
=head1 DESCRIPTION
The SYNC extension adds
=over
=item *
Counter objects, counting in 64-bits client controlled or server builtin.
=item *
Alarm objects to receive events for counter values.
=item *
Priority level for clients.
=item *
Fence objects triggered by completion of screen rendering. New in SYNC
version 3.1.
=back
Counters and alarms allow multiple clients to synchronize their actions.
One client can create a counter and increment it. Other clients can block
or receive events for desired target values.
Counter values are INT64 signed 64-bit integers, so -2^63 to +2^63-1
inclusive. On a 64-bit Perl these values are returned as plain integers.
On a 32-bit Perl they're returned as C objects. For requests
values can be given as either integers, floating point, or BigInts.
=head2 Client Counters
Client counters are changed by C or C
requests. The meaning of a counter value and when and by how much it
changes is entirely up to client programs.
Client counters do not wrap-around. If an increment overflows the -2^63 to
+2^63-1 range then a C results, or alarms becomes Inactive when
adding their C overflows the INT64 range.
=head2 System Counters
Pre-defined system counters are controlled by the server. As of SYNC
specification 3.1 the only system counter always available is "SERVERTIME".
A particular server might have more.
=over
=item "SERVERTIME"
The server timestamp in milliseconds. This is per the C