Dawn of a new world

This commit is contained in:
Lauri Kasanen 2013-11-30 15:51:10 +02:00
commit 5971d63df6
319 changed files with 138294 additions and 0 deletions

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
Makefile
Makefile.in
.deps
.libs
.msg
*.lo
*.la
*.a
*.o
*~
aclocal.m4
autom4te.cache
m4/lt*m4
m4/libtool.m4
compile
config.guess
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
missing
xorg-server.pc
stamp-h?
do-not-use-config.h
do-not-use-config.h.in
kdrive/fbdev/Xfbdev
kdrive/vesa/Xvesa
include/dix-config.h
include/kdrive-config.h
include/xkb-config.h
ylwrap
err
*rig
*rej

675
COPYING Normal file
View File

@ -0,0 +1,675 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
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.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 <http://www.gnu.org/licenses/>.
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:
<program> Copyright (C) <year> <name of author>
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
<http://www.gnu.org/licenses/>.
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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

35
Makefile.am Normal file
View File

@ -0,0 +1,35 @@
ACLOCAL_AMFLAGS=-I m4
if DBE
DBE_DIR=dbe
endif
SUBDIRS = \
include \
dix \
fb \
mi \
Xext \
miext \
os \
randr \
render \
$(DBE_DIR) \
xfixes \
damageext \
kdrive
DIST_SUBDIRS = \
include \
dix \
fb \
mi \
Xext \
miext \
os \
randr \
render \
dbe \
xfixes \
damageext \
kdrive

43
README Normal file
View File

@ -0,0 +1,43 @@
Necromancy
==========
We resurrected Xvesa from the depths of git history, and intend to maintain it with Xfbdev.
This includes bugfixes, security fixes, and occasional new features if required.
Why?
----
The TinyX servers fill our needs while being a lot smaller than Xorg can be made.
Why 1.2.0 and not 1.3.0?
------------------------
As you know, Xvesa was killed in 1.4.0, so the latest released version would be 1.3.0.
However, they broke all input in 1.3.0 (keyboard and mouse), so the last working released
version is 1.2.0.
There were also some changes later on that we disagree with (mandatory xinput & xkb).
Design choices
--------------
We aim for the smallest fully featured X server binary. Currently there are the vesa and
fbdev servers, but others may appear in the future (Xmodesetting?).
- no xkb; it's bloat when console keymaps suffice
- no xinput
- no xinerama
- no gl
- TCP listening disabled by default, shadow FB enabled by default
...
Licensing
---------
While the original codebase is MIT, any changes here are GPLv3. Supporting closed devices
with this code is not a goal.

65
Xext/Makefile.am Normal file
View File

@ -0,0 +1,65 @@
# libXext.la: includes all extensions and should be linked into Xvfb,
# Xnest, Xdmx and Xprt
# libXextbuiltin.la: includes those extensions that are built directly into
# Xorg by default
# libXextmodule.la: includes those extensions that are built into a module
# that Xorg loads
noinst_LTLIBRARIES = libXext.la
AM_CFLAGS = $(DIX_CFLAGS)
# Sources always included in libXextbuiltin.la & libXext.la
BUILTIN_SRCS = \
shape.c \
sleepuntil.c \
sleepuntil.h \
xtest.c
# Sources always included in libXextmodule.la & libXext.la
MODULE_SRCS = \
bigreq.c \
shape.c \
sync.c \
xcmisc.c
# Optional sources included if extension enabled by configure.ac rules
# MIT Shared Memory extension
MITSHM_SRCS = shm.c shmint.h
BUILTIN_SRCS += $(MITSHM_SRCS)
# XResource extension: lets clients get data about per-client resource usage
RES_SRCS = xres.c
if RES
MODULE_SRCS += $(RES_SRCS)
endif
# MIT ScreenSaver extension
SCREENSAVER_SRCS = saver.c
if SCREENSAVER
MODULE_SRCS += $(SCREENSAVER_SRCS)
endif
# XF86 Big Font extension
BIGFONT_SRCS = xf86bigfont.c xf86bigfontsrv.h
if XF86BIGFONT
BUILTIN_SRCS += $(BIGFONT_SRCS)
endif
# DPMS extension
DPMS_SRCS = dpms.c dpmsproc.h
if DPMSExtension
MODULE_SRCS += $(DPMS_SRCS)
endif
# Now take all of the above, mix well, bake for 10 minutes and get libXext*.la
libXext_la_SOURCES = $(BUILTIN_SRCS) $(MODULE_SRCS)
EXTRA_DIST = \
$(MITSHM_SRCS) \
$(RES_SRCS) \
$(SCREENSAVER_SRCS) \
$(BIGFONT_SRCS) \
$(DPMS_SRCS)

101
Xext/bigreq.c Normal file
View File

@ -0,0 +1,101 @@
/*
Copyright 1992, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include <X11/extensions/bigreqsproto.h>
#include "opaque.h"
#include "extinit.h"
#if 0
static unsigned char XBigReqCode;
#endif
static void BigReqResetProc(ExtensionEntry * /* extEntry */
);
static DISPATCH_PROC(ProcBigReqDispatch);
void
BigReqExtensionInit(INITARGS)
{
#if 0
ExtensionEntry *extEntry;
if ((extEntry = AddExtension(XBigReqExtensionName, 0, 0,
ProcBigReqDispatch, ProcBigReqDispatch,
BigReqResetProc, StandardMinorOpcode)) != 0)
XBigReqCode = (unsigned char) extEntry->base;
#else
(void) AddExtension(XBigReqExtensionName, 0, 0,
ProcBigReqDispatch, ProcBigReqDispatch,
BigReqResetProc, StandardMinorOpcode);
#endif
DeclareExtensionSecurity(XBigReqExtensionName, TRUE);
}
/*ARGSUSED*/ static void
BigReqResetProc(extEntry)
ExtensionEntry *extEntry;
{
}
static int
ProcBigReqDispatch(client)
ClientPtr client;
{
REQUEST(xBigReqEnableReq);
xBigReqEnableReply rep = {0};
if (client->swapped) {
swaps(&stuff->length);
}
if (stuff->brReqType != X_BigReqEnable)
return BadRequest;
REQUEST_SIZE_MATCH(xBigReqEnableReq);
client->big_requests = TRUE;
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.max_request_size = maxBigRequestSize;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.max_request_size);
}
WriteToClient(client, sizeof(xBigReqEnableReply), (char *) &rep);
return (client->noClientException);
}

453
Xext/dpms.c Normal file
View File

@ -0,0 +1,453 @@
/*****************************************************************
Copyright (c) 1996 Digital Equipment Corporation, Maynard, Massachusetts.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Digital Equipment Corporation
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from Digital
Equipment Corporation.
******************************************************************/
/*
* HISTORY
*
* @(#)RCSfile: dpms.c,v Revision: 1.1.4.5 (DEC) Date: 1996/03/04 15:27:00
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include "opaque.h"
#define DPMS_SERVER
#include <X11/extensions/dpms.h>
#include <X11/extensions/dpmsproto.h>
#include "dpmsproc.h"
#include "extinit.h"
#if 0
static unsigned char DPMSCode;
#endif
static DISPATCH_PROC(ProcDPMSDispatch);
static DISPATCH_PROC(SProcDPMSDispatch);
static DISPATCH_PROC(ProcDPMSGetVersion);
static DISPATCH_PROC(SProcDPMSGetVersion);
static DISPATCH_PROC(ProcDPMSGetTimeouts);
static DISPATCH_PROC(SProcDPMSGetTimeouts);
static DISPATCH_PROC(ProcDPMSSetTimeouts);
static DISPATCH_PROC(SProcDPMSSetTimeouts);
static DISPATCH_PROC(ProcDPMSEnable);
static DISPATCH_PROC(SProcDPMSEnable);
static DISPATCH_PROC(ProcDPMSDisable);
static DISPATCH_PROC(SProcDPMSDisable);
static DISPATCH_PROC(ProcDPMSForceLevel);
static DISPATCH_PROC(SProcDPMSForceLevel);
static DISPATCH_PROC(ProcDPMSInfo);
static DISPATCH_PROC(SProcDPMSInfo);
static DISPATCH_PROC(ProcDPMSCapable);
static DISPATCH_PROC(SProcDPMSCapable);
static void DPMSResetProc(ExtensionEntry * extEntry);
void
DPMSExtensionInit(INITARGS)
{
#if 0
ExtensionEntry *extEntry;
if ((extEntry = AddExtension(DPMSExtensionName, 0, 0,
ProcDPMSDispatch, SProcDPMSDispatch,
DPMSResetProc, StandardMinorOpcode)))
DPMSCode = (unsigned char) extEntry->base;
#else
(void) AddExtension(DPMSExtensionName, 0, 0,
ProcDPMSDispatch, SProcDPMSDispatch,
DPMSResetProc, StandardMinorOpcode);
#endif
}
/*ARGSUSED*/ static void
DPMSResetProc(extEntry)
ExtensionEntry *extEntry;
{
}
static int
ProcDPMSGetVersion(client)
ClientPtr client;
{
/* REQUEST(xDPMSGetVersionReq); */
xDPMSGetVersionReply rep;
REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = DPMSMajorVersion;
rep.minorVersion = DPMSMinorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
WriteToClient(client, sizeof(xDPMSGetVersionReply), (char *) &rep);
return (client->noClientException);
}
static int
ProcDPMSCapable(register ClientPtr client)
{
/* REQUEST(xDPMSCapableReq); */
xDPMSCapableReply rep;
REQUEST_SIZE_MATCH(xDPMSCapableReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.capable = DPMSCapableFlag;
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
WriteToClient(client, sizeof(xDPMSCapableReply), (char *) &rep);
return (client->noClientException);
}
static int
ProcDPMSGetTimeouts(client)
ClientPtr client;
{
/* REQUEST(xDPMSGetTimeoutsReq); */
xDPMSGetTimeoutsReply rep;
REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.standby = DPMSStandbyTime / MILLI_PER_SECOND;
rep.suspend = DPMSSuspendTime / MILLI_PER_SECOND;
rep.off = DPMSOffTime / MILLI_PER_SECOND;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.standby);
swaps(&rep.suspend);
swaps(&rep.off);
}
WriteToClient(client, sizeof(xDPMSGetTimeoutsReply), (char *) &rep);
return (client->noClientException);
}
static int
ProcDPMSSetTimeouts(client)
ClientPtr client;
{
REQUEST(xDPMSSetTimeoutsReq);
REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
if ((stuff->off != 0) && (stuff->off < stuff->suspend)) {
client->errorValue = stuff->off;
return BadValue;
}
if ((stuff->suspend != 0) && (stuff->suspend < stuff->standby)) {
client->errorValue = stuff->suspend;
return BadValue;
}
DPMSStandbyTime = stuff->standby * MILLI_PER_SECOND;
DPMSSuspendTime = stuff->suspend * MILLI_PER_SECOND;
DPMSOffTime = stuff->off * MILLI_PER_SECOND;
SetScreenSaverTimer();
return (client->noClientException);
}
static int
ProcDPMSEnable(client)
ClientPtr client;
{
/* REQUEST(xDPMSEnableReq); */
REQUEST_SIZE_MATCH(xDPMSEnableReq);
if (DPMSCapableFlag)
DPMSEnabled = TRUE;
return (client->noClientException);
}
static int
ProcDPMSDisable(client)
ClientPtr client;
{
/* REQUEST(xDPMSDisableReq); */
REQUEST_SIZE_MATCH(xDPMSDisableReq);
DPMSSet(DPMSModeOn);
DPMSEnabled = FALSE;
return (client->noClientException);
}
static int
ProcDPMSForceLevel(client)
ClientPtr client;
{
REQUEST(xDPMSForceLevelReq);
REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
if (!DPMSEnabled)
return BadMatch;
if (stuff->level == DPMSModeOn) {
lastDeviceEventTime.milliseconds = GetTimeInMillis();
}
else if (stuff->level == DPMSModeStandby) {
lastDeviceEventTime.milliseconds = GetTimeInMillis() - DPMSStandbyTime;
}
else if (stuff->level == DPMSModeSuspend) {
lastDeviceEventTime.milliseconds = GetTimeInMillis() - DPMSSuspendTime;
}
else if (stuff->level == DPMSModeOff) {
lastDeviceEventTime.milliseconds = GetTimeInMillis() - DPMSOffTime;
}
else {
client->errorValue = stuff->level;
return BadValue;
}
DPMSSet(stuff->level);
return (client->noClientException);
}
static int
ProcDPMSInfo(register ClientPtr client)
{
/* REQUEST(xDPMSInfoReq); */
xDPMSInfoReply rep;
REQUEST_SIZE_MATCH(xDPMSInfoReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.power_level = DPMSPowerLevel;
rep.state = DPMSEnabled;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.power_level);
}
WriteToClient(client, sizeof(xDPMSInfoReply), (char *) &rep);
return (client->noClientException);
}
static int
ProcDPMSDispatch(client)
ClientPtr client;
{
REQUEST(xReq);
switch (stuff->data) {
case X_DPMSGetVersion:
return ProcDPMSGetVersion(client);
case X_DPMSCapable:
return ProcDPMSCapable(client);
case X_DPMSGetTimeouts:
return ProcDPMSGetTimeouts(client);
case X_DPMSSetTimeouts:
return ProcDPMSSetTimeouts(client);
case X_DPMSEnable:
return ProcDPMSEnable(client);
case X_DPMSDisable:
return ProcDPMSDisable(client);
case X_DPMSForceLevel:
return ProcDPMSForceLevel(client);
case X_DPMSInfo:
return ProcDPMSInfo(client);
default:
return BadRequest;
}
}
static int
SProcDPMSGetVersion(client)
ClientPtr client;
{
REQUEST(xDPMSGetVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion);
return ProcDPMSGetVersion(client);
}
static int
SProcDPMSCapable(register ClientPtr client)
{
REQUEST(xDPMSCapableReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSCapableReq);
return ProcDPMSCapable(client);
}
static int
SProcDPMSGetTimeouts(client)
ClientPtr client;
{
REQUEST(xDPMSGetTimeoutsReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq);
return ProcDPMSGetTimeouts(client);
}
static int
SProcDPMSSetTimeouts(client)
ClientPtr client;
{
REQUEST(xDPMSSetTimeoutsReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
swaps(&stuff->standby);
swaps(&stuff->suspend);
swaps(&stuff->off);
return ProcDPMSSetTimeouts(client);
}
static int
SProcDPMSEnable(client)
ClientPtr client;
{
REQUEST(xDPMSEnableReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSEnableReq);
return ProcDPMSEnable(client);
}
static int
SProcDPMSDisable(client)
ClientPtr client;
{
REQUEST(xDPMSDisableReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSDisableReq);
return ProcDPMSDisable(client);
}
static int
SProcDPMSForceLevel(client)
ClientPtr client;
{
REQUEST(xDPMSForceLevelReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
swaps(&stuff->level);
return ProcDPMSForceLevel(client);
}
static int
SProcDPMSInfo(client)
ClientPtr client;
{
REQUEST(xDPMSInfoReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSInfoReq);
return ProcDPMSInfo(client);
}
static int
SProcDPMSDispatch(client)
ClientPtr client;
{
REQUEST(xReq);
switch (stuff->data) {
case X_DPMSGetVersion:
return SProcDPMSGetVersion(client);
case X_DPMSCapable:
return SProcDPMSCapable(client);
case X_DPMSGetTimeouts:
return SProcDPMSGetTimeouts(client);
case X_DPMSSetTimeouts:
return SProcDPMSSetTimeouts(client);
case X_DPMSEnable:
return SProcDPMSEnable(client);
case X_DPMSDisable:
return SProcDPMSDisable(client);
case X_DPMSForceLevel:
return SProcDPMSForceLevel(client);
case X_DPMSInfo:
return SProcDPMSInfo(client);
default:
return BadRequest;
}
}

15
Xext/dpmsproc.h Normal file
View File

@ -0,0 +1,15 @@
/* Prototypes for functions that the DDX must provide */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef _DPMSPROC_H_
#define _DPMSPROC_H_
void DPMSSet(int level);
Bool DPMSSupported(void);
#endif

1427
Xext/saver.c Normal file

File diff suppressed because it is too large Load Diff

1241
Xext/shape.c Normal file

File diff suppressed because it is too large Load Diff

991
Xext/shm.c Normal file
View File

@ -0,0 +1,991 @@
/************************************************************
Copyright 1989, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
********************************************************/
/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */
#define SHM
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <unistd.h>
#include <sys/stat.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "resource.h"
#include "scrnintstr.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "gcstruct.h"
#include "extnsionst.h"
#include "servermd.h"
#define _XSHM_SERVER_
#include <X11/extensions/shmstr.h>
#include <X11/Xfuncproto.h>
#include "extinit.h"
typedef struct _ShmDesc {
struct _ShmDesc *next;
int shmid;
int refcnt;
char *addr;
Bool writable;
unsigned long size;
} ShmDescRec, *ShmDescPtr;
static void miShmPutImage(XSHM_PUT_IMAGE_ARGS);
static void fbShmPutImage(XSHM_PUT_IMAGE_ARGS);
static PixmapPtr fbShmCreatePixmap(XSHM_CREATE_PIXMAP_ARGS);
static int ShmDetachSegment(pointer /* value */ ,
XID /* shmseg */
);
static void ShmResetProc(ExtensionEntry * /* extEntry */
);
static void SShmCompletionEvent(xShmCompletionEvent * /* from */ ,
xShmCompletionEvent * /* to */
);
static Bool ShmDestroyPixmap(PixmapPtr pPixmap);
static DISPATCH_PROC(ProcShmAttach);
static DISPATCH_PROC(ProcShmCreatePixmap);
static DISPATCH_PROC(ProcShmDetach);
static DISPATCH_PROC(ProcShmDispatch);
static DISPATCH_PROC(ProcShmGetImage);
static DISPATCH_PROC(ProcShmPutImage);
static DISPATCH_PROC(ProcShmQueryVersion);
static DISPATCH_PROC(SProcShmAttach);
static DISPATCH_PROC(SProcShmCreatePixmap);
static DISPATCH_PROC(SProcShmDetach);
static DISPATCH_PROC(SProcShmDispatch);
static DISPATCH_PROC(SProcShmGetImage);
static DISPATCH_PROC(SProcShmPutImage);
static DISPATCH_PROC(SProcShmQueryVersion);
static unsigned char ShmReqCode;
_X_EXPORT int ShmCompletionCode;
_X_EXPORT int BadShmSegCode;
_X_EXPORT RESTYPE ShmSegType;
static ShmDescPtr Shmsegs;
static Bool sharedPixmaps;
static int pixmapFormat;
static int shmPixFormat[MAXSCREENS];
static const ShmFuncs * shmFuncs[MAXSCREENS];
static DestroyPixmapProcPtr destroyPixmap[MAXSCREENS];
static int shmPixmapPrivate;
static const ShmFuncs miFuncs = { NULL, miShmPutImage };
static const ShmFuncs fbFuncs = { fbShmCreatePixmap, fbShmPutImage };
#define VERIFY_SHMSEG(shmseg,shmdesc,client) \
{ \
shmdesc = (ShmDescPtr)LookupIDByType(shmseg, ShmSegType); \
if (!shmdesc) \
{ \
client->errorValue = shmseg; \
return BadShmSegCode; \
} \
}
#define VERIFY_SHMPTR(shmseg,offset,needwrite,shmdesc,client) \
{ \
VERIFY_SHMSEG(shmseg, shmdesc, client); \
if ((offset & 3) || (offset > shmdesc->size)) \
{ \
client->errorValue = offset; \
return BadValue; \
} \
if (needwrite && !shmdesc->writable) \
return BadAccess; \
}
#define VERIFY_SHMSIZE(shmdesc,offset,len,client) \
{ \
if ((offset + len) > shmdesc->size) \
{ \
return BadAccess; \
} \
}
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
#include <sys/signal.h>
static Bool badSysCall = FALSE;
static void
SigSysHandler(signo)
int signo;
{
badSysCall = TRUE;
}
static Bool
CheckForShmSyscall()
{
void (*oldHandler) ();
int shmid = -1;
/* If no SHM support in the kernel, the bad syscall will generate SIGSYS */
oldHandler = signal(SIGSYS, SigSysHandler);
badSysCall = FALSE;
shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
if (shmid != -1) {
/* Successful allocation - clean up */
shmctl(shmid, IPC_RMID, (struct shmid_ds *) NULL);
}
else {
/* Allocation failed */
badSysCall = TRUE;
}
signal(SIGSYS, oldHandler);
return (!badSysCall);
}
#define MUST_CHECK_FOR_SHM_SYSCALL
#endif
void
ShmExtensionInit(INITARGS)
{
ExtensionEntry *extEntry;
int i;
#ifdef MUST_CHECK_FOR_SHM_SYSCALL
if (!CheckForShmSyscall()) {
ErrorF("MIT-SHM extension disabled due to lack of kernel support\n");
return;
}
#endif
sharedPixmaps = xFalse;
pixmapFormat = 0;
{
sharedPixmaps = xTrue;
pixmapFormat = shmPixFormat[0];
for (i = 0; i < screenInfo.numScreens; i++) {
if (!shmFuncs[i])
shmFuncs[i] = &miFuncs;
if (!shmFuncs[i]->CreatePixmap)
sharedPixmaps = xFalse;
if (shmPixFormat[i] && (shmPixFormat[i] != pixmapFormat)) {
sharedPixmaps = xFalse;
pixmapFormat = 0;
}
}
if (!pixmapFormat)
pixmapFormat = ZPixmap;
if (sharedPixmaps) {
for (i = 0; i < screenInfo.numScreens; i++) {
destroyPixmap[i] = screenInfo.screens[i]->DestroyPixmap;
screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap;
}
shmPixmapPrivate = AllocatePixmapPrivateIndex();
for (i = 0; i < screenInfo.numScreens; i++) {
if (!AllocatePixmapPrivate(screenInfo.screens[i],
shmPixmapPrivate, 0))
return;
}
}
}
ShmSegType = CreateNewResourceType(ShmDetachSegment);
if (ShmSegType &&
(extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors,
ProcShmDispatch, SProcShmDispatch,
ShmResetProc, StandardMinorOpcode))) {
ShmReqCode = (unsigned char) extEntry->base;
ShmCompletionCode = extEntry->eventBase;
BadShmSegCode = extEntry->errorBase;
EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent;
}
}
/*ARGSUSED*/ static void
ShmResetProc(extEntry)
ExtensionEntry *extEntry;
{
int i;
for (i = 0; i < MAXSCREENS; i++) {
shmFuncs[i] = (ShmFuncsPtr) NULL;
shmPixFormat[i] = 0;
}
}
void
ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs)
{
shmFuncs[pScreen->myNum] = funcs;
}
void
ShmSetPixmapFormat(ScreenPtr pScreen, int format)
{
shmPixFormat[pScreen->myNum] = format;
}
static Bool
ShmDestroyPixmap(PixmapPtr pPixmap)
{
ScreenPtr pScreen = pPixmap->drawable.pScreen;
Bool ret;
if (pPixmap->refcnt == 1) {
ShmDescPtr shmdesc;
shmdesc = (ShmDescPtr) pPixmap->devPrivates[shmPixmapPrivate].ptr;
if (shmdesc)
ShmDetachSegment((pointer) shmdesc, pPixmap->drawable.id);
}
pScreen->DestroyPixmap = destroyPixmap[pScreen->myNum];
ret = (*pScreen->DestroyPixmap) (pPixmap);
destroyPixmap[pScreen->myNum] = pScreen->DestroyPixmap;
pScreen->DestroyPixmap = ShmDestroyPixmap;
return ret;
}
void
ShmRegisterFbFuncs(pScreen)
ScreenPtr pScreen;
{
shmFuncs[pScreen->myNum] = &fbFuncs;
}
static int
ProcShmQueryVersion(client)
ClientPtr client;
{
xShmQueryVersionReply rep;
REQUEST_SIZE_MATCH(xShmQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.sharedPixmaps = sharedPixmaps;
rep.pixmapFormat = pixmapFormat;
rep.majorVersion = SHM_MAJOR_VERSION;
rep.minorVersion = SHM_MINOR_VERSION;
rep.uid = geteuid();
rep.gid = getegid();
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
swaps(&rep.uid);
swaps(&rep.gid);
}
WriteToClient(client, sizeof(xShmQueryVersionReply), (char *) &rep);
return (client->noClientException);
}
/*
* Simulate the access() system call for a shared memory segement,
* using the credentials from the client if available
*/
static int
shm_access(ClientPtr client, struct ipc_perm *perm, int readonly)
{
int uid, gid;
mode_t mask;
if (LocalClientCred(client, &uid, &gid) != -1) {
/* User id 0 always gets access */
if (uid == 0) {
return 0;
}
/* Check the owner */
if (perm->uid == uid || perm->cuid == uid) {
mask = S_IRUSR;
if (!readonly) {
mask |= S_IWUSR;
}
return (perm->mode & mask) == mask ? 0 : -1;
}
/* Check the group */
if (perm->gid == gid || perm->cgid == gid) {
mask = S_IRGRP;
if (!readonly) {
mask |= S_IWGRP;
}
return (perm->mode & mask) == mask ? 0 : -1;
}
}
/* Otherwise, check everyone else */
mask = S_IROTH;
if (!readonly) {
mask |= S_IWOTH;
}
return (perm->mode & mask) == mask ? 0 : -1;
}
static int
ProcShmAttach(client)
ClientPtr client;
{
struct shmid_ds buf;
ShmDescPtr shmdesc;
REQUEST(xShmAttachReq);
REQUEST_SIZE_MATCH(xShmAttachReq);
LEGAL_NEW_RESOURCE(stuff->shmseg, client);
if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) {
client->errorValue = stuff->readOnly;
return (BadValue);
}
for (shmdesc = Shmsegs;
shmdesc && (shmdesc->shmid != stuff->shmid); shmdesc = shmdesc->next);
if (shmdesc) {
if (!stuff->readOnly && !shmdesc->writable)
return BadAccess;
shmdesc->refcnt++;
}
else {
shmdesc = malloc(sizeof(ShmDescRec));
if (!shmdesc)
return BadAlloc;
shmdesc->addr = shmat(stuff->shmid, 0,
stuff->readOnly ? SHM_RDONLY : 0);
if ((shmdesc->addr == ((char *) -1)) ||
shmctl(stuff->shmid, IPC_STAT, &buf)) {
free(shmdesc);
return BadAccess;
}
/* The attach was performed with root privs. We must
* do manual checking of access rights for the credentials
* of the client */
if (shm_access(client, &(buf.shm_perm), stuff->readOnly) == -1) {
shmdt(shmdesc->addr);
free(shmdesc);
return BadAccess;
}
shmdesc->shmid = stuff->shmid;
shmdesc->refcnt = 1;
shmdesc->writable = !stuff->readOnly;
shmdesc->size = buf.shm_segsz;
shmdesc->next = Shmsegs;
Shmsegs = shmdesc;
}
if (!AddResource(stuff->shmseg, ShmSegType, (pointer) shmdesc))
return BadAlloc;
return (client->noClientException);
}
/*ARGSUSED*/ static int
ShmDetachSegment(value, shmseg)
pointer value; /* must conform to DeleteType */
XID shmseg;
{
ShmDescPtr shmdesc = (ShmDescPtr) value;
ShmDescPtr *prev;
if (--shmdesc->refcnt)
return TRUE;
shmdt(shmdesc->addr);
for (prev = &Shmsegs; *prev != shmdesc; prev = &(*prev)->next);
*prev = shmdesc->next;
free(shmdesc);
return Success;
}
static int
ProcShmDetach(client)
ClientPtr client;
{
ShmDescPtr shmdesc;
REQUEST(xShmDetachReq);
REQUEST_SIZE_MATCH(xShmDetachReq);
VERIFY_SHMSEG(stuff->shmseg, shmdesc, client);
FreeResource(stuff->shmseg, RT_NONE);
return (client->noClientException);
}
static void
miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data)
DrawablePtr dst;
GCPtr pGC;
int depth, w, h, sx, sy, sw, sh, dx, dy;
unsigned int format;
char *data;
{
PixmapPtr pmap;
GCPtr putGC;
putGC = GetScratchGC(depth, dst->pScreen);
if (!putGC)
return;
pmap = (*dst->pScreen->CreatePixmap) (dst->pScreen, sw, sh, depth);
if (!pmap) {
FreeScratchGC(putGC);
return;
}
ValidateGC((DrawablePtr) pmap, putGC);
(*putGC->ops->PutImage) ((DrawablePtr) pmap, putGC, depth, -sx, -sy, w, h,
0, (format == XYPixmap) ? XYPixmap : ZPixmap,
data);
FreeScratchGC(putGC);
if (format == XYBitmap)
(void) (*pGC->ops->CopyPlane) ((DrawablePtr) pmap, dst, pGC, 0, 0, sw,
sh, dx, dy, 1L);
else
(void) (*pGC->ops->CopyArea) ((DrawablePtr) pmap, dst, pGC, 0, 0, sw,
sh, dx, dy);
(*pmap->drawable.pScreen->DestroyPixmap) (pmap);
}
static void
fbShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data)
DrawablePtr dst;
GCPtr pGC;
int depth, w, h, sx, sy, sw, sh, dx, dy;
unsigned int format;
char *data;
{
if ((format == ZPixmap) || (depth == 1)) {
PixmapPtr pPixmap;
pPixmap = GetScratchPixmapHeader(dst->pScreen, w, h, depth,
BitsPerPixel(depth), PixmapBytePad(w,
depth),
(pointer) data);
if (!pPixmap)
return;
if (format == XYBitmap)
(void) (*pGC->ops->CopyPlane) ((DrawablePtr) pPixmap, dst, pGC,
sx, sy, sw, sh, dx, dy, 1L);
else
(void) (*pGC->ops->CopyArea) ((DrawablePtr) pPixmap, dst, pGC,
sx, sy, sw, sh, dx, dy);
FreeScratchPixmapHeader(pPixmap);
}
else
miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy,
data);
}
static int
ProcShmPutImage(client)
ClientPtr client;
{
GCPtr pGC;
DrawablePtr pDraw;
long length;
ShmDescPtr shmdesc;
REQUEST(xShmPutImageReq);
REQUEST_SIZE_MATCH(xShmPutImageReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client);
if ((stuff->sendEvent != xTrue) && (stuff->sendEvent != xFalse))
return BadValue;
if (stuff->format == XYBitmap) {
if (stuff->depth != 1)
return BadMatch;
length = PixmapBytePad(stuff->totalWidth, 1);
}
else if (stuff->format == XYPixmap) {
if (pDraw->depth != stuff->depth)
return BadMatch;
length = PixmapBytePad(stuff->totalWidth, 1);
length *= stuff->depth;
}
else if (stuff->format == ZPixmap) {
if (pDraw->depth != stuff->depth)
return BadMatch;
length = PixmapBytePad(stuff->totalWidth, stuff->depth);
}
else {
client->errorValue = stuff->format;
return BadValue;
}
VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight, client);
if (stuff->srcX > stuff->totalWidth) {
client->errorValue = stuff->srcX;
return BadValue;
}
if (stuff->srcY > stuff->totalHeight) {
client->errorValue = stuff->srcY;
return BadValue;
}
if ((stuff->srcX + stuff->srcWidth) > stuff->totalWidth) {
client->errorValue = stuff->srcWidth;
return BadValue;
}
if ((stuff->srcY + stuff->srcHeight) > stuff->totalHeight) {
client->errorValue = stuff->srcHeight;
return BadValue;
}
if ((((stuff->format == ZPixmap) && (stuff->srcX == 0)) ||
((stuff->format != ZPixmap) &&
(stuff->srcX < screenInfo.bitmapScanlinePad) &&
((stuff->format == XYBitmap) ||
((stuff->srcY == 0) &&
(stuff->srcHeight == stuff->totalHeight))))) &&
((stuff->srcX + stuff->srcWidth) == stuff->totalWidth))
(*pGC->ops->PutImage) (pDraw, pGC, stuff->depth,
stuff->dstX, stuff->dstY,
stuff->totalWidth, stuff->srcHeight,
stuff->srcX, stuff->format,
shmdesc->addr + stuff->offset +
(stuff->srcY * length));
else
(*shmFuncs[pDraw->pScreen->myNum]->PutImage) (pDraw, pGC, stuff->depth,
stuff->format,
stuff->totalWidth,
stuff->totalHeight,
stuff->srcX, stuff->srcY,
stuff->srcWidth,
stuff->srcHeight,
stuff->dstX, stuff->dstY,
shmdesc->addr +
stuff->offset);
if (stuff->sendEvent) {
xShmCompletionEvent ev;
ev.type = ShmCompletionCode;
ev.drawable = stuff->drawable;
ev.sequenceNumber = client->sequence;
ev.minorEvent = X_ShmPutImage;
ev.majorEvent = ShmReqCode;
ev.shmseg = stuff->shmseg;
ev.offset = stuff->offset;
WriteEventsToClient(client, 1, (xEvent *) &ev);
}
return (client->noClientException);
}
static int
ProcShmGetImage(client)
ClientPtr client;
{
DrawablePtr pDraw;
long lenPer = 0, length;
Mask plane = 0;
xShmGetImageReply xgi;
ShmDescPtr shmdesc;
REQUEST(xShmGetImageReq);
REQUEST_SIZE_MATCH(xShmGetImageReq);
if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
client->errorValue = stuff->format;
return (BadValue);
}
VERIFY_DRAWABLE(pDraw, stuff->drawable, client);
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
if (pDraw->type == DRAWABLE_WINDOW) {
if ( /* check for being viewable */
!((WindowPtr) pDraw)->realized ||
/* check for being on screen */
pDraw->x + stuff->x < 0 ||
pDraw->x + stuff->x + (int) stuff->width > pDraw->pScreen->width
|| pDraw->y + stuff->y < 0 ||
pDraw->y + stuff->y + (int) stuff->height >
pDraw->pScreen->height ||
/* check for being inside of border */
stuff->x < -wBorderWidth((WindowPtr) pDraw) ||
stuff->x + (int) stuff->width >
wBorderWidth((WindowPtr) pDraw) + (int) pDraw->width ||
stuff->y < -wBorderWidth((WindowPtr) pDraw) ||
stuff->y + (int) stuff->height >
wBorderWidth((WindowPtr) pDraw) + (int) pDraw->height)
return (BadMatch);
xgi.visual = wVisual(((WindowPtr) pDraw));
}
else {
if (stuff->x < 0 ||
stuff->x + (int) stuff->width > pDraw->width ||
stuff->y < 0 || stuff->y + (int) stuff->height > pDraw->height)
return (BadMatch);
xgi.visual = None;
}
xgi.type = X_Reply;
xgi.length = 0;
xgi.sequenceNumber = client->sequence;
xgi.depth = pDraw->depth;
if (stuff->format == ZPixmap) {
length = PixmapBytePad(stuff->width, pDraw->depth) * stuff->height;
}
else {
lenPer = PixmapBytePad(stuff->width, 1) * stuff->height;
plane = ((Mask) 1) << (pDraw->depth - 1);
/* only planes asked for */
length = lenPer * Ones(stuff->planeMask & (plane | (plane - 1)));
}
VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client);
xgi.size = length;
if (length == 0) {
/* nothing to do */
}
else if (stuff->format == ZPixmap) {
(*pDraw->pScreen->GetImage) (pDraw, stuff->x, stuff->y,
stuff->width, stuff->height,
stuff->format, stuff->planeMask,
shmdesc->addr + stuff->offset);
}
else {
length = stuff->offset;
for (; plane; plane >>= 1) {
if (stuff->planeMask & plane) {
(*pDraw->pScreen->GetImage) (pDraw,
stuff->x, stuff->y,
stuff->width, stuff->height,
stuff->format, plane,
shmdesc->addr + length);
length += lenPer;
}
}
}
if (client->swapped) {
swaps(&xgi.sequenceNumber);
swapl(&xgi.length);
swapl(&xgi.visual);
swapl(&xgi.size);
}
WriteToClient(client, sizeof(xShmGetImageReply), (char *) &xgi);
return (client->noClientException);
}
static PixmapPtr
fbShmCreatePixmap(pScreen, width, height, depth, addr)
ScreenPtr pScreen;
int width;
int height;
int depth;
char *addr;
{
PixmapPtr pPixmap;
pPixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, pScreen->rootDepth);
if (!pPixmap)
return NullPixmap;
if (!(*pScreen->ModifyPixmapHeader) (pPixmap, width, height, depth,
BitsPerPixel(depth),
PixmapBytePad(width, depth),
(pointer) addr)) {
(*pScreen->DestroyPixmap) (pPixmap);
return NullPixmap;
}
return pPixmap;
}
static int
ProcShmCreatePixmap(client)
ClientPtr client;
{
PixmapPtr pMap;
DrawablePtr pDraw;
DepthPtr pDepth;
int i;
ShmDescPtr shmdesc;
REQUEST(xShmCreatePixmapReq);
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
client->errorValue = stuff->pid;
if (!sharedPixmaps)
return BadImplementation;
LEGAL_NEW_RESOURCE(stuff->pid, client);
VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client);
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
if (!stuff->width || !stuff->height) {
client->errorValue = 0;
return BadValue;
}
if (stuff->depth != 1) {
pDepth = pDraw->pScreen->allowedDepths;
for (i = 0; i < pDraw->pScreen->numDepths; i++, pDepth++)
if (pDepth->depth == stuff->depth)
goto CreatePmap;
client->errorValue = stuff->depth;
return BadValue;
}
CreatePmap:
VERIFY_SHMSIZE(shmdesc, stuff->offset,
PixmapBytePad(stuff->width, stuff->depth) * stuff->height,
client);
pMap =
(*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap) (pDraw->pScreen,
stuff->width,
stuff->height,
stuff->depth,
shmdesc->addr +
stuff->offset);
if (pMap) {
pMap->devPrivates[shmPixmapPrivate].ptr = (pointer) shmdesc;
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid;
if (AddResource(stuff->pid, RT_PIXMAP, (pointer) pMap)) {
return (client->noClientException);
}
}
return (BadAlloc);
}
static int
ProcShmDispatch(client)
ClientPtr client;
{
REQUEST(xReq);
switch (stuff->data) {
case X_ShmQueryVersion:
return ProcShmQueryVersion(client);
case X_ShmAttach:
return ProcShmAttach(client);
case X_ShmDetach:
return ProcShmDetach(client);
case X_ShmPutImage:
return ProcShmPutImage(client);
case X_ShmGetImage:
return ProcShmGetImage(client);
case X_ShmCreatePixmap:
return ProcShmCreatePixmap(client);
default:
return BadRequest;
}
}
static void
SShmCompletionEvent(from, to)
xShmCompletionEvent *from, *to;
{
to->type = from->type;
cpswaps(from->sequenceNumber, to->sequenceNumber);
cpswapl(from->drawable, to->drawable);
cpswaps(from->minorEvent, to->minorEvent);
to->majorEvent = from->majorEvent;
cpswapl(from->shmseg, to->shmseg);
cpswapl(from->offset, to->offset);
}
static int
SProcShmQueryVersion(client)
ClientPtr client;
{
REQUEST(xShmQueryVersionReq);
swaps(&stuff->length);
return ProcShmQueryVersion(client);
}
static int
SProcShmAttach(client)
ClientPtr client;
{
REQUEST(xShmAttachReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShmAttachReq);
swapl(&stuff->shmseg);
swapl(&stuff->shmid);
return ProcShmAttach(client);
}
static int
SProcShmDetach(client)
ClientPtr client;
{
REQUEST(xShmDetachReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShmDetachReq);
swapl(&stuff->shmseg);
return ProcShmDetach(client);
}
static int
SProcShmPutImage(client)
ClientPtr client;
{
REQUEST(xShmPutImageReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShmPutImageReq);
swapl(&stuff->drawable);
swapl(&stuff->gc);
swaps(&stuff->totalWidth);
swaps(&stuff->totalHeight);
swaps(&stuff->srcX);
swaps(&stuff->srcY);
swaps(&stuff->srcWidth);
swaps(&stuff->srcHeight);
swaps(&stuff->dstX);
swaps(&stuff->dstY);
swapl(&stuff->shmseg);
swapl(&stuff->offset);
return ProcShmPutImage(client);
}
static int
SProcShmGetImage(client)
ClientPtr client;
{
REQUEST(xShmGetImageReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShmGetImageReq);
swapl(&stuff->drawable);
swaps(&stuff->x);
swaps(&stuff->y);
swaps(&stuff->width);
swaps(&stuff->height);
swapl(&stuff->planeMask);
swapl(&stuff->shmseg);
swapl(&stuff->offset);
return ProcShmGetImage(client);
}
static int
SProcShmCreatePixmap(client)
ClientPtr client;
{
REQUEST(xShmCreatePixmapReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
swapl(&stuff->pid);
swapl(&stuff->drawable);
swaps(&stuff->width);
swaps(&stuff->height);
swapl(&stuff->shmseg);
swapl(&stuff->offset);
return ProcShmCreatePixmap(client);
}
static int
SProcShmDispatch(client)
ClientPtr client;
{
REQUEST(xReq);
switch (stuff->data) {
case X_ShmQueryVersion:
return SProcShmQueryVersion(client);
case X_ShmAttach:
return SProcShmAttach(client);
case X_ShmDetach:
return SProcShmDetach(client);
case X_ShmPutImage:
return SProcShmPutImage(client);
case X_ShmGetImage:
return SProcShmGetImage(client);
case X_ShmCreatePixmap:
return SProcShmCreatePixmap(client);
default:
return BadRequest;
}
}

43
Xext/shmint.h Normal file
View File

@ -0,0 +1,43 @@
/*
*
* Copyright © 2003 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _SHMINT_H_
#define _SHMINT_H_
#define _XSHM_SERVER_
#include <X11/extensions/shmstr.h>
#include "screenint.h"
#include "pixmap.h"
#include "gc.h"
void
ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs);
void
ShmSetPixmapFormat(ScreenPtr pScreen, int format);
void
ShmRegisterFbFuncs(ScreenPtr pScreen);
#endif /* _SHMINT_H_ */

240
Xext/sleepuntil.c Normal file
View File

@ -0,0 +1,240 @@
/*
*
Copyright 1992, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*
* Author: Keith Packard, MIT X Consortium
*/
/* dixsleep.c - implement millisecond timeouts for X clients */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "sleepuntil.h"
#include <X11/X.h>
#include <X11/Xmd.h>
#include "misc.h"
#include "windowstr.h"
#include "dixstruct.h"
#include "pixmapstr.h"
#include "scrnintstr.h"
typedef struct _Sertafied {
struct _Sertafied *next;
TimeStamp revive;
ClientPtr pClient;
XID id;
void (*notifyFunc) (ClientPtr /* client */ ,
pointer /* closure */
);
pointer closure;
} SertafiedRec, *SertafiedPtr;
static SertafiedPtr pPending;
static RESTYPE SertafiedResType;
static Bool BlockHandlerRegistered;
static int SertafiedGeneration;
static void ClientAwaken(ClientPtr /* client */ ,
pointer /* closure */
);
static int SertafiedDelete(pointer /* value */ ,
XID /* id */
);
static void SertafiedBlockHandler(pointer /* data */ ,
OSTimePtr /* wt */ ,
pointer /* LastSelectMask */
);
static void SertafiedWakeupHandler(pointer /* data */ ,
int /* i */ ,
pointer /* LastSelectMask */
);
_X_EXPORT int
ClientSleepUntil(client, revive, notifyFunc, closure)
ClientPtr client;
TimeStamp *revive;
void (*notifyFunc) (ClientPtr /* client */ ,
pointer /* closure */ );
pointer closure;
{
SertafiedPtr pRequest, pReq, pPrev;
if (SertafiedGeneration != serverGeneration) {
SertafiedResType = CreateNewResourceType(SertafiedDelete);
if (!SertafiedResType)
return FALSE;
SertafiedGeneration = serverGeneration;
BlockHandlerRegistered = FALSE;
}
pRequest = malloc(sizeof(SertafiedRec));
if (!pRequest)
return FALSE;
pRequest->pClient = client;
pRequest->revive = *revive;
pRequest->id = FakeClientID(client->index);
pRequest->closure = closure;
if (!BlockHandlerRegistered) {
if (!RegisterBlockAndWakeupHandlers(SertafiedBlockHandler,
SertafiedWakeupHandler,
(pointer) 0)) {
free(pRequest);
return FALSE;
}
BlockHandlerRegistered = TRUE;
}
pRequest->notifyFunc = 0;
if (!AddResource(pRequest->id, SertafiedResType, (pointer) pRequest))
return FALSE;
if (!notifyFunc)
notifyFunc = ClientAwaken;
pRequest->notifyFunc = notifyFunc;
/* Insert into time-ordered queue, with earliest activation time coming first. */
pPrev = 0;
for (pReq = pPending; pReq; pReq = pReq->next) {
if (CompareTimeStamps(pReq->revive, *revive) == LATER)
break;
pPrev = pReq;
}
if (pPrev)
pPrev->next = pRequest;
else
pPending = pRequest;
pRequest->next = pReq;
IgnoreClient(client);
return TRUE;
}
static void
ClientAwaken(client, closure)
ClientPtr client;
pointer closure;
{
if (!client->clientGone)
AttendClient(client);
}
static int
SertafiedDelete(value, id)
pointer value;
XID id;
{
SertafiedPtr pRequest = (SertafiedPtr) value;
SertafiedPtr pReq, pPrev;
pPrev = 0;
for (pReq = pPending; pReq; pPrev = pReq, pReq = pReq->next)
if (pReq == pRequest) {
if (pPrev)
pPrev->next = pReq->next;
else
pPending = pReq->next;
break;
}
if (pRequest->notifyFunc)
(*pRequest->notifyFunc) (pRequest->pClient, pRequest->closure);
free(pRequest);
return TRUE;
}
static void
SertafiedBlockHandler(data, wt, LastSelectMask)
pointer data; /* unused */
OSTimePtr wt; /* wait time */
pointer LastSelectMask;
{
SertafiedPtr pReq, pNext;
unsigned long delay;
TimeStamp now;
if (!pPending)
return;
now.milliseconds = GetTimeInMillis();
now.months = currentTime.months;
if ((int) (now.milliseconds - currentTime.milliseconds) < 0)
now.months++;
for (pReq = pPending; pReq; pReq = pNext) {
pNext = pReq->next;
if (CompareTimeStamps(pReq->revive, now) == LATER)
break;
FreeResource(pReq->id, RT_NONE);
/* AttendClient() may have been called via the resource delete
* function so a client may have input to be processed and so
* set delay to 0 to prevent blocking in WaitForSomething().
*/
AdjustWaitForDelay(wt, 0);
}
pReq = pPending;
if (!pReq)
return;
delay = pReq->revive.milliseconds - now.milliseconds;
AdjustWaitForDelay(wt, delay);
}
static void
SertafiedWakeupHandler(data, i, LastSelectMask)
pointer data;
int i;
pointer LastSelectMask;
{
SertafiedPtr pReq, pNext;
TimeStamp now;
now.milliseconds = GetTimeInMillis();
now.months = currentTime.months;
if ((int) (now.milliseconds - currentTime.milliseconds) < 0)
now.months++;
for (pReq = pPending; pReq; pReq = pNext) {
pNext = pReq->next;
if (CompareTimeStamps(pReq->revive, now) == LATER)
break;
FreeResource(pReq->id, RT_NONE);
}
if (!pPending) {
RemoveBlockAndWakeupHandlers(SertafiedBlockHandler,
SertafiedWakeupHandler, (pointer) 0);
BlockHandlerRegistered = FALSE;
}
}

42
Xext/sleepuntil.h Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2001 The XFree86 Project, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the XFree86 Project shall
* not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization from the
* XFree86 Project.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef _SLEEPUNTIL_H_
#define _SLEEPUNTIL_H_ 1
#include "dix.h"
extern int ClientSleepUntil(ClientPtr client,
TimeStamp *revive,
void (*notifyFunc) (ClientPtr /* client */ ,
pointer /* closure */
), pointer Closure);
#endif

2456
Xext/sync.c Normal file

File diff suppressed because it is too large Load Diff

244
Xext/xcmisc.c Normal file
View File

@ -0,0 +1,244 @@
/*
Copyright 1993, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include "swaprep.h"
#include <X11/extensions/xcmiscproto.h>
#include "extinit.h"
#if 0
static unsigned char XCMiscCode;
#endif
static void XCMiscResetProc(ExtensionEntry * /* extEntry */
);
static DISPATCH_PROC(ProcXCMiscDispatch);
static DISPATCH_PROC(ProcXCMiscGetVersion);
static DISPATCH_PROC(ProcXCMiscGetXIDList);
static DISPATCH_PROC(ProcXCMiscGetXIDRange);
static DISPATCH_PROC(SProcXCMiscDispatch);
static DISPATCH_PROC(SProcXCMiscGetVersion);
static DISPATCH_PROC(SProcXCMiscGetXIDList);
static DISPATCH_PROC(SProcXCMiscGetXIDRange);
void
XCMiscExtensionInit(INITARGS)
{
#if 0
ExtensionEntry *extEntry;
if ((extEntry = AddExtension(XCMiscExtensionName, 0, 0,
ProcXCMiscDispatch, SProcXCMiscDispatch,
XCMiscResetProc, StandardMinorOpcode)) != 0)
XCMiscCode = (unsigned char) extEntry->base;
#else
(void) AddExtension(XCMiscExtensionName, 0, 0,
ProcXCMiscDispatch, SProcXCMiscDispatch,
XCMiscResetProc, StandardMinorOpcode);
#endif
DeclareExtensionSecurity(XCMiscExtensionName, TRUE);
}
/*ARGSUSED*/ static void
XCMiscResetProc(extEntry)
ExtensionEntry *extEntry;
{
}
static int
ProcXCMiscGetVersion(client)
ClientPtr client;
{
xXCMiscGetVersionReply rep;
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = XCMiscMajorVersion;
rep.minorVersion = XCMiscMinorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
WriteToClient(client, sizeof(xXCMiscGetVersionReply), (char *) &rep);
return (client->noClientException);
}
static int
ProcXCMiscGetXIDRange(client)
ClientPtr client;
{
xXCMiscGetXIDRangeReply rep;
XID min_id, max_id;
REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq);
GetXIDRange(client->index, FALSE, &min_id, &max_id);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.start_id = min_id;
rep.count = max_id - min_id + 1;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.start_id);
swapl(&rep.count);
}
WriteToClient(client, sizeof(xXCMiscGetXIDRangeReply), (char *) &rep);
return (client->noClientException);
}
static int
ProcXCMiscGetXIDList(client)
ClientPtr client;
{
REQUEST(xXCMiscGetXIDListReq);
xXCMiscGetXIDListReply rep;
XID *pids;
unsigned int count;
REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
pids = (XID *) ALLOCATE_LOCAL(stuff->count * sizeof(XID));
if (!pids) {
return BadAlloc;
}
count = GetXIDList(client, stuff->count, pids);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = count;
rep.count = count;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.count);
}
WriteToClient(client, sizeof(xXCMiscGetXIDListReply), (char *) &rep);
if (count) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, count * sizeof(XID), pids);
}
DEALLOCATE_LOCAL(pids);
return (client->noClientException);
}
static int
ProcXCMiscDispatch(client)
ClientPtr client;
{
REQUEST(xReq);
switch (stuff->data) {
case X_XCMiscGetVersion:
return ProcXCMiscGetVersion(client);
case X_XCMiscGetXIDRange:
return ProcXCMiscGetXIDRange(client);
case X_XCMiscGetXIDList:
return ProcXCMiscGetXIDList(client);
default:
return BadRequest;
}
}
static int
SProcXCMiscGetVersion(client)
ClientPtr client;
{
REQUEST(xXCMiscGetVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion);
return ProcXCMiscGetVersion(client);
}
static int
SProcXCMiscGetXIDRange(client)
ClientPtr client;
{
REQUEST(xReq);
swaps(&stuff->length);
return ProcXCMiscGetXIDRange(client);
}
static int
SProcXCMiscGetXIDList(client)
ClientPtr client;
{
REQUEST(xXCMiscGetXIDListReq);
swaps(&stuff->length);
swapl(&stuff->count);
return ProcXCMiscGetXIDList(client);
}
static int
SProcXCMiscDispatch(client)
ClientPtr client;
{
REQUEST(xReq);
switch (stuff->data) {
case X_XCMiscGetVersion:
return SProcXCMiscGetVersion(client);
case X_XCMiscGetXIDRange:
return SProcXCMiscGetXIDRange(client);
case X_XCMiscGetXIDList:
return SProcXCMiscGetXIDList(client);
default:
return BadRequest;
}
}

779
Xext/xf86bigfont.c Normal file
View File

@ -0,0 +1,779 @@
/*
* BIGFONT extension for sharing font metrics between clients (if possible)
* and for transmitting font metrics to clients in a compressed form.
*
* Copyright (c) 1999-2000 Bruno Haible
* Copyright (c) 1999-2000 The XFree86 Project, Inc.
*/
/* THIS IS NOT AN X CONSORTIUM STANDARD */
/*
* Big fonts suffer from the following: All clients that have opened a
* font can access the complete glyph metrics array (the XFontStruct member
* `per_char') directly, without going through a macro. Moreover these
* glyph metrics are ink metrics, i.e. are not redundant even for a
* fixed-width font. For a Unicode font, the size of this array is 768 KB.
*
* Problems: 1. It eats a lot of memory in each client. 2. All this glyph
* metrics data is piped through the socket when the font is opened.
*
* This extension addresses these two problems for local clients, by using
* shared memory. It also addresses the second problem for non-local clients,
* by compressing the data before transmit by a factor of nearly 6.
*
* If you use this extension, your OS ought to nicely support shared memory.
* This means: Shared memory should be swappable to the swap, and the limits
* should be high enough (SHMMNI at least 64, SHMMAX at least 768 KB,
* SHMALL at least 48 MB). It is a plus if your OS allows shmat() calls
* on segments that have already been marked "removed", because it permits
* these segments to be cleaned up by the OS if the X server is killed with
* signal SIGKILL.
*
* This extension is transparently exploited by Xlib (functions XQueryFont,
* XLoadQueryFont).
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <sys/types.h>
#if defined(linux) && (!defined(__GNU_LIBRARY__) || __GNU_LIBRARY__ < 2)
/* libc4 does not define __GNU_LIBRARY__, libc5 defines __GNU_LIBRARY__ as 1 */
/* Linux libc4 and libc5 only (because glibc doesn't include kernel headers):
Linux 2.0.x and 2.2.x define SHMLBA as PAGE_SIZE, but forget to define
PAGE_SIZE. It is defined in <asm/page.h>. */
#include <asm/page.h>
#endif
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "gcstruct.h"
#include "dixfontstr.h"
#include "extnsionst.h"
#define _XF86BIGFONT_SERVER_
#include <X11/extensions/xf86bigfproto.h>
static void XF86BigfontResetProc(ExtensionEntry * /* extEntry */
);
static DISPATCH_PROC(ProcXF86BigfontDispatch);
static DISPATCH_PROC(ProcXF86BigfontQueryVersion);
static DISPATCH_PROC(ProcXF86BigfontQueryFont);
static DISPATCH_PROC(SProcXF86BigfontDispatch);
static DISPATCH_PROC(SProcXF86BigfontQueryVersion);
static DISPATCH_PROC(SProcXF86BigfontQueryFont);
#if 0
static unsigned char XF86BigfontReqCode;
#endif
/* A random signature, transmitted to the clients so they can verify that the
shared memory segment they are attaching to was really established by the
X server they are talking to. */
static CARD32 signature;
/* Index for additional information stored in a FontRec's devPrivates array. */
static int FontShmdescIndex;
static unsigned int pagesize;
static Bool badSysCall = FALSE;
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
#include <sys/signal.h>
static void
SigSysHandler(int signo)
{
badSysCall = TRUE;
}
static Bool
CheckForShmSyscall(void)
{
void (*oldHandler) (int);
int shmid = -1;
/* If no SHM support in the kernel, the bad syscall will generate SIGSYS */
oldHandler = signal(SIGSYS, SigSysHandler);
badSysCall = FALSE;
shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
if (shmid != -1) {
/* Successful allocation - clean up */
shmctl(shmid, IPC_RMID, (struct shmid_ds *) NULL);
}
else {
/* Allocation failed */
badSysCall = TRUE;
}
signal(SIGSYS, oldHandler);
return (!badSysCall);
}
#define MUST_CHECK_FOR_SHM_SYSCALL
#endif
void
XFree86BigfontExtensionInit()
{
#if 0
ExtensionEntry *extEntry;
if ((extEntry = AddExtension(XF86BIGFONTNAME,
XF86BigfontNumberEvents,
XF86BigfontNumberErrors,
ProcXF86BigfontDispatch,
SProcXF86BigfontDispatch,
XF86BigfontResetProc, StandardMinorOpcode))) {
XF86BigfontReqCode = (unsigned char) extEntry->base;
#else
if (AddExtension(XF86BIGFONTNAME,
XF86BigfontNumberEvents,
XF86BigfontNumberErrors,
ProcXF86BigfontDispatch,
SProcXF86BigfontDispatch,
XF86BigfontResetProc, StandardMinorOpcode)) {
#endif
#ifdef MUST_CHECK_FOR_SHM_SYSCALL
/*
* Note: Local-clients will not be optimized without shared memory
* support. Remote-client optimization does not depend on shared
* memory support. Thus, the extension is still registered even
* when shared memory support is not functional.
*/
if (!CheckForShmSyscall()) {
ErrorF(XF86BIGFONTNAME
" extension local-client optimization disabled due to lack of shared memory support in the kernel\n");
return;
}
#endif
srand((unsigned int) time(NULL));
signature = ((unsigned int) (65536.0 / (RAND_MAX + 1.0) * rand()) << 16)
+ (unsigned int) (65536.0 / (RAND_MAX + 1.0) * rand());
/* fprintf(stderr, "signature = 0x%08X\n", signature); */
FontShmdescIndex = AllocateFontPrivateIndex();
#if !defined(CSRG_BASED) && !defined(__CYGWIN__)
pagesize = SHMLBA;
#else
# ifdef _SC_PAGESIZE
pagesize = sysconf(_SC_PAGESIZE);
# else
pagesize = getpagesize();
# endif
#endif
}
}
/* ========== Management of shared memory segments ========== */
#ifdef __linux__
/* On Linux, shared memory marked as "removed" can still be attached.
Nice feature, because the kernel will automatically free the associated
storage when the server and all clients are gone. */
#define EARLY_REMOVE
#endif
typedef struct _ShmDesc {
struct _ShmDesc *next;
struct _ShmDesc **prev;
int shmid;
char *attach_addr;
} ShmDescRec, *ShmDescPtr;
static ShmDescPtr ShmList = (ShmDescPtr) NULL;
static ShmDescPtr
shmalloc(unsigned int size)
{
ShmDescPtr pDesc;
int shmid;
char *addr;
#ifdef MUST_CHECK_FOR_SHM_SYSCALL
if (pagesize == 0)
return (ShmDescPtr) NULL;
#endif
/* On some older Linux systems, the number of shared memory segments
system-wide is 127. In Linux 2.4, it is 4095.
Therefore there is a tradeoff to be made between allocating a
shared memory segment on one hand, and allocating memory and piping
the glyph metrics on the other hand. If the glyph metrics size is
small, we prefer the traditional way. */
if (size < 3500)
return (ShmDescPtr) NULL;
pDesc = malloc(sizeof(ShmDescRec));
if (!pDesc)
return (ShmDescPtr) NULL;
size = (size + pagesize - 1) & -pagesize;
shmid = shmget(IPC_PRIVATE, size, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
if (shmid == -1) {
ErrorF(XF86BIGFONTNAME
" extension: shmget() failed, size = %u, errno = %d\n", size,
errno);
free(pDesc);
return (ShmDescPtr) NULL;
}
if ((addr = shmat(shmid, 0, 0)) == (char *) -1) {
ErrorF(XF86BIGFONTNAME
" extension: shmat() failed, size = %u, errno = %d\n", size,
errno);
shmctl(shmid, IPC_RMID, (void *) 0);
free(pDesc);
return (ShmDescPtr) NULL;
}
#ifdef EARLY_REMOVE
shmctl(shmid, IPC_RMID, (void *) 0);
#endif
pDesc->shmid = shmid;
pDesc->attach_addr = addr;
if (ShmList)
ShmList->prev = &pDesc->next;
pDesc->next = ShmList;
pDesc->prev = &ShmList;
ShmList = pDesc;
return pDesc;
}
static void
shmdealloc(ShmDescPtr pDesc)
{
#ifndef EARLY_REMOVE
shmctl(pDesc->shmid, IPC_RMID, (void *) 0);
#endif
shmdt(pDesc->attach_addr);
if (pDesc->next)
pDesc->next->prev = pDesc->prev;
*pDesc->prev = pDesc->next;
free(pDesc);
}
/* Called when a font is closed. */
void
XF86BigfontFreeFontShm(FontPtr pFont)
{
ShmDescPtr pDesc;
/* If during shutdown of the server, XF86BigfontCleanup() has already
* called shmdealloc() for all segments, we don't need to do it here.
*/
if (!ShmList)
return;
pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
if (pDesc)
shmdealloc(pDesc);
}
/* Called upon fatal signal. */
void
XF86BigfontCleanup()
{
while (ShmList)
shmdealloc(ShmList);
}
/* Called when a server generation dies. */
static void
XF86BigfontResetProc(ExtensionEntry * extEntry)
{
/* This function is normally called from CloseDownExtensions(), called
* from main(). It will be followed by a call to FreeAllResources(),
* which will call XF86BigfontFreeFontShm() for each font. Thus it
* appears that we do not need to do anything in this function. --
* But I prefer to write robust code, and not keep shared memory lying
* around when it's not needed any more. (Someone might close down the
* extension without calling FreeAllResources()...)
*/
XF86BigfontCleanup();
}
/* ========== Handling of extension specific requests ========== */
static int
ProcXF86BigfontQueryVersion(ClientPtr client)
{
xXF86BigfontQueryVersionReply reply = {0};
REQUEST_SIZE_MATCH(xXF86BigfontQueryVersionReq);
reply.type = X_Reply;
reply.length = 0;
reply.sequenceNumber = client->sequence;
reply.majorVersion = XF86BIGFONT_MAJOR_VERSION;
reply.minorVersion = XF86BIGFONT_MINOR_VERSION;
reply.uid = geteuid();
reply.gid = getegid();
reply.signature = signature;
reply.capabilities =
(LocalClient(client) && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0)
; /* may add more bits here in future versions */
if (client->swapped) {
swaps(&reply.sequenceNumber);
swapl(&reply.length);
swaps(&reply.majorVersion);
swaps(&reply.minorVersion);
swapl(&reply.uid);
swapl(&reply.gid);
swapl(&reply.signature);
}
WriteToClient(client,
sizeof(xXF86BigfontQueryVersionReply), (char *) &reply);
return client->noClientException;
}
static void
swapCharInfo(xCharInfo * pCI)
{
swaps(&pCI->leftSideBearing);
swaps(&pCI->rightSideBearing);
swaps(&pCI->characterWidth);
swaps(&pCI->ascent);
swaps(&pCI->descent);
swaps(&pCI->attributes);
}
/* static CARD32 hashCI (xCharInfo *p); */
#define hashCI(p) \
(CARD32)(((p->leftSideBearing << 27) + (p->leftSideBearing >> 5) + \
(p->rightSideBearing << 23) + (p->rightSideBearing >> 9) + \
(p->characterWidth << 16) + \
(p->ascent << 11) + (p->descent << 6)) ^ p->attributes)
static int
ProcXF86BigfontQueryFont(ClientPtr client)
{
FontPtr pFont;
REQUEST(xXF86BigfontQueryFontReq);
CARD32 stuff_flags;
xCharInfo *pmax;
xCharInfo *pmin;
int nCharInfos;
int shmid;
ShmDescPtr pDesc;
xCharInfo *pCI;
CARD16 *pIndex2UniqIndex;
CARD16 *pUniqIndex2Index;
CARD32 nUniqCharInfos;
#if 0
REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
#else
switch (client->req_len) {
case 2: /* client with version 1.0 libX11 */
stuff_flags = (LocalClient(client) &&
!client->swapped ? XF86Bigfont_FLAGS_Shm : 0);
break;
case 3: /* client with version 1.1 libX11 */
stuff_flags = stuff->flags;
break;
default:
return BadLength;
}
#endif
client->errorValue = stuff->id; /* EITHER font or gc */
pFont = (FontPtr) SecurityLookupIDByType(client, stuff->id, RT_FONT,
SecurityReadAccess);
if (!pFont) {
/* can't use VERIFY_GC because it might return BadGC */
GC *pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC,
SecurityReadAccess);
if (!pGC) {
client->errorValue = stuff->id;
return BadFont; /* procotol spec says only error is BadFont */
}
pFont = pGC->font;
}
pmax = FONTINKMAX(pFont);
pmin = FONTINKMIN(pFont);
nCharInfos =
(pmax->rightSideBearing == pmin->rightSideBearing
&& pmax->leftSideBearing == pmin->leftSideBearing
&& pmax->descent == pmin->descent
&& pmax->ascent == pmin->ascent
&& pmax->characterWidth == pmin->characterWidth)
? 0 : N2dChars(pFont);
shmid = -1;
pCI = NULL;
pIndex2UniqIndex = NULL;
pUniqIndex2Index = NULL;
nUniqCharInfos = 0;
if (nCharInfos > 0) {
if (!badSysCall)
pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
else
pDesc = NULL;
if (pDesc) {
pCI = (xCharInfo *) pDesc->attach_addr;
if (stuff_flags & XF86Bigfont_FLAGS_Shm)
shmid = pDesc->shmid;
}
else {
if (stuff_flags & XF86Bigfont_FLAGS_Shm && !badSysCall)
pDesc = shmalloc(nCharInfos * sizeof(xCharInfo)
+ sizeof(CARD32));
if (pDesc) {
pCI = (xCharInfo *) pDesc->attach_addr;
shmid = pDesc->shmid;
}
else {
pCI = (xCharInfo *)
ALLOCATE_LOCAL(nCharInfos * sizeof(xCharInfo));
if (!pCI)
return BadAlloc;
}
/* Fill nCharInfos starting at pCI. */
{
xCharInfo *prCI = pCI;
int ninfos = 0;
int ncols = pFont->info.lastCol - pFont->info.firstCol + 1;
int row;
for (row = pFont->info.firstRow;
row <= pFont->info.lastRow && ninfos < nCharInfos; row++) {
unsigned char chars[512];
xCharInfo *tmpCharInfos[256];
unsigned long count;
int col;
unsigned long i;
i = 0;
for (col = pFont->info.firstCol;
col <= pFont->info.lastCol; col++) {
chars[i++] = row;
chars[i++] = col;
}
(*pFont->get_metrics) (pFont, ncols, chars, TwoD16Bit,
&count, tmpCharInfos);
for (i = 0; i < count && ninfos < nCharInfos; i++) {
*prCI++ = *tmpCharInfos[i];
ninfos++;
}
}
}
if (pDesc && !badSysCall) {
*(CARD32 *) (pCI + nCharInfos) = signature;
if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) {
shmdealloc(pDesc);
return BadAlloc;
}
}
}
if (shmid == -1) {
/* Cannot use shared memory, so remove-duplicates the xCharInfos
using a temporary hash table. */
/* Note that CARD16 is suitable as index type, because
nCharInfos <= 0x10000. */
CARD32 hashModulus;
CARD16 *pHash2UniqIndex;
CARD16 *pUniqIndex2NextUniqIndex;
CARD32 NextIndex;
CARD32 NextUniqIndex;
CARD16 *tmp;
CARD32 i, j;
hashModulus = 67;
if (hashModulus > nCharInfos + 1)
hashModulus = nCharInfos + 1;
tmp = (CARD16 *)
ALLOCATE_LOCAL((4 * nCharInfos + 1) * sizeof(CARD16));
if (!tmp) {
if (!pDesc)
DEALLOCATE_LOCAL(pCI);
return BadAlloc;
}
pIndex2UniqIndex = tmp;
/* nCharInfos elements */
pUniqIndex2Index = tmp + nCharInfos;
/* max. nCharInfos elements */
pUniqIndex2NextUniqIndex = tmp + 2 * nCharInfos;
/* max. nCharInfos elements */
pHash2UniqIndex = tmp + 3 * nCharInfos;
/* hashModulus (<= nCharInfos+1) elements */
/* Note that we can use 0xffff as end-of-list indicator, because
even if nCharInfos = 0x10000, 0xffff can not occur as valid
entry before the last element has been inserted. And once the
last element has been inserted, we don't need the hash table
any more. */
for (j = 0; j < hashModulus; j++)
pHash2UniqIndex[j] = (CARD16) (-1);
NextUniqIndex = 0;
for (NextIndex = 0; NextIndex < nCharInfos; NextIndex++) {
xCharInfo *p = &pCI[NextIndex];
CARD32 hashCode = hashCI(p) % hashModulus;
for (i = pHash2UniqIndex[hashCode];
i != (CARD16) (-1); i = pUniqIndex2NextUniqIndex[i]) {
j = pUniqIndex2Index[i];
if (pCI[j].leftSideBearing == p->leftSideBearing
&& pCI[j].rightSideBearing == p->rightSideBearing
&& pCI[j].characterWidth == p->characterWidth
&& pCI[j].ascent == p->ascent
&& pCI[j].descent == p->descent
&& pCI[j].attributes == p->attributes)
break;
}
if (i != (CARD16) (-1)) {
/* Found *p at Index j, UniqIndex i */
pIndex2UniqIndex[NextIndex] = i;
}
else {
/* Allocate a new entry in the Uniq table */
if (hashModulus <= 2 * NextUniqIndex
&& hashModulus < nCharInfos + 1) {
/* Time to increate hash table size */
hashModulus = 2 * hashModulus + 1;
if (hashModulus > nCharInfos + 1)
hashModulus = nCharInfos + 1;
for (j = 0; j < hashModulus; j++)
pHash2UniqIndex[j] = (CARD16) (-1);
for (i = 0; i < NextUniqIndex; i++)
pUniqIndex2NextUniqIndex[i] = (CARD16) (-1);
for (i = 0; i < NextUniqIndex; i++) {
j = pUniqIndex2Index[i];
p = &pCI[j];
hashCode = hashCI(p) % hashModulus;
pUniqIndex2NextUniqIndex[i] =
pHash2UniqIndex[hashCode];
pHash2UniqIndex[hashCode] = i;
}
p = &pCI[NextIndex];
hashCode = hashCI(p) % hashModulus;
}
i = NextUniqIndex++;
pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode];
pHash2UniqIndex[hashCode] = i;
pUniqIndex2Index[i] = NextIndex;
pIndex2UniqIndex[NextIndex] = i;
}
}
nUniqCharInfos = NextUniqIndex;
/* fprintf(stderr, "font metrics: nCharInfos = %d, nUniqCharInfos = %d, hashModulus = %d\n", nCharInfos, nUniqCharInfos, hashModulus); */
}
}
{
int nfontprops = pFont->info.nprops;
int rlength = sizeof(xXF86BigfontQueryFontReply)
+ nfontprops * sizeof(xFontProp)
+ (nCharInfos > 0 && shmid == -1
? nUniqCharInfos * sizeof(xCharInfo)
+ (nCharInfos + 1) / 2 * 2 * sizeof(CARD16)
: 0);
xXF86BigfontQueryFontReply *reply =
(xXF86BigfontQueryFontReply *) ALLOCATE_LOCAL(rlength);
char *p;
if (!reply) {
if (nCharInfos > 0) {
if (shmid == -1)
DEALLOCATE_LOCAL(pIndex2UniqIndex);
if (!pDesc)
DEALLOCATE_LOCAL(pCI);
}
return BadAlloc;
}
memset(reply, 0, rlength);
reply->type = X_Reply;
reply->length = (rlength - sizeof(xGenericReply)) >> 2;
reply->sequenceNumber = client->sequence;
reply->minBounds = pFont->info.ink_minbounds;
reply->maxBounds = pFont->info.ink_maxbounds;
reply->minCharOrByte2 = pFont->info.firstCol;
reply->maxCharOrByte2 = pFont->info.lastCol;
reply->defaultChar = pFont->info.defaultCh;
reply->nFontProps = pFont->info.nprops;
reply->drawDirection = pFont->info.drawDirection;
reply->minByte1 = pFont->info.firstRow;
reply->maxByte1 = pFont->info.lastRow;
reply->allCharsExist = pFont->info.allExist;
reply->fontAscent = pFont->info.fontAscent;
reply->fontDescent = pFont->info.fontDescent;
reply->nCharInfos = nCharInfos;
reply->nUniqCharInfos = nUniqCharInfos;
reply->shmid = shmid;
reply->shmsegoffset = 0;
if (client->swapped) {
swaps(&reply->sequenceNumber);
swapl(&reply->length);
swapCharInfo(&reply->minBounds);
swapCharInfo(&reply->maxBounds);
swaps(&reply->minCharOrByte2);
swaps(&reply->maxCharOrByte2);
swaps(&reply->defaultChar);
swaps(&reply->nFontProps);
swaps(&reply->fontAscent);
swaps(&reply->fontDescent);
swapl(&reply->nCharInfos);
swapl(&reply->nUniqCharInfos);
swapl(&reply->shmid);
swapl(&reply->shmsegoffset);
}
p = (char *) &reply[1];
{
FontPropPtr pFP;
xFontProp *prFP;
int i;
for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) p;
i < nfontprops; i++, pFP++, prFP++) {
prFP->name = pFP->name;
prFP->value = pFP->value;
if (client->swapped) {
swapl(&prFP->name);
swapl(&prFP->value);
}
}
p = (char *) prFP;
}
if (nCharInfos > 0 && shmid == -1) {
xCharInfo *pci;
CARD16 *ps;
int i, j;
pci = (xCharInfo *) p;
for (i = 0; i < nUniqCharInfos; i++, pci++) {
*pci = pCI[pUniqIndex2Index[i]];
if (client->swapped)
swapCharInfo(pci);
}
ps = (CARD16 *) pci;
for (j = 0; j < nCharInfos; j++, ps++) {
*ps = pIndex2UniqIndex[j];
if (client->swapped) {
swaps(ps);
}
}
}
WriteToClient(client, rlength, (char *) reply);
DEALLOCATE_LOCAL(reply);
if (nCharInfos > 0) {
if (shmid == -1)
DEALLOCATE_LOCAL(pIndex2UniqIndex);
if (!pDesc)
DEALLOCATE_LOCAL(pCI);
}
return (client->noClientException);
}
}
static int
ProcXF86BigfontDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_XF86BigfontQueryVersion:
return ProcXF86BigfontQueryVersion(client);
case X_XF86BigfontQueryFont:
return ProcXF86BigfontQueryFont(client);
default:
return BadRequest;
}
}
static int
SProcXF86BigfontQueryVersion(ClientPtr client)
{
REQUEST(xXF86BigfontQueryVersionReq);
swaps(&stuff->length);
return ProcXF86BigfontQueryVersion(client);
}
static int
SProcXF86BigfontQueryFont(ClientPtr client)
{
REQUEST(xXF86BigfontQueryFontReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
swapl(&stuff->id);
return ProcXF86BigfontQueryFont(client);
}
static int
SProcXF86BigfontDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_XF86BigfontQueryVersion:
return SProcXF86BigfontQueryVersion(client);
case X_XF86BigfontQueryFont:
return SProcXF86BigfontQueryFont(client);
default:
return BadRequest;
}
}

33
Xext/xf86bigfontsrv.h Normal file
View File

@ -0,0 +1,33 @@
/*
* Copyright © 2010 Yaakov Selkowitz
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _XF86BIGFONTSRV_H_
#define _XF86BIGFONTSRV_H_
#include <X11/fonts/font.h>
extern void XF86BigfontFreeFontShm(FontPtr);
extern void XF86BigfontCleanup(void);
#endif

392
Xext/xres.c Normal file
View File

@ -0,0 +1,392 @@
/*
Copyright (c) 2002 XFree86 Inc
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <stdio.h>
#include <string.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include "swaprep.h"
#include <X11/extensions/XResproto.h>
#include "pixmapstr.h"
#include "windowstr.h"
#include "gcstruct.h"
#include "extinit.h"
static int
ProcXResQueryVersion(ClientPtr client)
{
xXResQueryVersionReply rep;
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.server_major = XRES_MAJOR_VERSION;
rep.server_minor = XRES_MINOR_VERSION;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.server_major);
swaps(&rep.server_minor);
}
WriteToClient(client, sizeof(xXResQueryVersionReply), (char *) &rep);
return (client->noClientException);
}
static int
ProcXResQueryClients(ClientPtr client)
{
/* REQUEST(xXResQueryClientsReq); */
xXResQueryClientsReply rep;
int *current_clients;
int i, num_clients;
REQUEST_SIZE_MATCH(xXResQueryClientsReq);
current_clients = ALLOCATE_LOCAL((currentMaxClients - 1) * sizeof(int));
num_clients = 0;
for (i = 1; i < currentMaxClients; i++) {
if (clients[i]) {
current_clients[num_clients] = i;
num_clients++;
}
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_clients = num_clients;
rep.length = rep.num_clients * sz_xXResClient >> 2;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.num_clients);
}
WriteToClient(client, sizeof(xXResQueryClientsReply), (char *) &rep);
if (num_clients) {
xXResClient scratch;
for (i = 0; i < num_clients; i++) {
scratch.resource_base = clients[current_clients[i]]->clientAsMask;
scratch.resource_mask = RESOURCE_ID_MASK;
if (client->swapped) {
swapl(&scratch.resource_base);
swapl(&scratch.resource_mask);
}
WriteToClient(client, sz_xXResClient, (char *) &scratch);
}
}
DEALLOCATE_LOCAL(current_clients);
return (client->noClientException);
}
static void
ResFindAllRes(pointer value, XID id, RESTYPE type, pointer cdata)
{
int *counts = (int *) cdata;
counts[(type & TypeMask) - 1]++;
}
static int
ProcXResQueryClientResources(ClientPtr client)
{
REQUEST(xXResQueryClientResourcesReq);
xXResQueryClientResourcesReply rep;
int i, clientID, num_types;
int *counts;
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
clientID = CLIENT_ID(stuff->xid);
/* we could remove the (clientID == 0) check if we wanted to allow
probing the X-server's resource usage */
if (!clientID || (clientID >= currentMaxClients) || !clients[clientID]) {
client->errorValue = stuff->xid;
return BadValue;
}
counts = ALLOCATE_LOCAL((lastResourceType + 1) * sizeof(int));
memset(counts, 0, (lastResourceType + 1) * sizeof(int));
FindAllClientResources(clients[clientID], ResFindAllRes, counts);
num_types = 0;
for (i = 0; i <= lastResourceType; i++) {
if (counts[i])
num_types++;
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_types = num_types;
rep.length = rep.num_types * sz_xXResType >> 2;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.num_types);
}
WriteToClient(client, sizeof(xXResQueryClientResourcesReply),
(char *) &rep);
if (num_types) {
xXResType scratch;
for (i = 0; i < lastResourceType; i++) {
if (!counts[i])
continue;
if (!ResourceNames[i + 1]) {
char buf[40];
snprintf(buf, sizeof(buf), "Unregistered resource %i", i + 1);
RegisterResourceName(i + 1, buf);
}
scratch.resource_type = ResourceNames[i + 1];
scratch.count = counts[i];
if (client->swapped) {
swapl(&scratch.resource_type);
swapl(&scratch.count);
}
WriteToClient(client, sz_xXResType, (char *) &scratch);
}
}
DEALLOCATE_LOCAL(counts);
return (client->noClientException);
}
static unsigned long
ResGetApproxPixmapBytes(PixmapPtr pix)
{
unsigned long nPixels;
int bytesPerPixel;
bytesPerPixel = pix->drawable.bitsPerPixel >> 3;
nPixels = pix->drawable.width * pix->drawable.height;
/* Divide by refcnt as pixmap could be shared between clients,
* so total pixmap mem is shared between these.
*/
return (nPixels * bytesPerPixel) / pix->refcnt;
}
static void
ResFindPixmaps(pointer value, XID id, pointer cdata)
{
unsigned long *bytes = (unsigned long *) cdata;
PixmapPtr pix = (PixmapPtr) value;
*bytes += ResGetApproxPixmapBytes(pix);
}
static void
ResFindWindowPixmaps(pointer value, XID id, pointer cdata)
{
unsigned long *bytes = (unsigned long *) cdata;
WindowPtr pWin = (WindowPtr) value;
if (pWin->backgroundState == BackgroundPixmap)
*bytes += ResGetApproxPixmapBytes(pWin->background.pixmap);
if (pWin->border.pixmap != NULL && !pWin->borderIsPixel)
*bytes += ResGetApproxPixmapBytes(pWin->border.pixmap);
}
static void
ResFindGCPixmaps(pointer value, XID id, pointer cdata)
{
unsigned long *bytes = (unsigned long *) cdata;
GCPtr pGC = (GCPtr) value;
if (pGC->stipple != NULL)
*bytes += ResGetApproxPixmapBytes(pGC->stipple);
if (pGC->tile.pixmap != NULL && !pGC->tileIsPixel)
*bytes += ResGetApproxPixmapBytes(pGC->tile.pixmap);
}
static int
ProcXResQueryClientPixmapBytes(ClientPtr client)
{
REQUEST(xXResQueryClientPixmapBytesReq);
xXResQueryClientPixmapBytesReply rep;
int clientID;
unsigned long bytes;
REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
clientID = CLIENT_ID(stuff->xid);
/* we could remove the (clientID == 0) check if we wanted to allow
probing the X-server's resource usage */
if (!clientID || (clientID >= currentMaxClients) || !clients[clientID]) {
client->errorValue = stuff->xid;
return BadValue;
}
bytes = 0;
FindClientResourcesByType(clients[clientID], RT_PIXMAP, ResFindPixmaps,
(pointer) (&bytes));
/*
* Make sure win background pixmaps also held to account.
*/
FindClientResourcesByType(clients[clientID], RT_WINDOW,
ResFindWindowPixmaps, (pointer) (&bytes));
/*
* GC Tile & Stipple pixmaps too.
*/
FindClientResourcesByType(clients[clientID], RT_GC,
ResFindGCPixmaps, (pointer) (&bytes));
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
rep.bytes = bytes;
#ifdef _XSERVER64
rep.bytes_overflow = bytes >> 32;
#else
rep.bytes_overflow = 0;
#endif
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.bytes);
swapl(&rep.bytes_overflow);
}
WriteToClient(client, sizeof(xXResQueryClientPixmapBytesReply),
(char *) &rep);
return (client->noClientException);
}
static void
ResResetProc(ExtensionEntry * extEntry)
{
}
static int
ProcResDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_XResQueryVersion:
return ProcXResQueryVersion(client);
case X_XResQueryClients:
return ProcXResQueryClients(client);
case X_XResQueryClientResources:
return ProcXResQueryClientResources(client);
case X_XResQueryClientPixmapBytes:
return ProcXResQueryClientPixmapBytes(client);
default:
break;
}
return BadRequest;
}
static int
SProcXResQueryVersion(ClientPtr client)
{
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
return ProcXResQueryVersion(client);
}
static int
SProcXResQueryClientResources(ClientPtr client)
{
REQUEST(xXResQueryClientResourcesReq);
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
swapl(&stuff->xid);
return ProcXResQueryClientResources(client);
}
static int
SProcXResQueryClientPixmapBytes(ClientPtr client)
{
REQUEST(xXResQueryClientPixmapBytesReq);
REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
swapl(&stuff->xid);
return ProcXResQueryClientPixmapBytes(client);
}
static int
SProcResDispatch(ClientPtr client)
{
REQUEST(xReq);
swaps(&stuff->length);
switch (stuff->data) {
case X_XResQueryVersion:
return SProcXResQueryVersion(client);
case X_XResQueryClients: /* nothing to swap */
return ProcXResQueryClients(client);
case X_XResQueryClientResources:
return SProcXResQueryClientResources(client);
case X_XResQueryClientPixmapBytes:
return SProcXResQueryClientPixmapBytes(client);
default:
break;
}
return BadRequest;
}
void
ResExtensionInit(INITARGS)
{
(void) AddExtension(XRES_NAME, 0, 0,
ProcResDispatch, SProcResDispatch,
ResResetProc, StandardMinorOpcode);
RegisterResourceName(RT_NONE, "NONE");
RegisterResourceName(RT_WINDOW, "WINDOW");
RegisterResourceName(RT_PIXMAP, "PIXMAP");
RegisterResourceName(RT_GC, "GC");
RegisterResourceName(RT_FONT, "FONT");
RegisterResourceName(RT_CURSOR, "CURSOR");
RegisterResourceName(RT_COLORMAP, "COLORMAP");
RegisterResourceName(RT_CMAPENTRY, "COLORMAP ENTRY");
RegisterResourceName(RT_OTHERCLIENT, "OTHER CLIENT");
RegisterResourceName(RT_PASSIVEGRAB, "PASSIVE GRAB");
}

436
Xext/xtest.c Normal file
View File

@ -0,0 +1,436 @@
/*
Copyright 1992, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include "windowstr.h"
#include "inputstr.h"
#include "scrnintstr.h"
#include "dixevents.h"
#include "sleepuntil.h"
#define _XTEST_SERVER_
#include <X11/extensions/xtestproto.h>
#include "extinit.h"
#if 0
static unsigned char XTestReqCode;
#endif
static void XTestResetProc(ExtensionEntry * /* extEntry */
);
static int XTestSwapFakeInput(ClientPtr /* client */ ,
xReq * /* req */
);
static DISPATCH_PROC(ProcXTestCompareCursor);
static DISPATCH_PROC(ProcXTestDispatch);
static DISPATCH_PROC(ProcXTestFakeInput);
static DISPATCH_PROC(ProcXTestGetVersion);
static DISPATCH_PROC(ProcXTestGrabControl);
static DISPATCH_PROC(SProcXTestCompareCursor);
static DISPATCH_PROC(SProcXTestDispatch);
static DISPATCH_PROC(SProcXTestFakeInput);
static DISPATCH_PROC(SProcXTestGetVersion);
static DISPATCH_PROC(SProcXTestGrabControl);
void
XTestExtensionInit(INITARGS)
{
#if 0
ExtensionEntry *extEntry;
if ((extEntry = AddExtension(XTestExtensionName, 0, 0,
ProcXTestDispatch, SProcXTestDispatch,
XTestResetProc, StandardMinorOpcode)) != 0)
XTestReqCode = (unsigned char) extEntry->base;
#else
(void) AddExtension(XTestExtensionName, 0, 0,
ProcXTestDispatch, SProcXTestDispatch,
XTestResetProc, StandardMinorOpcode);
#endif
}
/*ARGSUSED*/ static void
XTestResetProc(extEntry)
ExtensionEntry *extEntry;
{
}
static int
ProcXTestGetVersion(client)
ClientPtr client;
{
xXTestGetVersionReply rep;
REQUEST_SIZE_MATCH(xXTestGetVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = XTestMajorVersion;
rep.minorVersion = XTestMinorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.minorVersion);
}
WriteToClient(client, sizeof(xXTestGetVersionReply), (char *) &rep);
return (client->noClientException);
}
static int
ProcXTestCompareCursor(client)
ClientPtr client;
{
REQUEST(xXTestCompareCursorReq);
xXTestCompareCursorReply rep;
WindowPtr pWin;
CursorPtr pCursor;
REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
pWin = (WindowPtr) LookupWindow(stuff->window, client);
if (!pWin)
return (BadWindow);
if (stuff->cursor == None)
pCursor = NullCursor;
else if (stuff->cursor == XTestCurrentCursor)
pCursor = GetSpriteCursor();
else {
pCursor = (CursorPtr) LookupIDByType(stuff->cursor, RT_CURSOR);
if (!pCursor) {
client->errorValue = stuff->cursor;
return (BadCursor);
}
}
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.same = (wCursor(pWin) == pCursor);
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
WriteToClient(client, sizeof(xXTestCompareCursorReply), (char *) &rep);
return (client->noClientException);
}
static int
ProcXTestFakeInput(client)
ClientPtr client;
{
REQUEST(xXTestFakeInputReq);
int nev;
xEvent *ev;
DeviceIntPtr dev = NULL;
WindowPtr root;
int type;
nev = (stuff->length << 2) - sizeof(xReq);
if ((nev % sizeof(xEvent)) || !nev)
return BadLength;
nev /= sizeof(xEvent);
UpdateCurrentTime();
ev = (xEvent *) &((xReq *) stuff)[1];
type = ev->u.u.type & 0177;
{
if (nev != 1)
return BadLength;
switch (type) {
case KeyPress:
case KeyRelease:
case MotionNotify:
case ButtonPress:
case ButtonRelease:
break;
default:
client->errorValue = ev->u.u.type;
return BadValue;
}
}
if (ev->u.keyButtonPointer.time) {
TimeStamp activateTime;
CARD32 ms;
activateTime = currentTime;
ms = activateTime.milliseconds + ev->u.keyButtonPointer.time;
if (ms < activateTime.milliseconds)
activateTime.months++;
activateTime.milliseconds = ms;
ev->u.keyButtonPointer.time = 0;
/* see mbuf.c:QueueDisplayRequest for code similar to this */
if (!ClientSleepUntil(client, &activateTime, NULL, NULL)) {
return BadAlloc;
}
/* swap the request back so we can simply re-execute it */
if (client->swapped) {
(void) XTestSwapFakeInput(client, (xReq *) stuff);
swaps(&stuff->length);
}
ResetCurrentRequest(client);
client->sequence--;
return Success;
}
switch (type) {
case KeyPress:
case KeyRelease:
dev = (DeviceIntPtr) LookupKeyboardDevice();
if (ev->u.u.detail < dev->key->curKeySyms.minKeyCode ||
ev->u.u.detail > dev->key->curKeySyms.maxKeyCode) {
client->errorValue = ev->u.u.detail;
return BadValue;
}
break;
case MotionNotify:
dev = (DeviceIntPtr) LookupPointerDevice();
if (ev->u.keyButtonPointer.root == None)
root = GetCurrentRootWindow();
else {
root = LookupWindow(ev->u.keyButtonPointer.root, client);
if (!root)
return BadWindow;
if (root->parent) {
client->errorValue = ev->u.keyButtonPointer.root;
return BadValue;
}
}
if (ev->u.u.detail == xTrue) {
int x, y;
GetSpritePosition(&x, &y);
ev->u.keyButtonPointer.rootX += x;
ev->u.keyButtonPointer.rootY += y;
}
else if (ev->u.u.detail != xFalse) {
client->errorValue = ev->u.u.detail;
return BadValue;
}
if (ev->u.keyButtonPointer.rootX < 0)
ev->u.keyButtonPointer.rootX = 0;
else if (ev->u.keyButtonPointer.rootX >= root->drawable.width)
ev->u.keyButtonPointer.rootX = root->drawable.width - 1;
if (ev->u.keyButtonPointer.rootY < 0)
ev->u.keyButtonPointer.rootY = 0;
else if (ev->u.keyButtonPointer.rootY >= root->drawable.height)
ev->u.keyButtonPointer.rootY = root->drawable.height - 1;
if (root != GetCurrentRootWindow())
{
NewCurrentScreen(root->drawable.pScreen,
ev->u.keyButtonPointer.rootX,
ev->u.keyButtonPointer.rootY);
return client->noClientException;
}
(*root->drawable.pScreen->SetCursorPosition)
(root->drawable.pScreen,
ev->u.keyButtonPointer.rootX, ev->u.keyButtonPointer.rootY, FALSE);
break;
case ButtonPress:
case ButtonRelease:
dev = (DeviceIntPtr) LookupPointerDevice();
if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) {
client->errorValue = ev->u.u.detail;
return BadValue;
}
break;
}
if (screenIsSaved == SCREEN_SAVER_ON)
SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset);
ev->u.keyButtonPointer.time = currentTime.milliseconds;
(*dev->public.processInputProc) (ev, dev, nev);
return client->noClientException;
}
static int
ProcXTestGrabControl(client)
ClientPtr client;
{
REQUEST(xXTestGrabControlReq);
REQUEST_SIZE_MATCH(xXTestGrabControlReq);
if ((stuff->impervious != xTrue) && (stuff->impervious != xFalse)) {
client->errorValue = stuff->impervious;
return (BadValue);
}
if (stuff->impervious)
MakeClientGrabImpervious(client);
else
MakeClientGrabPervious(client);
return (client->noClientException);
}
static int
ProcXTestDispatch(client)
ClientPtr client;
{
REQUEST(xReq);
switch (stuff->data) {
case X_XTestGetVersion:
return ProcXTestGetVersion(client);
case X_XTestCompareCursor:
return ProcXTestCompareCursor(client);
case X_XTestFakeInput:
return ProcXTestFakeInput(client);
case X_XTestGrabControl:
return ProcXTestGrabControl(client);
default:
return BadRequest;
}
}
static int
SProcXTestGetVersion(client)
ClientPtr client;
{
REQUEST(xXTestGetVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXTestGetVersionReq);
swaps(&stuff->minorVersion);
return ProcXTestGetVersion(client);
}
static int
SProcXTestCompareCursor(client)
ClientPtr client;
{
REQUEST(xXTestCompareCursorReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
swapl(&stuff->window);
swapl(&stuff->cursor);
return ProcXTestCompareCursor(client);
}
static int
XTestSwapFakeInput(client, req)
ClientPtr client;
xReq *req;
{
int nev;
xEvent *ev;
xEvent sev;
EventSwapPtr proc;
nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent);
for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) {
/* Swap event */
proc = EventSwapVector[ev->u.u.type & 0177];
/* no swapping proc; invalid event type? */
if (!proc || proc == NotImplemented) {
client->errorValue = ev->u.u.type;
return BadValue;
}
(*proc) (ev, &sev);
*ev = sev;
}
return Success;
}
static int
SProcXTestFakeInput(client)
ClientPtr client;
{
REQUEST(xReq);
swaps(&stuff->length);
int n = XTestSwapFakeInput(client, stuff);
if (n != Success)
return n;
return ProcXTestFakeInput(client);
}
static int
SProcXTestGrabControl(client)
ClientPtr client;
{
REQUEST(xXTestGrabControlReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXTestGrabControlReq);
return ProcXTestGrabControl(client);
}
static int
SProcXTestDispatch(client)
ClientPtr client;
{
REQUEST(xReq);
switch (stuff->data) {
case X_XTestGetVersion:
return SProcXTestGetVersion(client);
case X_XTestCompareCursor:
return SProcXTestCompareCursor(client);
case X_XTestFakeInput:
return SProcXTestFakeInput(client);
case X_XTestGrabControl:
return SProcXTestGrabControl(client);
default:
return BadRequest;
}
}

10
autogen.sh Executable file
View File

@ -0,0 +1,10 @@
#! /bin/sh
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
ORIGDIR=`pwd`
cd $srcdir
autoreconf -v --install || exit 1
cd $ORIGDIR || exit $?

687
configure.ac Normal file
View File

@ -0,0 +1,687 @@
dnl Copyright © 2003-2005 Keith Packard, Daniel Stone
dnl Copyright © 2013 Lauri Kasanen
dnl
dnl Permission to use, copy, modify, distribute, and sell this software and its
dnl documentation for any purpose is hereby granted without fee, provided that
dnl the above copyright notice appear in all copies and that both that
dnl copyright notice and this permission notice appear in supporting
dnl documentation, and that the names of Keith Packard and Daniel Stone not be
dnl used in advertising or publicity pertaining to distribution of the software
dnl without specific, written prior permission. Keith Packard and Daniel Stone
dnl make no representations about the suitability of this software for any
dnl purpose. It is provided "as is" without express or implied warranty.
dnl
dnl KEITH PACKARD AND DANIEL STONE DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
dnl SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
dnl IN NO EVENT SHALL KEITH PACKARD OR DANIEL STONE BE LIABLE FOR ANY SPECIAL,
dnl INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dnl LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dnl OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dnl PERFORMANCE OF THIS SOFTWARE.
dnl
dnl Process this file with autoconf to create configure.
AC_PREREQ(2.57)
AC_INIT([tinyx], 1.0)
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip foreign -Wall])
dnl this gets generated by autoheader, and thus contains all the defines. we
dnl don't ever actually use it, internally.
AC_CONFIG_HEADERS(include/do-not-use-config.h)
dnl dix-config.h covers most of the DIX (i.e. everything but the DDX, not just
dnl dix/).
AC_CONFIG_HEADERS(include/dix-config.h)
dnl kdrive-config.h covers the kdrive DDX
AC_CONFIG_HEADERS(include/kdrive-config.h)
AC_PROG_CC
AM_PROG_AS
AC_PROG_INSTALL
AC_PROG_LN_S
AC_DISABLE_SHARED
AC_PROG_LIBTOOL
PKG_PROG_PKG_CONFIG
AC_PROG_LEX
AC_PROG_YACC
XORG_PROG_RAWCPP
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_BIGENDIAN([ENDIAN="X_BIG_ENDIAN"], [ENDIAN="X_LITTLE_ENDIAN"])
AC_CHECK_SIZEOF([unsigned long])
if test "$ac_cv_sizeof_unsigned_long" = 8; then
AC_DEFINE(_XSERVER64, 1, [Define to 1 if unsigned long is 64 bits.])
fi
AC_TYPE_PID_T
dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
strtol getopt getopt_long vsnprintf])
AC_FUNC_ALLOCA
dnl Old HAS_* names used in os/*.c.
AC_CHECK_FUNC([getdtablesize],
AC_DEFINE(HAS_GETDTABLESIZE, 1, [Have the `getdtablesize' function.]))
AC_CHECK_FUNC([getifaddrs],
AC_DEFINE(HAS_GETIFADDRS, 1, [Have the `getifaddrs' function.]))
AC_CHECK_FUNC([getpeereid],
AC_DEFINE(HAS_GETPEEREID, 1, [Have the `getpeereid' function.]))
AC_CHECK_FUNC([getpeerucred],
AC_DEFINE(HAS_GETPEERUCRED, 1, [Have the `getpeerucred' function.]))
AC_CHECK_FUNC([strlcat], HAVE_STRLCAT=yes, HAVE_STRLCAT=no)
AM_CONDITIONAL(NEED_STRLCAT, [test x$HAVE_STRLCAT = xno])
AM_CONDITIONAL(NEED_VSNPRINTF, [test x$HAVE_VSNPRINTF = xno])
dnl Check for mmap support for Xvfb
AC_CHECK_FUNC([mmap], AC_DEFINE(HAS_MMAP, 1, [Have the `mmap' function.]))
dnl Find the math libary
AC_CHECK_LIB(m, sqrt)
dnl APM header
AC_CHECK_HEADERS([linux/apm_bios.h], LNXAPM=yes)
AM_CONDITIONAL(LNXAPM, [test "x$LNXAPM" = xyes])
dnl fbdev header
AC_CHECK_HEADERS([linux/fb.h], FBDEV=yes)
AM_CONDITIONAL(FBDEVHW, [test "x$FBDEV" = xyes])
dnl MTRR header
AC_CHECK_HEADERS([asm/mtrr.h], ac_cv_asm_mtrr_h=yes)
if test "x$ac_cv_asm_mtrr_h" = xyes; then
HAVE_MTRR=yes
fi
dnl BSD MTRR header
AC_CHECK_HEADERS([sys/memrange.h], ac_cv_memrange_h=yes)
if test "x$ac_cv_memrange_h" = xyes; then
HAVE_MTRR=yes
fi
if test "x$HAVE_MTRR" = xyes; then
AC_DEFINE(HAS_MTRR_SUPPORT, 1, [MTRR support available])
fi
dnl A NetBSD MTRR header
AC_CHECK_HEADERS([machine/mtrr.h], ac_cv_machine_mtrr_h=yes)
if test "x$ac_cv_machine_mtrr_h" = xyes; then
AC_DEFINE(HAS_MTRR_BUILTIN, 1, [Define to 1 if NetBSD built-in MTRR
support is available])
fi
dnl FreeBSD kldload support (sys/linker.h)
AC_CHECK_HEADERS([sys/linker.h],
[ac_cv_sys_linker_h=yes],
[ac_cv_sys_linker_h=no],
[#include <sys/param.h>])
AM_CONDITIONAL(FREEBSD_KLDLOAD, [test "x$ac_cv_sys_linker_h" = xyes])
AC_CACHE_CHECK([for SYSV IPC],
ac_cv_sysv_ipc,
[AC_TRY_LINK([
#include <sys/shm.h>
],[
{
int id;
id = shmget(IPC_PRIVATE, 512, SHM_W | SHM_R);
if (id < 0) return -1;
return shmctl(id, IPC_RMID, 0);
}],
[ac_cv_sysv_ipc=yes],
[ac_cv_sysv_ipc=no])])
if test "x$ac_cv_sysv_ipc" = xyes; then
AC_DEFINE(HAVE_SYSV_IPC, 1, [Define to 1 if SYSV IPC is available])
fi
dnl ---------------------------------------------------------------------------
dnl Bus options and CPU capabilities. Replaces logic in
dnl hw/xfree86/os-support/bus/Makefile.am, among others.
dnl ---------------------------------------------------------------------------
DEFAULT_INT10="x86emu"
dnl Override defaults as needed for specific platforms:
case $host_cpu in
alpha*)
ALPHA_VIDEO=yes
case $host_os in
*netbsd*) AC_DEFINE(USE_ALPHA_PIO, 1, [NetBSD PIO alpha IO]) ;;
esac
;;
arm*)
ARM_VIDEO=yes
;;
i*86)
I386_VIDEO=yes
case $host_os in
*linux*) DEFAULT_INT10=vm86 ;;
*freebsd*) AC_DEFINE(USE_DEV_IO) ;;
*netbsd*) AC_DEFINE(USE_I386_IOPL)
SYS_LIBS=-li386
;;
*openbsd*) AC_DEFINE(USE_I386_IOPL)
SYS_LIBS=-li386
;;
esac
;;
powerpc*)
PPC_VIDEO=yes
case $host_os in
*freebsd*) DEFAULT_INT10=stub ;;
esac
;;
sparc*)
xorg_loader_sparcmuldiv="yes"
SPARC64_VIDEO=yes
BSD_ARCH_SOURCES="sparc64_video.c ioperm_noop.c"
;;
x86_64*|amd64*)
I386_VIDEO=yes
case $host_os in
*freebsd*) AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;;
*netbsd*) AC_DEFINE(USE_I386_IOPL, 1, [BSD i386 iopl])
SYS_LIBS=-lx86_64
;;
*openbsd*) AC_DEFINE(USE_AMD64_IOPL, 1, [BSD AMD64 iopl])
SYS_LIBS=-lamd64
;;
esac
;;
esac
dnl BSD *_video.c selection
AM_CONDITIONAL(ALPHA_VIDEO, [test "x$ALPHA_VIDEO" = xyes])
AM_CONDITIONAL(ARM_VIDEO, [test "x$ARM_VIDEO" = xyes])
AM_CONDITIONAL(I386_VIDEO, [test "x$I386_VIDEO" = xyes])
AM_CONDITIONAL(PPC_VIDEO, [test "x$PPC_VIDEO" = xyes])
AM_CONDITIONAL(SPARC64_VIDEO, [test "x$SPARC64_VIDEO" = xyes])
DRI=no
dnl it would be nice to autodetect these *CONS_SUPPORTs
case $host_os in
*freebsd*)
case $host_os in
kfreebsd*-gnu) ;;
*) AC_DEFINE(CSRG_BASED, 1, [System is BSD-like]) ;;
esac
AC_DEFINE(PCCONS_SUPPORT, 1, [System has PC console])
AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
AC_DEFINE(SYSCONS_SUPPORT, 1, [System has syscons console])
;;
*netbsd*)
AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
AC_DEFINE(PCCONS_SUPPORT, 1, [System has PC console])
AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
;;
*openbsd*)
AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
AC_DEFINE(PCVT_SUPPORT, 1, [System has PC console])
AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
;;
esac
OSNAME=`uname -srm`
AC_DEFINE_UNQUOTED(OSNAME, "$OSNAME",
[Define to OS Name string to display for build OS in Xorg log])
DEFAULT_VENDOR_NAME="TinyCore Linux"
DEFAULT_VENDOR_NAME_SHORT="TinyCore"
VERSION_MAJOR=1
VERSION_MINOR=0
VERSION_PATCH=0
VERSION_SNAP=0
RELEASE_DATE="9 Nov 2013"
DEFAULT_VENDOR_WEB="http://tinycorelinux.com"
m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])
dnl Build options.
AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror],
[Treat warnings as errors (default: disabled)]),
[WERROR=$enableval], [WERROR=no])
AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],
[Enable debugging (default: disabled)]),
[DEBUGGING=$enableval], [DEBUGGING=no])
AC_ARG_WITH(int10, AS_HELP_STRING([--with-int10=BACKEND], [int10 backend: vm86, x86emu or stub]),
[INT10="$withval"],
[INT10="$DEFAULT_INT10"])
AC_ARG_WITH(vendor-name, AS_HELP_STRING([--with-vendor-string=VENDOR],
[Vendor string reported by the server]),
[ VENDOR_STRING="$withval" ],
[ VENDOR_STRING="$DEFAULT_VENDOR_NAME" ])
AC_ARG_WITH(vendor-name-short, AS_HELP_STRING([--with-vendor-string-short=VENDOR],
[Short version of vendor string reported by the server]),
[ VENDOR_STRING_SHORT="$withval" ],
[ VENDOR_STRING_SHORT="$DEFAULT_VENDOR_NAME_SHORT" ])
AC_ARG_WITH(vendor-web, AS_HELP_STRING([--with-vendor-web=URL],
[Vendor web address reported by the server]),
[ VENDOR_WEB="$withval" ],
[ VENDOR_WEB="$DEFAULT_VENDOR_WEB" ])
AC_ARG_WITH(builder-addr, AS_HELP_STRING([--with-builder-addr=ADDRESS],
[Builder address (default: xorg@lists.freedesktop.org)]),
[ BUILDERADDR="$withval" ],
[ BUILDERADDR="xorg@lists.freedesktop.org" ])
AC_ARG_WITH(fontdir, AS_HELP_STRING([--with-fontdir=FONTDIR], [Path to top level dir where fonts are installed (default: ${libdir}/X11/fonts)]),
[ FONTDIR="$withval" ],
[ FONTDIR="${libdir}/X11/fonts" ])
DEFAULT_FONT_PATH="${FONTDIR}/misc/,${FONTDIR}/TTF/,${FONTDIR}/OTF,${FONTDIR}/Type1/,${FONTDIR}/100dpi/,${FONTDIR}/75dpi/"
AC_ARG_WITH(default-font-path, AS_HELP_STRING([--with-default-font-path=PATH], [Comma separated list of font dirs]),
[ FONTPATH="$withval" ],
[ FONTPATH="${DEFAULT_FONT_PATH}" ])
dnl Extensions.
AC_ARG_ENABLE(xres, AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
AC_ARG_ENABLE(screensaver, AS_HELP_STRING([--disable-screensaver], [Build ScreenSaver extension (default: enabled)]), [SCREENSAVER=$enableval], [SCREENSAVER=yes])
AC_ARG_ENABLE(xdmcp, AS_HELP_STRING([--disable-xdmcp], [Build XDMCP extension (default: auto)]), [XDMCP=$enableval], [XDMCP=auto])
AC_ARG_ENABLE(xdm-auth-1, AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), [XDMAUTH=$enableval], [XDMAUTH=auto])
AC_ARG_ENABLE(dbe, AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes])
AC_ARG_ENABLE(xf86bigfont, AS_HELP_STRING([--disable-xf86bigfont], [Build XF86 Big Font extension (default: enabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=yes])
AC_ARG_ENABLE(dpms, AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes])
dnl kdrive and its subsystems
AC_ARG_ENABLE(kdrive, AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: yes)]), [KDRIVE=$enableval], [KDRIVE=yes])
dnl chown/chmod to be setuid root as part of build
dnl Replaces InstallXserverSetUID in imake
AC_ARG_ENABLE(install-setuid,
AS_HELP_STRING([--enable-install-setuid],
[Install Xorg server as owned by root with setuid bit (default: auto)]),
[SETUID=$enableval], [SETUID=auto])
AC_MSG_CHECKING([to see if we can install the Xorg server as root])
if test "x$SETUID" = "xauto" ; then
case $host_os in
darwin*) SETUID="no" ;;
*)
case $host_cpu in
sparc) SETUID="no" ;;
*) SETUID="yes" ;;
esac
esac
if test "x$SETUID" = xyes; then
touch testfile
chown root testfile > /dev/null 2>&1 || SETUID="no"
rm -f testfile
fi
fi
AC_MSG_RESULT([$SETUID])
AM_CONDITIONAL(INSTALL_SETUID, [test "x$SETUID" = "xyes"])
dnl Issue an error if xtrans.m4 was not found and XTRANS_CONNECTION_FLAGS macro
dnl was not expanded, since xorg-server with no transport types is rather useless.
dnl
dnl If you're seeing an error here, be sure you installed the lib/xtrans module
dnl first and if it's not in the default location, that you set the ACLOCAL
dnl environment variable to find it, such as:
dnl ACLOCAL="aclocal -I ${PREFIX}/share/aclocal"
m4_pattern_forbid([^XTRANS_CONNECTION_FLAGS$])
# Transport selection macro from xtrans.m4
XTRANS_CONNECTION_FLAGS
# Secure RPC detection macro from xtrans.m4
XTRANS_SECURE_RPC_FLAGS
AM_CONDITIONAL(INT10_VM86, [test "x$INT10" = xvm86])
AM_CONDITIONAL(INT10_X86EMU, [test "x$INT10" = xx86emu])
AM_CONDITIONAL(INT10_STUB, [test "x$INT10" = xstub])
if test "x$INT10" = xyes; then
dnl VM86 headers
AC_CHECK_HEADERS([sys/vm86.h sys/io.h])
fi
dnl ---------------------------------------------------------------------------
dnl Extension section
dnl ---------------------------------------------------------------------------
XEXT_INC='-I$(top_srcdir)/Xext'
XEXT_LIB='$(top_builddir)/Xext/libXext.la'
XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
dnl Core modules for most extensions, et al.
REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto xproto xtrans xf86bigfontproto [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto inputproto [kbproto >= 1.0.3]"
REQUIRED_LIBS="xfont fontenc"
AM_CONDITIONAL(SCREENSAVER, [test "x$SCREENSAVER" = xyes])
if test "x$SCREENSAVER" = xyes; then
AC_DEFINE(SCREENSAVER, 1, [Support MIT-SCREEN-SAVER extension])
fi
AM_CONDITIONAL(RES, [test "x$RES" = xyes])
if test "x$RES" = xyes; then
AC_DEFINE(RES, 1, [Support X resource extension])
REQUIRED_MODULES="$REQUIRED_MODULES resourceproto"
fi
AM_CONDITIONAL(DBE, [test "x$DBE" = xyes])
if test "x$DBE" = xyes; then
AC_DEFINE(DBE, 1, [Support DBE extension])
DBE_LIB='$(top_builddir)/dbe/libdbe.la'
fi
AM_CONDITIONAL(XF86BIGFONT, [test "x$XF86BIGFONT" = xyes])
if test "x$XF86BIGFONT" = xyes; then
AC_DEFINE(XF86BIGFONT, 1, [Support XF86 Big font extension])
fi
AM_CONDITIONAL(DPMSExtension, [test "x$DPMSExtension" = xyes])
if test "x$DPMSExtension" = xyes; then
AC_DEFINE(DPMSExtension, 1, [Support DPMS extension])
fi
RENDER_LIB='$(top_builddir)/render/librender.la'
RENDER_INC='-I$(top_srcdir)/render'
RANDR_LIB='$(top_builddir)/randr/librandr.la'
RANDR_INC='-I$(top_srcdir)/randr'
FIXES_LIB='$(top_builddir)/xfixes/libxfixes.la'
FIXES_INC='-I$(top_srcdir)/xfixes'
DAMAGE_LIB='$(top_builddir)/damageext/libdamageext.la'
DAMAGE_INC='-I$(top_srcdir)/damageext'
MIEXT_DAMAGE_LIB='$(top_builddir)/miext/damage/libdamage.la'
MIEXT_DAMAGE_INC='-I$(top_srcdir)/miext/damage'
AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1,
[Do not have `strcasecmp'.]))
PKG_CHECK_MODULES([XDMCP], [xdmcp], [have_libxdmcp="yes"], [have_libxdmcp="no"])
if test "x$have_libxdmcp" = xyes; then
AC_CHECK_LIB(Xdmcp, XdmcpWrap, [have_xdmcpwrap="yes"], [have_xdmcpwrap="no"], [$XDMCP_LIBS])
fi
if test "x$XDMCP" = xauto; then
if test "x$have_libxdmcp" = xyes; then
XDMCP=yes
else
XDMCP=no
fi
fi
if test "x$XDMAUTH" = xauto; then
if test "x$have_libxdmcp" = xyes && test "x$have_xdmcpwrap" = xyes; then
XDMAUTH=yes
else
XDMAUTH=no
fi
fi
AM_CONDITIONAL(XDMCP, [test "x$XDMCP" = xyes])
if test "x$XDMCP" = xyes; then
AC_DEFINE(XDMCP, 1, [Support XDM Control Protocol])
REQUIRED_LIBS="$REQUIRED_LIBS xdmcp"
XDMCP_MODULES="xdmcp"
fi
AM_CONDITIONAL(XDMAUTH, [test "x$XDMAUTH" = xyes])
if test "x$XDMAUTH" = xyes; then
AC_DEFINE(HASXDMAUTH,1,[Support XDM-AUTH*-1])
if ! test "x$XDMCP" = xyes; then
REQUIRED_LIBS="$REQUIRED_LIBS xdmcp"
XDMCP_MODULES="xdmcp"
fi
fi
VENDOR_RELEASE="((($VERSION_MAJOR) * 10000000) + (($VERSION_MINOR) * 100000) + (($VERSION_PATCH) * 1000) + $VERSION_SNAP)"
if test $VERSION_SNAP = "0"; then
if test $VERSION_PATCH = "0"; then
VENDOR_VERSION_STRING="${VERSION_MAJOR}.${VERSION_MINOR}"
else
VENDOR_VERSION_STRING="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
fi
else
VENDOR_VERSION_STRING="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_SNAP}"
fi
VENDOR_RELEASE_STRING="Release ${VENDOR_VERSION_STRING}"
VENDOR_MAN_VERSION="Version ${VENDOR_VERSION_STRING}"
AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
AC_DEFINE_DIR(BASE_FONT_PATH, FONTDIR, [Default base font path])
AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_STRING"], [Vendor name])
AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_STRING_SHORT"], [Short vendor name])
AC_DEFINE_UNQUOTED(XORG_RELEASE, ["$VENDOR_RELEASE_STRING"], [Vendor release])
AC_DEFINE_UNQUOTED(XORG_DATE, ["$RELEASE_DATE"], [Vendor release])
AC_DEFINE_UNQUOTED(XORG_MAN_VERSION, ["$VENDOR_MAN_VERSION"], [Vendor man version])
AC_DEFINE_UNQUOTED(BUILDERADDR, ["$BUILDERADDR"], [Builder address])
AC_DEFINE_UNQUOTED(OSNAME, ["$OSNAME"], [Operating System Name])
AC_SUBST([VENDOR_STRING])
AC_SUBST([VENDOR_STRING_SHORT])
AC_SUBST([VENDOR_RELEASE])
AC_SUBST([VENDOR_MAN_VERSION])
AC_DEFINE(SMART_SCHEDULE, 1, [Include time-based scheduler])
AM_CONDITIONAL(DEBUG, test "x$DEBUGGING" = xyes)
if ! test "x$DEBUGGING" = xyes; then
AC_DEFINE(NDEBUG, 1, [Disable some debugging code])
fi
DIX_LIB='$(top_builddir)/dix/libdix.la'
OS_LIB='$(top_builddir)/os/libos.la'
MI_LIB='$(top_builddir)/mi/libmi.la'
MI_EXT_LIB='$(top_builddir)/mi/libmiext.la'
MI_INC='-I$(top_srcdir)/mi'
FB_LIB='$(top_builddir)/fb/libfb.la'
FB_INC='-I$(top_srcdir)/fb'
MIEXT_SHADOW_INC='-I$(top_srcdir)/miext/shadow'
MIEXT_SHADOW_LIB='$(top_builddir)/miext/shadow/libshadow.la'
CORE_INCS='-I$(top_srcdir)/include -I$(top_builddir)/include'
PKG_CHECK_MODULES([XSERVERCFLAGS], [$REQUIRED_MODULES $REQUIRED_LIBS])
PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])
XSERVER_CFLAGS="${XSERVERCFLAGS_CFLAGS}"
XSERVER_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} -lm"
AC_SUBST([SYS_LIBS])
AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes],
[AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
[have_clock_gettime=no])])
AC_MSG_CHECKING([for a useful monotonic clock ...])
if ! test "x$have_clock_gettime" = xno; then
if ! test "x$have_clock_gettime" = xyes; then
LIBS="$have_clock_gettime"
else
LIBS=""
fi
AC_RUN_IFELSE([AC_LANG_SOURCE([
#define _POSIX_C_SOURCE 199309L
#include <time.h>
int main(int argc, char *argv[]) {
struct timespec tp;
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
return 0;
else
return 1;
}
])], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no],
[MONOTONIC_CLOCK="cross compiling"])
else
MONOTONIC_CLOCK=no
fi
AC_MSG_RESULT([$MONOTONIC_CLOCK])
if test "x$MONOTONIC_CLOCK" = xyes; then
AC_DEFINE(MONOTONIC_CLOCK, 1, [Have monotonic clock from clock_gettime()])
XSERVER_LIBS="$XSERVER_LIBS $LIBS"
fi
XSERVER_CFLAGS="$XSERVER_CFLAGS $CORE_INCS $XEXT_INC $DAMAGE_INC $FIXES_INC $MI_INC $MIEXT_SHADOW_INC $MIEXT_LAYER_INC $MIEXT_DAMAGE_INC $RENDER_INC $RANDR_INC $FB_INC"
AC_DEFINE_UNQUOTED(X_BYTE_ORDER,[$ENDIAN],[Endian order])
AC_SUBST([XSERVER_LIBS])
dnl ---------------------------------------------------------------------------
dnl DDX section.
dnl ---------------------------------------------------------------------------
# XORG_CORE_LIBS is needed even if you're not building the Xorg DDX
XORG_CORE_LIBS="$DIX_LIB"
AC_SUBST([XORG_CORE_LIBS])
xorg_bus_linuxpci=no
xorg_bus_freebsdpci=no
xorg_bus_netbsdpci=no
xorg_bus_ix86pci=no
xorg_bus_ppcpci=no
xorg_bus_sparcpci=no
xorg_bus_sparc=no
AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
AM_CONDITIONAL([XORG_BUS_FREEBSDPCI], [test "x$xorg_bus_freebsdpci" = xyes])
AM_CONDITIONAL([XORG_BUS_NETBSDPCI], [test "x$xorg_bus_netbsdpci" = xyes])
AM_CONDITIONAL([XORG_BUS_IX86PCI], [test "x$xorg_bus_ix86pci" = xyes])
AM_CONDITIONAL([XORG_BUS_PPCPCI], [test "x$xorg_bus_ppcpci" = xyes])
AM_CONDITIONAL([XORG_BUS_SPARCPCI], [test "x$xorg_bus_sparcpci" = xyes])
AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes])
AM_CONDITIONAL([XORG_LOADER_SPARC], [test "x$xorg_loader_sparcmuldiv" = xyes])
AM_CONDITIONAL([LINUX_IA64], [test "x$linux_ia64" = xyes])
AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes])
AM_CONDITIONAL([LNXACPI], [test "x$linux_acpi" = xyes])
dnl kdrive DDX
AM_CONDITIONAL(KDRIVE, [test x$KDRIVE = xyes])
if test "$KDRIVE" = yes; then
AC_DEFINE(KDRIVESERVER,1,[Build Kdrive X server])
AC_DEFINE(KDRIVEDDXACTIONS,,[Build kdrive ddx])
AC_CHECK_HEADERS([asm/vm86.h sys/io.h])
if test "$ac_cv_header_asm_vm86_h" = yes; then
AC_DEFINE(KDRIVEVESA, 1, [Build VESA-based kdrive servers])
fi
AC_CHECK_HEADERS([linux/fb.h])
if test "$ac_cv_header_linux_fb_h" = yes; then
AC_DEFINE(KDRIVEFBDEV, 1, [Build fbdev-based kdrive server])
fi
# damage shadow extension fb mi
KDRIVE_INC='-I$(top_srcdir)/kdrive/src'
KDRIVE_PURE_INCS="$KDRIVE_INC $MIEXT_DAMAGE_INC $MIEXT_SHADOW_INC $XEXT_INC $FB_INC $MI_INC"
KDRIVE_OS_INC='-I$(top_srcdir)/kdrive/linux'
KDRIVE_INCS="$KDRIVE_PURE_INCS $KDRIVE_OS_INC"
KDRIVE_CFLAGS="$XSERVER_CFLAGS -DHAVE_KDRIVE_CONFIG_H"
# dix os fb mi extension glx (NOTYET) damage shadow
#KDRIVE_PURE_LIBS="$DIX_LIB $OS_LIB $FB_LIB $XEXT_LIB $MIEXT_DAMAGE_LIB \
# $MIEXT_SHADOW_LIB"
KDRIVE_PURE_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $OS_LIB"
KDRIVE_LIB='$(top_builddir)/kdrive/src/libkdrive.a'
case $host_os in
*linux*)
KDRIVE_OS_LIB='$(top_builddir)/kdrive/linux/liblinux.a'
KDRIVELINUX=yes
;;
esac
KDRIVE_STUB_LIB='$(top_builddir)/kdrive/src/libkdrivestubs.a'
KDRIVE_LIBS="$DIX_LIB $KDRIVE_LIB $KDRIVE_OS_LIB $KDRIVE_PURE_LIBS $KDRIVE_STUB_LIB"
fi
AC_SUBST(KDRIVE_INCS)
AC_SUBST(KDRIVE_PURE_INCS)
AC_SUBST(KDRIVE_CFLAGS)
AC_SUBST(KDRIVE_PURE_LIBS)
AC_SUBST(KDRIVE_LIBS)
AM_CONDITIONAL(KDRIVELINUX, [test "x$KDRIVELINUX" = xyes])
AM_CONDITIONAL(KDRIVEVESA, [test x"$ac_cv_header_asm_vm86_h" = xyes])
AM_CONDITIONAL(KDRIVEFBDEV, [test x"$ac_cv_header_linux_fb_h" = xyes])
dnl and the rest of these are generic, so they're in config.h
AC_DEFINE(XResExtension, 1, [Build XRes extension])
AC_TRY_COMPILE([
#include <features.h>
#ifndef __GLIBC__
#error not glibc
#endif
], [], [AC_DEFINE(_GNU_SOURCE, 1,
[ Enable GNU and other extensions to the C environment for glibc])])
dnl ---------- Compiler arguments
AX_CHECK_COMPILE_FLAG([-flto],
[CFLAGS="$CFLAGS -flto"; LDFLAGS="$LDFLAGS -flto"; ac_cv_lto_supported=yes],
[ac_cv_lto_supported=no],
[])
if test x"$ac_cv_lto_supported" = xno; then
AC_MSG_NOTICE([LTO not supported, checking sections instead...])
AX_CHECK_COMPILE_FLAG([-ffunction-sections],
[CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
LDFLAGS="$LDFLAGS -Wl,-gc-sections"
ac_cv_sections_supported=yes],
[ac_cv_sections_supported=no],
[])
fi
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],
[CFLAGS="$CFLAGS -fvisibility=hidden"; ac_cv_visibility_supported=yes],
[ac_cv_visiblity_supported=no],
[])
AX_CHECK_LINK_FLAG([-Wl,-as-needed], [LDFLAGS="$LDFLAGS -Wl,-as-needed"],
[], [])
dnl ----------
AC_CHECK_LIB([ife],[meaning])
CFLAGS="$XSERVER_CFLAGS $CFLAGS -Wall"
AC_SUBST([CFLAGS])
LDFLAGS="$LDFLAGS -Wl,-O1"
AC_SUBST([LDFLAGS])
BUILD_DATE="$(date +'%Y%m%d')"
AC_SUBST([BUILD_DATE])
DIX_CFLAGS="-DHAVE_DIX_CONFIG_H"
AC_SUBST([DIX_CFLAGS])
AC_SUBST([libdir])
AC_SUBST([exec_prefix])
AC_SUBST([prefix])
# XORG in this case refers to the roll-up releases, not the Xorg DDX.
XORG_RELEASE_VERSION
AC_OUTPUT([
Makefile
include/Makefile
damageext/Makefile
dbe/Makefile
dix/Makefile
fb/Makefile
mi/Makefile
miext/Makefile
miext/damage/Makefile
miext/shadow/Makefile
os/Makefile
randr/Makefile
render/Makefile
Xext/Makefile
xfixes/Makefile
kdrive/Makefile
kdrive/fbdev/Makefile
kdrive/linux/Makefile
kdrive/src/Makefile
kdrive/vesa/Makefile
])

8
damageext/Makefile.am Normal file
View File

@ -0,0 +1,8 @@
noinst_LTLIBRARIES = libdamageext.la
AM_CFLAGS = $(DIX_CFLAGS)
libdamageext_la_SOURCES = \
damageext.c \
damageext.h \
damageextint.h

515
damageext/damageext.c Normal file
View File

@ -0,0 +1,515 @@
/*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "damageextint.h"
#include "extinit.h"
unsigned char DamageReqCode;
int DamageEventBase;
int DamageErrorBase;
int DamageClientPrivateIndex;
RESTYPE DamageExtType;
RESTYPE DamageExtWinType;
/* Version of the damage extension supported by the server, as opposed to the
* DAMAGE_* defines from damageproto for what version the proto header
* supports.
*/
#define SERVER_DAMAGE_MAJOR 1
#define SERVER_DAMAGE_MINOR 1
#define prScreen screenInfo.screens[0]
static void
DamageExtNotify(DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes)
{
ClientPtr pClient = pDamageExt->pClient;
DamageClientPtr pDamageClient = GetDamageClient(pClient);
DrawablePtr pDrawable = pDamageExt->pDrawable;
xDamageNotifyEvent ev;
int i;
UpdateCurrentTimeIf();
ev = (xDamageNotifyEvent) {
.type = DamageEventBase + XDamageNotify,
.level = pDamageExt->level,
.drawable = pDamageExt->drawable,
.damage = pDamageExt->id,
.timestamp = currentTime.milliseconds,
.geometry.x = pDrawable->x,
.geometry.y = pDrawable->y,
.geometry.width = pDrawable->width,
.geometry.height = pDrawable->height
};
if (pBoxes) {
for (i = 0; i < nBoxes; i++) {
ev.level = pDamageExt->level;
if (i < nBoxes - 1)
ev.level |= DamageNotifyMore;
ev.area.x = pBoxes[i].x1;
ev.area.y = pBoxes[i].y1;
ev.area.width = pBoxes[i].x2 - pBoxes[i].x1;
ev.area.height = pBoxes[i].y2 - pBoxes[i].y1;
WriteEventsToClient(pClient, 1, (xEvent *) &ev);
}
}
else {
ev.area.x = 0;
ev.area.y = 0;
ev.area.width = pDrawable->width;
ev.area.height = pDrawable->height;
WriteEventsToClient(pClient, 1, (xEvent *) &ev);
}
/* Composite extension marks clients with manual Subwindows as critical */
if (pDamageClient->critical > 0) {
SetCriticalOutputPending();
pClient->smart_priority = SMART_MAX_PRIORITY;
}
}
static void
DamageExtReport(DamagePtr pDamage, RegionPtr pRegion, void *closure)
{
DamageExtPtr pDamageExt = closure;
switch (pDamageExt->level) {
case DamageReportRawRegion:
case DamageReportDeltaRegion:
DamageExtNotify(pDamageExt, REGION_RECTS(pRegion),
REGION_NUM_RECTS(pRegion));
break;
case DamageReportBoundingBox:
DamageExtNotify(pDamageExt, REGION_EXTENTS(pRegion), 1);
break;
case DamageReportNonEmpty:
DamageExtNotify(pDamageExt, NullBox, 0);
break;
case DamageReportNone:
break;
}
}
static void
DamageExtDestroy(DamagePtr pDamage, void *closure)
{
DamageExtPtr pDamageExt = closure;
pDamageExt->pDamage = 0;
if (pDamageExt->id)
FreeResource(pDamageExt->id, RT_NONE);
}
void
DamageExtSetCritical(ClientPtr pClient, Bool critical)
{
DamageClientPtr pDamageClient = GetDamageClient(pClient);
if (pDamageClient)
pDamageClient->critical += critical ? 1 : -1;
}
static int
ProcDamageQueryVersion(ClientPtr client)
{
DamageClientPtr pDamageClient = GetDamageClient(client);
xDamageQueryVersionReply rep;
REQUEST(xDamageQueryVersionReq);
REQUEST_SIZE_MATCH(xDamageQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
if (stuff->majorVersion < SERVER_DAMAGE_MAJOR) {
rep.majorVersion = stuff->majorVersion;
rep.minorVersion = stuff->minorVersion;
}
else {
rep.majorVersion = SERVER_DAMAGE_MAJOR;
if (stuff->majorVersion == SERVER_DAMAGE_MAJOR &&
stuff->minorVersion < SERVER_DAMAGE_MINOR)
rep.minorVersion = stuff->minorVersion;
else
rep.minorVersion = SERVER_DAMAGE_MINOR;
}
pDamageClient->major_version = rep.majorVersion;
pDamageClient->minor_version = rep.minorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.majorVersion);
swapl(&rep.minorVersion);
}
WriteToClient(client, sizeof(xDamageQueryVersionReply), (char *) &rep);
return (client->noClientException);
}
static int
ProcDamageCreate(ClientPtr client)
{
DrawablePtr pDrawable;
DamageExtPtr pDamageExt;
DamageReportLevel level;
RegionPtr pRegion;
REQUEST(xDamageCreateReq);
REQUEST_SIZE_MATCH(xDamageCreateReq);
LEGAL_NEW_RESOURCE(stuff->damage, client);
SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client,
SecurityReadAccess);
switch (stuff->level) {
case XDamageReportRawRectangles:
level = DamageReportRawRegion;
break;
case XDamageReportDeltaRectangles:
level = DamageReportDeltaRegion;
break;
case XDamageReportBoundingBox:
level = DamageReportBoundingBox;
break;
case XDamageReportNonEmpty:
level = DamageReportNonEmpty;
break;
default:
client->errorValue = stuff->level;
return BadValue;
}
pDamageExt = malloc(sizeof(DamageExtRec));
if (!pDamageExt)
return BadAlloc;
pDamageExt->id = stuff->damage;
pDamageExt->pDrawable = pDrawable;
pDamageExt->level = level;
pDamageExt->pClient = client;
pDamageExt->pDamage = DamageCreate(DamageExtReport,
DamageExtDestroy,
level,
FALSE, pDrawable->pScreen, pDamageExt);
if (!pDamageExt->pDamage) {
free(pDamageExt);
return BadAlloc;
}
if (!AddResource(stuff->damage, DamageExtType, (pointer) pDamageExt))
return BadAlloc;
DamageRegister(pDamageExt->pDrawable, pDamageExt->pDamage);
if (pDrawable->type == DRAWABLE_WINDOW) {
pRegion = &((WindowPtr) pDrawable)->borderClip;
DamageDamageRegion(pDrawable, pRegion);
}
return (client->noClientException);
}
static int
ProcDamageDestroy(ClientPtr client)
{
REQUEST(xDamageDestroyReq);
DamageExtPtr pDamageExt;
REQUEST_SIZE_MATCH(xDamageDestroyReq);
VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, SecurityWriteAccess);
FreeResource(stuff->damage, RT_NONE);
return (client->noClientException);
}
static int
ProcDamageSubtract(ClientPtr client)
{
REQUEST(xDamageSubtractReq);
DamageExtPtr pDamageExt;
RegionPtr pRepair;
RegionPtr pParts;
REQUEST_SIZE_MATCH(xDamageSubtractReq);
VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, SecurityWriteAccess);
VERIFY_REGION_OR_NONE(pRepair, stuff->repair, client, SecurityWriteAccess);
VERIFY_REGION_OR_NONE(pParts, stuff->parts, client, SecurityWriteAccess);
if (pDamageExt->level != DamageReportRawRegion) {
DamagePtr pDamage = pDamageExt->pDamage;
if (pRepair) {
if (pParts)
REGION_INTERSECT(pParts, DamageRegion(pDamage),
pRepair);
if (DamageSubtract(pDamage, pRepair))
DamageExtReport(pDamage, DamageRegion(pDamage),
(void *) pDamageExt);
}
else {
if (pParts)
REGION_COPY(pParts, DamageRegion(pDamage));
DamageEmpty(pDamage);
}
}
return (client->noClientException);
}
static int
ProcDamageAdd(ClientPtr client)
{
REQUEST(xDamageAddReq);
DrawablePtr pDrawable;
RegionPtr pRegion;
REQUEST_SIZE_MATCH(xDamageAddReq);
VERIFY_REGION(pRegion, stuff->region, client, SecurityWriteAccess);
SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client,
SecurityReadAccess);
/* The region is relative to the drawable origin, so translate it out to
* screen coordinates like damage expects.
*/
REGION_TRANSLATE(pRegion, pDrawable->x, pDrawable->y);
DamageDamageRegion(pDrawable, pRegion);
REGION_TRANSLATE(pRegion, -pDrawable->x, -pDrawable->y);
return (client->noClientException);
}
/* Major version controls available requests */
static const int version_requests[] = {
X_DamageQueryVersion, /* before client sends QueryVersion */
X_DamageAdd, /* Version 1 */
};
#define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0]))
int (*ProcDamageVector[XDamageNumberRequests]) (ClientPtr) = {
/*************** Version 1 ******************/
ProcDamageQueryVersion,
ProcDamageCreate, ProcDamageDestroy, ProcDamageSubtract,
/*************** Version 1.1 ****************/
ProcDamageAdd,};
static int
ProcDamageDispatch(ClientPtr client)
{
REQUEST(xDamageReq);
DamageClientPtr pDamageClient = GetDamageClient(client);
if (pDamageClient->major_version >= NUM_VERSION_REQUESTS)
return BadRequest;
if (stuff->damageReqType > version_requests[pDamageClient->major_version])
return BadRequest;
return (*ProcDamageVector[stuff->damageReqType]) (client);
}
static int
SProcDamageQueryVersion(ClientPtr client)
{
REQUEST(xDamageQueryVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDamageQueryVersionReq);
swapl(&stuff->majorVersion);
swapl(&stuff->minorVersion);
return (*ProcDamageVector[stuff->damageReqType]) (client);
}
static int
SProcDamageCreate(ClientPtr client)
{
REQUEST(xDamageCreateReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDamageCreateReq);
swapl(&stuff->damage);
swapl(&stuff->drawable);
return (*ProcDamageVector[stuff->damageReqType]) (client);
}
static int
SProcDamageDestroy(ClientPtr client)
{
REQUEST(xDamageDestroyReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDamageDestroyReq);
swapl(&stuff->damage);
return (*ProcDamageVector[stuff->damageReqType]) (client);
}
static int
SProcDamageSubtract(ClientPtr client)
{
REQUEST(xDamageSubtractReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDamageSubtractReq);
swapl(&stuff->damage);
swapl(&stuff->repair);
swapl(&stuff->parts);
return (*ProcDamageVector[stuff->damageReqType]) (client);
}
static int
SProcDamageAdd(ClientPtr client)
{
REQUEST(xDamageAddReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDamageSubtractReq);
swapl(&stuff->drawable);
swapl(&stuff->region);
return (*ProcDamageVector[stuff->damageReqType]) (client);
}
int (*SProcDamageVector[XDamageNumberRequests]) (ClientPtr) = {
/*************** Version 1 ******************/
SProcDamageQueryVersion,
SProcDamageCreate, SProcDamageDestroy, SProcDamageSubtract,
/*************** Version 1.1 ****************/
SProcDamageAdd,};
static int
SProcDamageDispatch(ClientPtr client)
{
REQUEST(xDamageReq);
if (stuff->damageReqType >= XDamageNumberRequests)
return BadRequest;
return (*SProcDamageVector[stuff->damageReqType]) (client);
}
static void
DamageClientCallback(CallbackListPtr *list, pointer closure, pointer data)
{
NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
ClientPtr pClient = clientinfo->client;
DamageClientPtr pDamageClient = GetDamageClient(pClient);
pDamageClient->critical = 0;
pDamageClient->major_version = 0;
pDamageClient->minor_version = 0;
}
/*ARGSUSED*/ static void
DamageResetProc(ExtensionEntry * extEntry)
{
DeleteCallback(&ClientStateCallback, DamageClientCallback, 0);
}
static int
FreeDamageExt(pointer value, XID did)
{
DamageExtPtr pDamageExt = (DamageExtPtr) value;
/*
* Get rid of the resource table entry hanging from the window id
*/
pDamageExt->id = 0;
if (WindowDrawable(pDamageExt->pDrawable->type))
FreeResourceByType(pDamageExt->pDrawable->id, DamageExtWinType, TRUE);
if (pDamageExt->pDamage) {
DamageUnregister(pDamageExt->pDrawable, pDamageExt->pDamage);
DamageDestroy(pDamageExt->pDamage);
}
free(pDamageExt);
return Success;
}
static int
FreeDamageExtWin(pointer value, XID wid)
{
DamageExtPtr pDamageExt = (DamageExtPtr) value;
if (pDamageExt->id)
FreeResource(pDamageExt->id, RT_NONE);
return Success;
}
void
SDamageNotifyEvent(xDamageNotifyEvent * from, xDamageNotifyEvent * to)
{
to->type = from->type;
cpswaps(from->sequenceNumber, to->sequenceNumber);
cpswapl(from->drawable, to->drawable);
cpswapl(from->damage, to->damage);
cpswaps(from->area.x, to->area.x);
cpswaps(from->area.y, to->area.y);
cpswaps(from->area.width, to->area.width);
cpswaps(from->area.height, to->area.height);
cpswaps(from->geometry.x, to->geometry.x);
cpswaps(from->geometry.y, to->geometry.y);
cpswaps(from->geometry.width, to->geometry.width);
cpswaps(from->geometry.height, to->geometry.height);
}
void
DamageExtensionInit(void)
{
ExtensionEntry *extEntry;
int s;
for (s = 0; s < screenInfo.numScreens; s++)
DamageSetup(screenInfo.screens[s]);
DamageExtType = CreateNewResourceType(FreeDamageExt);
if (!DamageExtType)
return;
DamageExtWinType = CreateNewResourceType(FreeDamageExtWin);
if (!DamageExtWinType)
return;
DamageClientPrivateIndex = AllocateClientPrivateIndex();
if (!AllocateClientPrivate(DamageClientPrivateIndex,
sizeof(DamageClientRec)))
return;
if (!AddCallback(&ClientStateCallback, DamageClientCallback, 0))
return;
if ((extEntry = AddExtension(DAMAGE_NAME, XDamageNumberEvents,
XDamageNumberErrors,
ProcDamageDispatch, SProcDamageDispatch,
DamageResetProc, StandardMinorOpcode)) != 0) {
DamageReqCode = (unsigned char) extEntry->base;
DamageEventBase = extEntry->eventBase;
DamageErrorBase = extEntry->errorBase;
EventSwapVector[DamageEventBase + XDamageNotify] =
(EventSwapPtr) SDamageNotifyEvent;
}
}

33
damageext/damageext.h Normal file
View File

@ -0,0 +1,33 @@
/*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef _DAMAGEEXT_H_
#define _DAMAGEEXT_H_
void
DamageExtensionInit(void);
#endif /* _DAMAGEEXT_H_ */

91
damageext/damageextint.h Normal file
View File

@ -0,0 +1,91 @@
/*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef _DAMAGEEXTINT_H_
#define _DAMAGEEXTINT_H_
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include <X11/extensions/damageproto.h>
#include "windowstr.h"
#include "selection.h"
#include "scrnintstr.h"
#include "damageext.h"
#include "damage.h"
#include "xfixes.h"
extern unsigned char DamageReqCode;
extern int DamageEventBase;
extern int DamageErrorBase;
extern int DamageClientPrivateIndex;
extern RESTYPE DamageExtType;
extern RESTYPE DamageExtWinType;
typedef struct _DamageClient {
CARD32 major_version;
CARD32 minor_version;
int critical;
} DamageClientRec, *DamageClientPtr;
#define GetDamageClient(pClient) ((DamageClientPtr) (pClient)->devPrivates[DamageClientPrivateIndex].ptr)
typedef struct _DamageExt {
DamagePtr pDamage;
DrawablePtr pDrawable;
DamageReportLevel level;
ClientPtr pClient;
XID id;
XID drawable;
} DamageExtRec, *DamageExtPtr;
extern int (*ProcDamageVector[ /*XDamageNumberRequests */ ]) (ClientPtr);
extern int (*SProcDamageVector[ /*XDamageNumberRequests */ ]) (ClientPtr);
#define VERIFY_DAMAGEEXT(pDamageExt, rid, client, mode) { \
pDamageExt = SecurityLookupIDByType (client, rid, DamageExtType, mode); \
if (!pDamageExt) { \
client->errorValue = rid; \
return DamageErrorBase + BadDamage; \
} \
}
void
SDamageNotifyEvent(xDamageNotifyEvent * from, xDamageNotifyEvent * to);
void
DamageExtSetCritical(ClientPtr pClient, Bool critical);
#endif /* _DAMAGEEXTINT_H_ */

10
dbe/Makefile.am Normal file
View File

@ -0,0 +1,10 @@
noinst_LTLIBRARIES = libdbe.la
AM_CFLAGS = $(DIX_CFLAGS)
libdbe_la_SOURCES = \
dbe.c \
dbestruct.h \
midbe.c \
midbe.h \
midbestr.h

1829
dbe/dbe.c Normal file

File diff suppressed because it is too large Load Diff

226
dbe/dbestruct.h Normal file
View File

@ -0,0 +1,226 @@
/******************************************************************************
*
* Copyright (c) 1994, 1995 Hewlett-Packard Company
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the Hewlett-Packard
* Company shall not be used in advertising or otherwise to promote the
* sale, use or other dealings in this Software without prior written
* authorization from the Hewlett-Packard Company.
*
* Header file for DIX-related DBE
*
*****************************************************************************/
#ifndef DBE_STRUCT_H
#define DBE_STRUCT_H
/* INCLUDES */
#define NEED_DBE_PROTOCOL
#include <X11/extensions/dbeproto.h>
#include "windowstr.h"
typedef struct {
VisualID visual; /* one visual ID that supports double-buffering */
int depth; /* depth of visual in bits */
int perflevel; /* performance level of visual */
} XdbeVisualInfo;
typedef struct {
int count; /* number of items in visual_depth */
XdbeVisualInfo *visinfo; /* list of visuals & depths for scrn */
} XdbeScreenVisualInfo;
/* DEFINES */
#define DBE_SCREEN_PRIV(pScreen) \
((dbeScreenPrivIndex < 0) ? \
NULL : \
((DbeScreenPrivPtr)((pScreen)->devPrivates[dbeScreenPrivIndex].ptr)))
#define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \
DBE_SCREEN_PRIV((pDrawable)->pScreen)
#define DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(pDbeWindowPriv) \
DBE_SCREEN_PRIV((pDbeWindowPriv)->pWindow->drawable.pScreen)
#define DBE_SCREEN_PRIV_FROM_WINDOW(pWindow) \
DBE_SCREEN_PRIV((pWindow)->drawable.pScreen)
#define DBE_SCREEN_PRIV_FROM_PIXMAP(pPixmap) \
DBE_SCREEN_PRIV((pPixmap)->drawable.pScreen)
#define DBE_SCREEN_PRIV_FROM_GC(pGC)\
DBE_SCREEN_PRIV((pGC)->pScreen)
#define DBE_WINDOW_PRIV(pWindow)\
((dbeWindowPrivIndex < 0) ? \
NULL : \
((DbeWindowPrivPtr)(pWindow->devPrivates[dbeWindowPrivIndex].ptr)))
/* Initial size of the buffer ID array in the window priv. */
#define DBE_INIT_MAX_IDS 2
/* Reallocation increment for the buffer ID array. */
#define DBE_INCR_MAX_IDS 4
/* Marker for free elements in the buffer ID array. */
#define DBE_FREE_ID_ELEMENT 0
/* TYPEDEFS */
/* Record used to pass swap information between DIX and DDX swapping
* procedures.
*/
typedef struct _DbeSwapInfoRec {
WindowPtr pWindow;
unsigned char swapAction;
} DbeSwapInfoRec, *DbeSwapInfoPtr;
/*
******************************************************************************
** Per-window data
******************************************************************************
*/
typedef struct _DbeWindowPrivRec {
/* A pointer to the window with which the DBE window private (buffer) is
* associated.
*/
WindowPtr pWindow;
/* Last known swap action for this buffer. Legal values for this field
* are XdbeUndefined, XdbeBackground, XdbeUntouched, and XdbeCopied.
*/
unsigned char swapAction;
/* Last known buffer size.
*/
unsigned short width, height;
/* Coordinates used for static gravity when the window is positioned.
*/
short x, y;
/* Number of XIDs associated with this buffer.
*/
int nBufferIDs;
/* Capacity of the current buffer ID array, IDs. */
int maxAvailableIDs;
/* Pointer to the array of buffer IDs. This initially points to initIDs.
* When the static limit of the initIDs array is reached, the array is
* reallocated and this pointer is set to the new array instead of initIDs.
*/
XID *IDs;
/* Initial array of buffer IDs. We are defining the XID array within the
* window priv to optimize for data locality. In most cases, only one
* buffer will be associated with a window. Having the array declared
* here can prevent us from accessing the data in another memory page,
* possibly resulting in a page swap and loss of performance. Initially we
* will use this array to store buffer IDs. For situations where we have
* more IDs than can fit in this static array, we will allocate a larger
* array to use, possibly suffering a performance loss.
*/
XID initIDs[DBE_INIT_MAX_IDS];
/* Device-specific private information.
*/
DevUnion *devPrivates;
} DbeWindowPrivRec, *DbeWindowPrivPtr;
/*
******************************************************************************
** Per-screen data
******************************************************************************
*/
typedef struct _DbeScreenPrivRec {
/* Info for creating window privs */
int winPrivPrivLen; /* Length of privs in DbeWindowPrivRec */
unsigned int *winPrivPrivSizes; /* Array of private record sizes */
unsigned int totalWinPrivSize; /* PrivRec + size of all priv priv ptrs */
/* Resources created by DIX to be used by DDX */
RESTYPE dbeDrawableResType;
RESTYPE dbeWindowPrivResType;
/* Private indices created by DIX to be used by DDX */
int dbeScreenPrivIndex;
int dbeWindowPrivIndex;
/* Wrapped functions
* It is the responsibilty of the DDX layer to wrap PositionWindow().
* DbeExtensionInit wraps DestroyWindow().
*/
PositionWindowProcPtr PositionWindow;
DestroyWindowProcPtr DestroyWindow;
/* Per-screen DIX routines */
Bool (*SetupBackgroundPainter) (WindowPtr /*pWin */ ,
GCPtr /*pGC */
);
DbeWindowPrivPtr(*AllocWinPriv) (ScreenPtr /*pScreen */
);
int (*AllocWinPrivPrivIndex) (void);
Bool (*AllocWinPrivPriv) (ScreenPtr /*pScreen */ ,
int /*index */ ,
unsigned /*amount */
);
/* Per-screen DDX routines */
Bool (*GetVisualInfo) (ScreenPtr /*pScreen */ ,
XdbeScreenVisualInfo * /*pVisInfo */
);
int (*AllocBackBufferName) (WindowPtr /*pWin */ ,
XID /*bufId */ ,
int /*swapAction */
);
int (*SwapBuffers) (ClientPtr /*client */ ,
int * /*pNumWindows */ ,
DbeSwapInfoPtr /*swapInfo */
);
void (*BeginIdiom) (ClientPtr /*client */
);
void (*EndIdiom) (ClientPtr /*client */
);
void (*WinPrivDelete) (DbeWindowPrivPtr /*pDbeWindowPriv */ ,
XID /*bufId */
);
void (*ResetProc) (ScreenPtr /*pScreen */
);
void (*ValidateBuffer) (WindowPtr /*pWin */ ,
XID /*bufId */ ,
Bool /*dstbuffer */
);
/* Device-specific private information.
*/
DevUnion *devPrivates;
} DbeScreenPrivRec, *DbeScreenPrivPtr;
#endif /* DBE_STRUCT_H */

791
dbe/midbe.c Normal file
View File

@ -0,0 +1,791 @@
/******************************************************************************
*
* Copyright (c) 1994, 1995 Hewlett-Packard Company
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the Hewlett-Packard
* Company shall not be used in advertising or otherwise to promote the
* sale, use or other dealings in this Software without prior written
* authorization from the Hewlett-Packard Company.
*
* Machine-independent DBE code
*
*****************************************************************************/
/* INCLUDES */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "windowstr.h"
#include "scrnintstr.h"
#include "pixmapstr.h"
#include "extnsionst.h"
#include "dixstruct.h"
#include "resource.h"
#include "opaque.h"
#include "dbestruct.h"
#include "midbestr.h"
#include "regionstr.h"
#include "gcstruct.h"
#include "inputstr.h"
#include "midbe.h"
#include <stdio.h>
/* DEFINES */
/* TYPEDEFS */
/* GLOBALS */
static int miDbePrivPrivGeneration = 0;
static int miDbeWindowPrivPrivIndex = -1;
RESTYPE dbeDrawableResType;
RESTYPE dbeWindowPrivResType;
int dbeScreenPrivIndex = -1;
int dbeWindowPrivIndex = -1;
/******************************************************************************
*
* DBE MI Procedure: miDbeGetVisualInfo
*
* Description:
*
* This is the MI function for the DbeGetVisualInfo request. This function
* is called through pDbeScreenPriv->GetVisualInfo. This function is also
* called for the DbeAllocateBackBufferName request at the extension level;
* it is called by ProcDbeAllocateBackBufferName() in dbe.c.
*
* If memory allocation fails or we can not get the visual info, this
* function returns FALSE. Otherwise, it returns TRUE for success.
*
*****************************************************************************/
static Bool
miDbeGetVisualInfo(ScreenPtr pScreen, XdbeScreenVisualInfo * pScrVisInfo)
{
int i, j, k;
int count;
DepthPtr pDepth;
XdbeVisualInfo *visInfo;
/* Determine number of visuals for this screen. */
for (i = 0, count = 0; i < pScreen->numDepths; i++) {
count += pScreen->allowedDepths[i].numVids;
}
if (!count)
return FALSE;
/* Allocate an array of XdbeVisualInfo items. */
if (!(visInfo = malloc(count * sizeof(XdbeVisualInfo)))) {
return FALSE; /* memory alloc failure */
}
for (i = 0, k = 0; i < pScreen->numDepths; i++) {
/* For each depth of this screen, get visual information. */
pDepth = &pScreen->allowedDepths[i];
for (j = 0; j < pDepth->numVids; j++) {
/* For each visual for this depth of this screen, get visual ID
* and visual depth. Since this is MI code, we will always return
* the same performance level for all visuals (0). A higher
* performance level value indicates higher performance.
*/
visInfo[k].visual = pDepth->vids[j];
visInfo[k].depth = pDepth->depth;
visInfo[k].perflevel = 0;
k++;
}
}
/* Record the number of visuals and point visual_depth to
* the array of visual info.
*/
pScrVisInfo->count = count;
pScrVisInfo->visinfo = visInfo;
return TRUE; /* success */
} /* miDbeGetVisualInfo() */
/******************************************************************************
*
* DBE MI Procedure: miAllocBackBufferName
*
* Description:
*
* This is the MI function for the DbeAllocateBackBufferName request.
*
*****************************************************************************/
static int
miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
{
ScreenPtr pScreen;
DbeWindowPrivPtr pDbeWindowPriv;
MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
DbeScreenPrivPtr pDbeScreenPriv;
GCPtr pGC;
xRectangle clearRect;
pScreen = pWin->drawable.pScreen;
pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
if (pDbeWindowPriv->nBufferIDs == 0) {
/* There is no buffer associated with the window.
* We have to create the window priv priv. Remember, the window
* priv was created at the DIX level, so all we need to do is
* create the priv priv and attach it to the priv.
*/
pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
/* Setup the window priv priv. */
pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
pDbeWindowPrivPriv->pDbeWindowPriv = pDbeWindowPriv;
/* Get a front pixmap. */
if (!(pDbeWindowPrivPriv->pFrontBuffer =
(*pScreen->CreatePixmap) (pScreen, pDbeWindowPriv->width,
pDbeWindowPriv->height,
pWin->drawable.depth))) {
return (BadAlloc);
}
/* Get a back pixmap. */
if (!(pDbeWindowPrivPriv->pBackBuffer =
(*pScreen->CreatePixmap) (pScreen, pDbeWindowPriv->width,
pDbeWindowPriv->height,
pWin->drawable.depth))) {
(*pScreen->DestroyPixmap) (pDbeWindowPrivPriv->pFrontBuffer);
return (BadAlloc);
}
/* Make the back pixmap a DBE drawable resource. */
if (!AddResource(bufId, dbeDrawableResType,
(pointer) pDbeWindowPrivPriv->pBackBuffer)) {
/* free the buffer and the drawable resource */
FreeResource(bufId, RT_NONE);
return (BadAlloc);
}
/* Attach the priv priv to the priv. */
pDbeWindowPriv->devPrivates[miDbeWindowPrivPrivIndex].ptr =
(pointer) pDbeWindowPrivPriv;
/* Clear the back buffer. */
pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
if ((*pDbeScreenPriv->SetupBackgroundPainter) (pWin, pGC)) {
ValidateGC((DrawablePtr) pDbeWindowPrivPriv->pBackBuffer, pGC);
clearRect.x = clearRect.y = 0;
clearRect.width = pDbeWindowPrivPriv->pBackBuffer->drawable.width;
clearRect.height = pDbeWindowPrivPriv->pBackBuffer->drawable.height;
(*pGC->ops->PolyFillRect) ((DrawablePtr) pDbeWindowPrivPriv->
pBackBuffer, pGC, 1, &clearRect);
}
FreeScratchGC(pGC);
} /* if no buffer associated with the window */
else {
/* A buffer is already associated with the window.
* Place the new buffer ID information at the head of the ID list.
*/
/* Associate the new ID with an existing pixmap. */
pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
if (!AddResource(bufId, dbeDrawableResType,
(pointer) pDbeWindowPrivPriv->pBackBuffer)) {
return (BadAlloc);
}
}
return (Success);
} /* miDbeAllocBackBufferName() */
/******************************************************************************
*
* DBE MI Procedure: miDbeAliasBuffers
*
* Description:
*
* This function associates all XIDs of a buffer with the back pixmap
* stored in the window priv.
*
*****************************************************************************/
static void
miDbeAliasBuffers(DbeWindowPrivPtr pDbeWindowPriv)
{
int i;
MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv =
MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
for (i = 0; i < pDbeWindowPriv->nBufferIDs; i++) {
ChangeResourceValue(pDbeWindowPriv->IDs[i], dbeDrawableResType,
(pointer) pDbeWindowPrivPriv->pBackBuffer);
}
} /* miDbeAliasBuffers() */
/******************************************************************************
*
* DBE MI Procedure: miDbeSwapBuffers
*
* Description:
*
* This is the MI function for the DbeSwapBuffers request.
*
*****************************************************************************/
static int
miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo)
{
DbeScreenPrivPtr pDbeScreenPriv;
GCPtr pGC;
WindowPtr pWin;
MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
PixmapPtr pTmpBuffer;
xRectangle clearRect;
pWin = swapInfo[0].pWindow;
pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin);
pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
/*
**********************************************************************
** Setup before swap.
**********************************************************************
*/
switch (swapInfo[0].swapAction) {
case XdbeUndefined:
break;
case XdbeBackground:
break;
case XdbeUntouched:
ValidateGC((DrawablePtr) pDbeWindowPrivPriv->pFrontBuffer, pGC);
(*pGC->ops->CopyArea) ((DrawablePtr) pWin,
(DrawablePtr) pDbeWindowPrivPriv->pFrontBuffer,
pGC, 0, 0, pWin->drawable.width,
pWin->drawable.height, 0, 0);
break;
case XdbeCopied:
break;
}
/*
**********************************************************************
** Swap.
**********************************************************************
*/
ValidateGC((DrawablePtr) pWin, pGC);
(*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPrivPriv->pBackBuffer,
(DrawablePtr) pWin, pGC, 0, 0,
pWin->drawable.width, pWin->drawable.height, 0, 0);
/*
**********************************************************************
** Tasks after swap.
**********************************************************************
*/
switch (swapInfo[0].swapAction) {
case XdbeUndefined:
break;
case XdbeBackground:
if ((*pDbeScreenPriv->SetupBackgroundPainter) (pWin, pGC)) {
ValidateGC((DrawablePtr) pDbeWindowPrivPriv->pBackBuffer, pGC);
clearRect.x = 0;
clearRect.y = 0;
clearRect.width = pDbeWindowPrivPriv->pBackBuffer->drawable.width;
clearRect.height = pDbeWindowPrivPriv->pBackBuffer->drawable.height;
(*pGC->ops->PolyFillRect) ((DrawablePtr) pDbeWindowPrivPriv->
pBackBuffer, pGC, 1, &clearRect);
}
break;
case XdbeUntouched:
/* Swap pixmap pointers. */
pTmpBuffer = pDbeWindowPrivPriv->pBackBuffer;
pDbeWindowPrivPriv->pBackBuffer = pDbeWindowPrivPriv->pFrontBuffer;
pDbeWindowPrivPriv->pFrontBuffer = pTmpBuffer;
miDbeAliasBuffers(pDbeWindowPrivPriv->pDbeWindowPriv);
break;
case XdbeCopied:
break;
}
/* Remove the swapped window from the swap information array and decrement
* pNumWindows to indicate to the DIX level how many windows were actually
* swapped.
*/
if (*pNumWindows > 1) {
/* We were told to swap more than one window, but we only swapped the
* first one. Remove the first window in the list by moving the last
* window to the beginning.
*/
swapInfo[0].pWindow = swapInfo[*pNumWindows - 1].pWindow;
swapInfo[0].swapAction = swapInfo[*pNumWindows - 1].swapAction;
/* Clear the last window information just to be safe. */
swapInfo[*pNumWindows - 1].pWindow = (WindowPtr) NULL;
swapInfo[*pNumWindows - 1].swapAction = 0;
}
else {
/* Clear the window information just to be safe. */
swapInfo[0].pWindow = (WindowPtr) NULL;
swapInfo[0].swapAction = 0;
}
(*pNumWindows)--;
FreeScratchGC(pGC);
return Success;
} /* miSwapBuffers() */
/******************************************************************************
*
* DBE MI Procedure: miDbeWinPrivDelete
*
* Description:
*
* This is the MI function for deleting the dbeWindowPrivResType resource.
* This function is invoked indirectly by calling FreeResource() to free
* the resources associated with a DBE buffer ID. There are 5 ways that
* miDbeWinPrivDelete() can be called by FreeResource(). They are:
*
* - A DBE window is destroyed, in which case the DbeDestroyWindow()
* wrapper is invoked. The wrapper calls FreeResource() for all DBE
* buffer IDs.
*
* - miDbeAllocBackBufferName() calls FreeResource() to clean up resources
* after a buffer allocation failure.
*
* - The PositionWindow wrapper, miDbePositionWindow(), calls
* FreeResource() when it fails to create buffers of the new size.
* FreeResource() is called for all DBE buffer IDs.
*
* - FreeClientResources() calls FreeResource() when a client dies or the
* the server resets.
*
* When FreeResource() is called for a DBE buffer ID, the delete function
* for the only other type of DBE resource, dbeDrawableResType, is also
* invoked. This delete function (DbeDrawableDelete) is a NOOP to make
* resource deletion easier. It is not guaranteed which delete function is
* called first. Hence, we will let miDbeWinPrivDelete() free all DBE
* resources.
*
* This function deletes/frees the following stuff associated with
* the window private:
*
* - the ID node in the ID list representing the passed in ID.
*
* In addition, pDbeWindowPriv->nBufferIDs is decremented.
*
* If this function is called for the last/only buffer ID for a window,
* these are additionally deleted/freed:
*
* - the front and back pixmaps
* - the window priv itself
*
*****************************************************************************/
static void
miDbeWinPrivDelete(DbeWindowPrivPtr pDbeWindowPriv, XID bufId)
{
MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
if (pDbeWindowPriv->nBufferIDs != 0) {
/* We still have at least one more buffer ID associated with this
* window.
*/
return;
}
/* We have no more buffer IDs associated with this window. We need to
* free some stuff.
*/
pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
/* Destroy the front and back pixmaps. */
if (pDbeWindowPrivPriv->pFrontBuffer) {
(*pDbeWindowPriv->pWindow->drawable.pScreen->
DestroyPixmap) (pDbeWindowPrivPriv->pFrontBuffer);
}
if (pDbeWindowPrivPriv->pBackBuffer) {
(*pDbeWindowPriv->pWindow->drawable.pScreen->
DestroyPixmap) (pDbeWindowPrivPriv->pBackBuffer);
}
} /* miDbeWinPrivDelete() */
/******************************************************************************
*
* DBE MI Procedure: miDbePositionWindow
*
* Description:
*
* This function was cloned from miMbxPositionWindow() in mimultibuf.c.
* This function resizes the buffer when the window is resized.
*
*****************************************************************************/
static Bool
miDbePositionWindow(WindowPtr pWin, int x, int y)
{
ScreenPtr pScreen;
DbeScreenPrivPtr pDbeScreenPriv;
DbeWindowPrivPtr pDbeWindowPriv;
int width, height;
int dx, dy, dw, dh;
int sourcex, sourcey;
int destx, desty;
int savewidth, saveheight;
PixmapPtr pFrontBuffer;
PixmapPtr pBackBuffer;
Bool clear;
GCPtr pGC;
xRectangle clearRect;
Bool ret;
/*
**************************************************************************
** 1. Unwrap the member routine.
**************************************************************************
*/
pScreen = pWin->drawable.pScreen;
pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
pScreen->PositionWindow = pDbeScreenPriv->PositionWindow;
/*
**************************************************************************
** 2. Do any work necessary before the member routine is called.
**
** In this case we do not need to do anything.
**************************************************************************
*/
/*
**************************************************************************
** 3. Call the member routine, saving its result if necessary.
**************************************************************************
*/
ret = (*pScreen->PositionWindow) (pWin, x, y);
/*
**************************************************************************
** 4. Rewrap the member routine, restoring the wrapper value first in case
** the wrapper (or something that it wrapped) change this value.
**************************************************************************
*/
pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
pScreen->PositionWindow = miDbePositionWindow;
/*
**************************************************************************
** 5. Do any work necessary after the member routine has been called.
**************************************************************************
*/
if (!(pDbeWindowPriv = DBE_WINDOW_PRIV(pWin))) {
return ret;
}
if (pDbeWindowPriv->width == pWin->drawable.width &&
pDbeWindowPriv->height == pWin->drawable.height) {
return ret;
}
width = pWin->drawable.width;
height = pWin->drawable.height;
dx = pWin->drawable.x - pDbeWindowPriv->x;
dy = pWin->drawable.y - pDbeWindowPriv->y;
dw = width - pDbeWindowPriv->width;
dh = height - pDbeWindowPriv->height;
GravityTranslate(0, 0, -dx, -dy, dw, dh, pWin->bitGravity, &destx, &desty);
clear = ((pDbeWindowPriv->width < (unsigned short) width) ||
(pDbeWindowPriv->height < (unsigned short) height) ||
(pWin->bitGravity == ForgetGravity));
sourcex = 0;
sourcey = 0;
savewidth = pDbeWindowPriv->width;
saveheight = pDbeWindowPriv->height;
/* Clip rectangle to source and destination. */
if (destx < 0) {
savewidth += destx;
sourcex -= destx;
destx = 0;
}
if (destx + savewidth > width) {
savewidth = width - destx;
}
if (desty < 0) {
saveheight += desty;
sourcey -= desty;
desty = 0;
}
if (desty + saveheight > height) {
saveheight = height - desty;
}
pDbeWindowPriv->width = width;
pDbeWindowPriv->height = height;
pDbeWindowPriv->x = pWin->drawable.x;
pDbeWindowPriv->y = pWin->drawable.y;
pGC = GetScratchGC(pWin->drawable.depth, pScreen);
if (clear) {
if ((*pDbeScreenPriv->SetupBackgroundPainter) (pWin, pGC)) {
clearRect.x = 0;
clearRect.y = 0;
clearRect.width = width;
clearRect.height = height;
}
else {
clear = FALSE;
}
}
/* Create DBE buffer pixmaps equal to size of resized window. */
pFrontBuffer = (*pScreen->CreatePixmap) (pScreen, width, height,
pWin->drawable.depth);
pBackBuffer = (*pScreen->CreatePixmap) (pScreen, width, height,
pWin->drawable.depth);
if (!pFrontBuffer || !pBackBuffer) {
/* We failed at creating 1 or 2 of the pixmaps. */
if (pFrontBuffer) {
(*pScreen->DestroyPixmap) (pFrontBuffer);
}
if (pBackBuffer) {
(*pScreen->DestroyPixmap) (pBackBuffer);
}
/* Destroy all buffers for this window. */
while (pDbeWindowPriv) {
/* DbeWindowPrivDelete() will free the window private if there no
* more buffer IDs associated with this window.
*/
FreeResource(pDbeWindowPriv->IDs[0], RT_NONE);
pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
}
FreeScratchGC(pGC);
return (FALSE);
}
else {
/* Clear out the new DBE buffer pixmaps. */
MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
ValidateGC((DrawablePtr) pFrontBuffer, pGC);
/* I suppose this could avoid quite a bit of work if
* it computed the minimal area required.
*/
if (clear) {
(*pGC->ops->PolyFillRect) ((DrawablePtr) pFrontBuffer, pGC, 1,
&clearRect);
(*pGC->ops->PolyFillRect) ((DrawablePtr) pBackBuffer, pGC, 1,
&clearRect);
}
/* Copy the contents of the old DBE pixmaps to the new pixmaps. */
if (pWin->bitGravity != ForgetGravity) {
(*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPrivPriv->
pFrontBuffer, (DrawablePtr) pFrontBuffer,
pGC, sourcex, sourcey, savewidth, saveheight,
destx, desty);
(*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPrivPriv->
pBackBuffer, (DrawablePtr) pBackBuffer, pGC,
sourcex, sourcey, savewidth, saveheight,
destx, desty);
}
/* Destroy the old pixmaps, and point the DBE window priv to the new
* pixmaps.
*/
(*pScreen->DestroyPixmap) (pDbeWindowPrivPriv->pFrontBuffer);
(*pScreen->DestroyPixmap) (pDbeWindowPrivPriv->pBackBuffer);
pDbeWindowPrivPriv->pFrontBuffer = pFrontBuffer;
pDbeWindowPrivPriv->pBackBuffer = pBackBuffer;
/* Make sure all XID are associated with the new back pixmap. */
miDbeAliasBuffers(pDbeWindowPriv);
FreeScratchGC(pGC);
}
return (ret);
} /* miDbePositionWindow() */
/******************************************************************************
*
* DBE MI Procedure: miDbeResetProc
*
* Description:
*
* This function is called from DbeResetProc(), which is called at the end
* of every server generation. This function peforms any MI-specific
* shutdown tasks.
*
*****************************************************************************/
static void
miDbeResetProc(ScreenPtr pScreen)
{
DbeScreenPrivPtr pDbeScreenPriv;
pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
/* Unwrap wrappers */
pScreen->PositionWindow = pDbeScreenPriv->PositionWindow;
} /* miDbeResetProc() */
static void
miDbeNopValidateBuffer(WindowPtr pWin, XID bufId, Bool dstbuffer)
{
}
/******************************************************************************
*
* DBE MI Procedure: miDbeInit
*
* Description:
*
* This is the MI initialization function called by DbeExtensionInit().
*
*****************************************************************************/
Bool
miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
{
/* Copy resource types created by DIX */
dbeDrawableResType = pDbeScreenPriv->dbeDrawableResType;
dbeWindowPrivResType = pDbeScreenPriv->dbeWindowPrivResType;
/* Copy private indices created by DIX */
dbeScreenPrivIndex = pDbeScreenPriv->dbeScreenPrivIndex;
dbeWindowPrivIndex = pDbeScreenPriv->dbeWindowPrivIndex;
/* Reset the window priv privs if generations do not match. */
if (miDbePrivPrivGeneration != serverGeneration) {
/*
**********************************************************************
** Allocate the window priv priv.
**********************************************************************
*/
miDbeWindowPrivPrivIndex = (*pDbeScreenPriv->AllocWinPrivPrivIndex) ();
/* Make sure we only do this code once. */
miDbePrivPrivGeneration = serverGeneration;
} /* if -- Reset priv privs. */
if (!(*pDbeScreenPriv->AllocWinPrivPriv) (pScreen,
miDbeWindowPrivPrivIndex,
sizeof(MiDbeWindowPrivPrivRec))) {
return (FALSE);
}
/* Wrap functions. */
pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
pScreen->PositionWindow = miDbePositionWindow;
/* Initialize the per-screen DBE function pointers. */
pDbeScreenPriv->GetVisualInfo = miDbeGetVisualInfo;
pDbeScreenPriv->AllocBackBufferName = miDbeAllocBackBufferName;
pDbeScreenPriv->SwapBuffers = miDbeSwapBuffers;
pDbeScreenPriv->BeginIdiom = 0;
pDbeScreenPriv->EndIdiom = 0;
pDbeScreenPriv->ResetProc = miDbeResetProc;
pDbeScreenPriv->WinPrivDelete = miDbeWinPrivDelete;
/* The mi implementation doesn't need buffer validation. */
pDbeScreenPriv->ValidateBuffer = miDbeNopValidateBuffer;
return (TRUE);
} /* miDbeInit() */

43
dbe/midbe.h Normal file
View File

@ -0,0 +1,43 @@
/******************************************************************************
* Copyright (c) 1994, 1995 Hewlett-Packard Company
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the Hewlett-Packard
* Company shall not be used in advertising or otherwise to promote the
* sale, use or other dealings in this Software without prior written
* authorization from the Hewlett-Packard Company.
*
* Header file for users of machine-independent DBE code
*
*****************************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef MIDBE_H
#define MIDBE_H
/* EXTERNS */
extern Bool miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv);
#endif /* MIDBE_H */

93
dbe/midbestr.h Normal file
View File

@ -0,0 +1,93 @@
/******************************************************************************
*
* Copyright (c) 1994, 1995 Hewlett-Packard Company
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the Hewlett-Packard
* Company shall not be used in advertising or otherwise to promote the
* sale, use or other dealings in this Software without prior written
* authorization from the Hewlett-Packard Company.
*
* Header file for users of machine-independent DBE code
*
*****************************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef MIDBE_STRUCT_H
#define MIDBE_STRUCT_H
/* DEFINES */
#define MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv) \
(((miDbeWindowPrivPrivIndex < 0) || (!pDbeWindowPriv)) ? \
NULL : \
((MiDbeWindowPrivPrivPtr) \
((pDbeWindowPriv)->devPrivates[miDbeWindowPrivPrivIndex].ptr)))
#define MI_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin)\
MI_DBE_WINDOW_PRIV_PRIV(DBE_WINDOW_PRIV(pWin))
#define MI_DBE_SCREEN_PRIV_PRIV(pDbeScreenPriv) \
(((miDbeScreenPrivPrivIndex < 0) || (!pDbeScreenPriv)) ? \
NULL : \
((MiDbeScreenPrivPrivPtr) \
((pDbeScreenPriv)->devPrivates[miDbeScreenPrivPrivIndex].ptr)))
/* TYPEDEFS */
typedef struct _MiDbeWindowPrivPrivRec {
/* Place machine-specific fields in here.
* Since this is mi code, we do not really have machine-specific fields.
*/
/* Pointer to a drawable that contains the contents of the back buffer.
*/
PixmapPtr pBackBuffer;
/* Pointer to a drawable that contains the contents of the front buffer.
* This pointer is only used for the XdbeUntouched swap action. For that
* swap action, we need to copy the front buffer (window) contents into
* this drawable, copy the contents of current back buffer drawable (the
* back buffer) into the window, swap the front and back drawable pointers,
* and then swap the drawable/resource associations in the resource
* database.
*/
PixmapPtr pFrontBuffer;
/* Pointer back to our window private with which we are associated. */
DbeWindowPrivPtr pDbeWindowPriv;
} MiDbeWindowPrivPrivRec, *MiDbeWindowPrivPrivPtr;
typedef struct _MiDbeScreenPrivPrivRec {
/* Place machine-specific fields in here.
* Since this is mi code, we do not really have machine-specific fields.
*/
/* Pointer back to our screen private with which we are associated. */
DbeScreenPrivPtr pDbeScreenPriv;
} MiDbeScreenPrivPrivRec, *MiDbeScreenPrivPrivPtr;
#endif /* MIDBE_STRUCT_H */

33
dix/Makefile.am Normal file
View File

@ -0,0 +1,33 @@
noinst_LTLIBRARIES = libdix.la
AM_CFLAGS = $(DIX_CFLAGS) \
-DVENDOR_STRING=\""@VENDOR_STRING@"\" \
-DVENDOR_RELEASE="@VENDOR_RELEASE@"
libdix_la_SOURCES = \
atom.c \
colormap.c \
cursor.c \
devices.c \
dispatch.c \
dispatch.h \
dixfonts.c \
dixutils.c \
events.c \
extension.c \
ffs.c \
gc.c \
globals.c \
glyphcurs.c \
grabs.c \
initatoms.c \
main.c \
pixmap.c \
privates.c \
property.c \
resource.c \
swaprep.c \
swapreq.c \
tables.c \
window.c \
strcasecmp.c

212
dix/atom.c Normal file
View File

@ -0,0 +1,212 @@
/***********************************************************
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h>
#include <X11/Xatom.h>
#include <stdio.h>
#include <string.h>
#include "misc.h"
#include "resource.h"
#include "dix.h"
#define InitialTableSize 100
typedef struct _Node {
struct _Node *left, *right;
Atom a;
unsigned int fingerPrint;
char *string;
} NodeRec, *NodePtr;
static Atom lastAtom = None;
static NodePtr atomRoot = (NodePtr) NULL;
static unsigned long tableLength;
static NodePtr *nodeTable;
void FreeAtom(NodePtr patom);
_X_EXPORT Atom
MakeAtom(char *string, unsigned len, Bool makeit)
{
NodePtr *np;
unsigned i;
int comp;
unsigned int fp = 0;
np = &atomRoot;
for (i = 0; i < (len + 1) / 2; i++) {
fp = fp * 27 + string[i];
fp = fp * 27 + string[len - 1 - i];
}
while (*np != (NodePtr) NULL) {
if (fp < (*np)->fingerPrint)
np = &((*np)->left);
else if (fp > (*np)->fingerPrint)
np = &((*np)->right);
else { /* now start testing the strings */
comp = strncmp(string, (*np)->string, (int) len);
if ((comp < 0) || ((comp == 0) && (len < strlen((*np)->string))))
np = &((*np)->left);
else if (comp > 0)
np = &((*np)->right);
else
return (*np)->a;
}
}
if (makeit) {
NodePtr nd;
nd = malloc(sizeof(NodeRec));
if (!nd)
return BAD_RESOURCE;
if (lastAtom < XA_LAST_PREDEFINED) {
nd->string = string;
}
else {
nd->string = malloc(len + 1);
if (!nd->string) {
free(nd);
return BAD_RESOURCE;
}
strncpy(nd->string, string, (int) len);
nd->string[len] = 0;
}
if ((lastAtom + 1) >= tableLength) {
NodePtr *table;
table = (NodePtr *) realloc(nodeTable,
tableLength * (2 * sizeof(NodePtr)));
if (!table) {
if (nd->string != string)
free(nd->string);
free(nd);
return BAD_RESOURCE;
}
tableLength <<= 1;
nodeTable = table;
}
*np = nd;
nd->left = nd->right = (NodePtr) NULL;
nd->fingerPrint = fp;
nd->a = (++lastAtom);
*(nodeTable + lastAtom) = nd;
return nd->a;
}
else
return None;
}
_X_EXPORT Bool
ValidAtom(Atom atom)
{
return (atom != None) && (atom <= lastAtom);
}
_X_EXPORT char *
NameForAtom(Atom atom)
{
NodePtr node;
if (atom > lastAtom)
return 0;
if ((node = nodeTable[atom]) == (NodePtr) NULL)
return 0;
return node->string;
}
void
AtomError()
{
FatalError("initializing atoms");
}
void
FreeAtom(NodePtr patom)
{
if (patom->left)
FreeAtom(patom->left);
if (patom->right)
FreeAtom(patom->right);
if (patom->a > XA_LAST_PREDEFINED)
free(patom->string);
free(patom);
}
void
FreeAllAtoms()
{
if (atomRoot == (NodePtr) NULL)
return;
FreeAtom(atomRoot);
atomRoot = (NodePtr) NULL;
free(nodeTable);
nodeTable = (NodePtr *) NULL;
lastAtom = None;
}
void
InitAtoms()
{
FreeAllAtoms();
tableLength = InitialTableSize;
nodeTable = malloc(InitialTableSize * sizeof(NodePtr));
if (!nodeTable)
AtomError();
nodeTable[None] = (NodePtr) NULL;
MakePredeclaredAtoms();
if (lastAtom != XA_LAST_PREDEFINED)
AtomError();
}

2555
dix/colormap.c Normal file

File diff suppressed because it is too large Load Diff

442
dix/cursor.c Normal file
View File

@ -0,0 +1,442 @@
/***********************************************************
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h>
#include <X11/Xmd.h>
#include "servermd.h"
#include "scrnintstr.h"
#include "dixstruct.h"
#include "cursorstr.h"
#include "dixfontstr.h"
#include "opaque.h"
typedef struct _GlyphShare {
FontPtr font;
unsigned short sourceChar;
unsigned short maskChar;
CursorBitsPtr bits;
struct _GlyphShare *next;
} GlyphShare, *GlyphSharePtr;
static GlyphSharePtr sharedGlyphs = (GlyphSharePtr) NULL;
static CARD32 cursorSerial;
static void
FreeCursorBits(CursorBitsPtr bits)
{
if (--bits->refcnt > 0)
return;
free(bits->source);
free(bits->mask);
#ifdef ARGB_CURSOR
free(bits->argb);
#endif
if (bits->refcnt == 0) {
GlyphSharePtr *prev, this;
for (prev = &sharedGlyphs;
(this = *prev) && (this->bits != bits); prev = &this->next);
if (this) {
*prev = this->next;
CloseFont(this->font, (Font) 0);
free(this);
}
free(bits);
}
}
/**
* To be called indirectly by DeleteResource; must use exactly two args.
*
* \param value must conform to DeleteType
*/
_X_EXPORT int
FreeCursor(pointer value, XID cid)
{
int nscr;
CursorPtr pCurs = (CursorPtr) value;
ScreenPtr pscr;
if (--pCurs->refcnt > 0)
return (Success);
for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
pscr = screenInfo.screens[nscr];
(void) (*pscr->UnrealizeCursor) (pscr, pCurs);
}
FreeCursorBits(pCurs->bits);
free(pCurs);
return (Success);
}
/*
* We check for empty cursors so that we won't have to display them
*/
static void
CheckForEmptyMask(CursorBitsPtr bits)
{
unsigned char *msk = bits->mask;
int n = BitmapBytePad(bits->width) * bits->height;
bits->emptyMask = FALSE;
while (n--)
if (*(msk++) != 0)
return;
#ifdef ARGB_CURSOR
if (bits->argb) {
CARD32 *argb = bits->argb;
int n = bits->width * bits->height;
while (n--)
if (*argb++ & 0xff000000)
return;
}
#endif
bits->emptyMask = TRUE;
}
/**
* does nothing about the resource table, just creates the data structure.
* does not copy the src and mask bits
*
* \param psrcbits server-defined padding
* \param pmaskbits server-defined padding
* \param argb no padding
*/
CursorPtr
AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb,
CursorMetricPtr cm,
unsigned foreRed, unsigned foreGreen, unsigned foreBlue,
unsigned backRed, unsigned backGreen, unsigned backBlue)
{
CursorBitsPtr bits;
CursorPtr pCurs;
int nscr;
ScreenPtr pscr;
pCurs = malloc(sizeof(CursorRec) + sizeof(CursorBits));
if (!pCurs) {
free(psrcbits);
free(pmaskbits);
return (CursorPtr) NULL;
}
bits = (CursorBitsPtr) ((char *) pCurs + sizeof(CursorRec));
bits->source = psrcbits;
bits->mask = pmaskbits;
#ifdef ARGB_CURSOR
bits->argb = argb;
#endif
bits->width = cm->width;
bits->height = cm->height;
bits->xhot = cm->xhot;
bits->yhot = cm->yhot;
bits->refcnt = -1;
CheckForEmptyMask(bits);
pCurs->bits = bits;
pCurs->refcnt = 1;
pCurs->serialNumber = ++cursorSerial;
pCurs->name = None;
pCurs->foreRed = foreRed;
pCurs->foreGreen = foreGreen;
pCurs->foreBlue = foreBlue;
pCurs->backRed = backRed;
pCurs->backGreen = backGreen;
pCurs->backBlue = backBlue;
/*
* realize the cursor for every screen
*/
for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
pscr = screenInfo.screens[nscr];
if (!(*pscr->RealizeCursor) (pscr, pCurs)) {
while (--nscr >= 0) {
pscr = screenInfo.screens[nscr];
(*pscr->UnrealizeCursor) (pscr, pCurs);
}
FreeCursorBits(bits);
free(pCurs);
return (CursorPtr) NULL;
}
}
return pCurs;
}
/**
*
* \param psrcbits server-defined padding
* \param pmaskbits server-defined padding
*/
CursorPtr
AllocCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
CursorMetricPtr cm,
unsigned foreRed, unsigned foreGreen, unsigned foreBlue,
unsigned backRed, unsigned backGreen, unsigned backBlue)
{
return AllocCursorARGB(psrcbits, pmaskbits, (CARD32 *) 0, cm,
foreRed, foreGreen, foreBlue,
backRed, backGreen, backBlue);
}
int
AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
unsigned foreRed, unsigned foreGreen, unsigned foreBlue,
unsigned backRed, unsigned backGreen, unsigned backBlue,
CursorPtr *ppCurs, ClientPtr client)
{
FontPtr sourcefont, maskfont;
unsigned char *srcbits;
unsigned char *mskbits;
CursorMetricRec cm;
int res;
CursorBitsPtr bits;
CursorPtr pCurs = NULL;
int nscr;
ScreenPtr pscr;
GlyphSharePtr pShare;
sourcefont = (FontPtr) SecurityLookupIDByType(client, source, RT_FONT,
SecurityReadAccess);
maskfont = (FontPtr) SecurityLookupIDByType(client, mask, RT_FONT,
SecurityReadAccess);
if (!sourcefont) {
client->errorValue = source;
return (BadFont);
}
if (!maskfont && (mask != None)) {
client->errorValue = mask;
return (BadFont);
}
if (sourcefont != maskfont)
pShare = (GlyphSharePtr) NULL;
else {
for (pShare = sharedGlyphs;
pShare &&
((pShare->font != sourcefont) ||
(pShare->sourceChar != sourceChar) ||
(pShare->maskChar != maskChar)); pShare = pShare->next);
}
if (pShare) {
pCurs = malloc(sizeof(CursorRec));
if (!pCurs)
return BadAlloc;
bits = pShare->bits;
bits->refcnt++;
}
else {
if (!CursorMetricsFromGlyph(sourcefont, sourceChar, &cm)) {
client->errorValue = sourceChar;
return BadValue;
}
if (!maskfont) {
long n;
unsigned char *mskptr;
n = BitmapBytePad(cm.width) * (long) cm.height;
mskptr = mskbits = malloc(n);
if (!mskptr)
return BadAlloc;
while (--n >= 0)
*mskptr++ = ~0;
}
else {
if (!CursorMetricsFromGlyph(maskfont, maskChar, &cm)) {
client->errorValue = maskChar;
return BadValue;
}
if ((res =
ServerBitsFromGlyph(maskfont, maskChar, &cm, &mskbits)) != 0)
return res;
}
if ((res =
ServerBitsFromGlyph(sourcefont, sourceChar, &cm, &srcbits)) != 0) {
free(mskbits);
return res;
}
if (sourcefont != maskfont) {
pCurs = malloc(sizeof(CursorRec) + sizeof(CursorBits));
if (pCurs)
bits = (CursorBitsPtr) ((char *) pCurs + sizeof(CursorRec));
else
bits = (CursorBitsPtr) NULL;
}
else {
pCurs = malloc(sizeof(CursorRec));
if (pCurs)
bits = malloc(sizeof(CursorBits));
else
bits = (CursorBitsPtr) NULL;
}
if (!bits) {
free(pCurs);
free(mskbits);
free(srcbits);
return BadAlloc;
}
bits->source = srcbits;
bits->mask = mskbits;
#ifdef ARGB_CURSOR
bits->argb = 0;
#endif
bits->width = cm.width;
bits->height = cm.height;
bits->xhot = cm.xhot;
bits->yhot = cm.yhot;
if (sourcefont != maskfont)
bits->refcnt = -1;
else {
bits->refcnt = 1;
pShare = malloc(sizeof(GlyphShare));
if (!pShare) {
FreeCursorBits(bits);
free(pCurs);
return BadAlloc;
}
pShare->font = sourcefont;
sourcefont->refcnt++;
pShare->sourceChar = sourceChar;
pShare->maskChar = maskChar;
pShare->bits = bits;
pShare->next = sharedGlyphs;
sharedGlyphs = pShare;
}
}
CheckForEmptyMask(bits);
pCurs->bits = bits;
pCurs->refcnt = 1;
pCurs->serialNumber = ++cursorSerial;
pCurs->name = None;
pCurs->foreRed = foreRed;
pCurs->foreGreen = foreGreen;
pCurs->foreBlue = foreBlue;
pCurs->backRed = backRed;
pCurs->backGreen = backGreen;
pCurs->backBlue = backBlue;
/*
* realize the cursor for every screen
*/
for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
pscr = screenInfo.screens[nscr];
if (!(*pscr->RealizeCursor) (pscr, pCurs)) {
while (--nscr >= 0) {
pscr = screenInfo.screens[nscr];
(*pscr->UnrealizeCursor) (pscr, pCurs);
}
FreeCursorBits(pCurs->bits);
free(pCurs);
return BadAlloc;
}
}
*ppCurs = pCurs;
return Success;
}
/** CreateRootCursor
*
* look up the name of a font
* open the font
* add the font to the resource table
* make a cursor from the glyphs
* add the cursor to the resource table
*************************************************************/
CursorPtr
CreateRootCursor(char *pfilename, unsigned glyph)
{
CursorPtr curs;
FontPtr cursorfont;
int err;
XID fontID;
fontID = FakeClientID(0);
err = OpenFont(serverClient, fontID, FontLoadAll | FontOpenSync,
(unsigned) strlen(pfilename), pfilename);
if (err != Success)
return NullCursor;
cursorfont = (FontPtr) LookupIDByType(fontID, RT_FONT);
if (!cursorfont)
return NullCursor;
if (AllocGlyphCursor(fontID, glyph, fontID, glyph + 1,
0, 0, 0, ~0, ~0, ~0, &curs, serverClient) != Success)
return NullCursor;
if (!AddResource(FakeClientID(0), RT_CURSOR, (pointer) curs))
return NullCursor;
return curs;
}

1363
dix/devices.c Normal file

File diff suppressed because it is too large Load Diff

3865
dix/dispatch.c Normal file

File diff suppressed because it is too large Load Diff

146
dix/dispatch.h Normal file
View File

@ -0,0 +1,146 @@
/************************************************************
Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of the above listed
copyright holder(s) not be used in advertising or publicity pertaining
to distribution of the software without specific, written prior