mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 10:20:07 +00:00
Initial revision
This commit is contained in:
commit
9508b76bd2
10
.cvsignore
Normal file
10
.cvsignore
Normal file
@ -0,0 +1,10 @@
|
||||
*.lo
|
||||
config.log
|
||||
config.h
|
||||
libtool
|
||||
config.status
|
||||
stamp-h
|
||||
Makefile
|
||||
gtk+.xconfig
|
||||
config.cache
|
||||
|
3
AUTHORS
Normal file
3
AUTHORS
Normal file
@ -0,0 +1,3 @@
|
||||
Peter Mattis (petm@xcf.berkeley.edu)
|
||||
Spencer Kimball (spencer@xcf.berkeley.edu)
|
||||
Josh MacDonald (jmacd@xcf.berkeley.edu)
|
481
COPYING
Normal file
481
COPYING
Normal file
@ -0,0 +1,481 @@
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, so that any problems introduced by others will not reflect on
|
||||
the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the source code distributed need not include anything that is normally
|
||||
distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
1140
ChangeLog.pre-2-0
Normal file
1140
ChangeLog.pre-2-0
Normal file
File diff suppressed because it is too large
Load Diff
1140
ChangeLog.pre-2-10
Normal file
1140
ChangeLog.pre-2-10
Normal file
File diff suppressed because it is too large
Load Diff
1140
ChangeLog.pre-2-2
Normal file
1140
ChangeLog.pre-2-2
Normal file
File diff suppressed because it is too large
Load Diff
1140
ChangeLog.pre-2-4
Normal file
1140
ChangeLog.pre-2-4
Normal file
File diff suppressed because it is too large
Load Diff
1140
ChangeLog.pre-2-6
Normal file
1140
ChangeLog.pre-2-6
Normal file
File diff suppressed because it is too large
Load Diff
1140
ChangeLog.pre-2-8
Normal file
1140
ChangeLog.pre-2-8
Normal file
File diff suppressed because it is too large
Load Diff
30
Makefile.am
Normal file
30
Makefile.am
Normal file
@ -0,0 +1,30 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
SRC_SUBDIRS = glib gdk gtk
|
||||
SUBDIRS = $(SRC_SUBDIRS) docs
|
||||
|
||||
EXTRA_DIST = gtk+.prj makecopyright TODO
|
||||
|
||||
.PHONY: files populate checkin release
|
||||
|
||||
files:
|
||||
@files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
|
||||
echo $$p; \
|
||||
done
|
||||
@for subdir in $(SUBDIRS); do \
|
||||
files=`cd $$subdir; $(MAKE) files | grep -v "make\[[1-9]\]"`; \
|
||||
for file in $$files; do \
|
||||
echo $$subdir/$$file; \
|
||||
done; \
|
||||
done
|
||||
|
||||
populate:
|
||||
@echo "populating project"
|
||||
@files=`$(MAKE) files | grep -v "make\[[1-9]\]"`; prcs populate -d gtk+.prj $$files
|
||||
|
||||
checkin: populate
|
||||
@echo "checking in project"
|
||||
@prcs checkin
|
||||
|
||||
release:
|
||||
$(MAKE) dist distdir=$(PACKAGE)`date +"%y%m%d"`
|
17
README
Normal file
17
README
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
The official ftp site is:
|
||||
ftp://ftp.gimp.org/pub/gtk
|
||||
|
||||
Patches can be uploaded to:
|
||||
ftp://ftp.gimp.org/incoming
|
||||
|
||||
Anonymous CVS access for gtk+ (as well as 'gimp', 'gimp-data', and
|
||||
'gnome') is available via
|
||||
CVSROOT=:pserver:anonymous@cvs.gnome.org:/home/cvs
|
||||
with an empty password.
|
||||
|
||||
A mailing list is located at:
|
||||
gtk-list@redhat.com
|
||||
|
||||
To subscribe: mail -s subscribe gtk-list-request@redhat.com < /dev/null
|
||||
(Send mail to gtk-list-request@redhat.com with the subject "subscribe")
|
36
TODO
Normal file
36
TODO
Normal file
@ -0,0 +1,36 @@
|
||||
Now
|
||||
---
|
||||
|
||||
3. Fix focus activation of list items. Does list item activation have to be
|
||||
completely reorganized?
|
||||
|
||||
4. Lists should scroll to center the recently selected item if it isn't
|
||||
visible.
|
||||
|
||||
|
||||
The Future
|
||||
----------
|
||||
|
||||
-Documentation
|
||||
|
||||
-Tree widget
|
||||
|
||||
-Text widget (needs to be finished)
|
||||
|
||||
-Widget redrawing when the window resizes sometimes messes up.
|
||||
|
||||
-Make sure a widget added to a list is a list item and a widget added
|
||||
to a menu is a menu item, etc...
|
||||
|
||||
-More dialogs? Print, font, etc?
|
||||
|
||||
-Multiple document interface (MDI)?
|
||||
|
||||
-Support another widget style? Should be possible using GtkStyle's, but
|
||||
there may be some work needed to remove any style dependencies in widget
|
||||
code. Maybe GtkStyle's should have 'draw_push_button', 'draw_check_button',
|
||||
etc, functions to draw the various widgets.
|
||||
|
||||
-OffiX drag and drop support
|
||||
|
||||
-Make all widget attributes configurable after the widget is created.
|
47
acconfig.h
Normal file
47
acconfig.h
Normal file
@ -0,0 +1,47 @@
|
||||
/* acconfig.h
|
||||
This file is in the public domain.
|
||||
|
||||
Descriptive text for the C preprocessor macros that
|
||||
the distributed Autoconf macros can define.
|
||||
No software package will use all of them; autoheader copies the ones
|
||||
your configure.in uses into your configuration header file templates.
|
||||
|
||||
The entries are in sort -df order: alphabetical, case insensitive,
|
||||
ignoring punctuation (such as underscores). Although this order
|
||||
can split up related entries, it makes it easier to check whether
|
||||
a given entry is in the file.
|
||||
|
||||
Leave the following blank line there!! Autoheader needs it. */
|
||||
|
||||
|
||||
/* Other stuff */
|
||||
#undef HAVE_IPC_H
|
||||
#undef HAVE_SHM_H
|
||||
#undef HAVE_XPM
|
||||
#undef HAVE_XSHM_H
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
#undef IPC_RMID_DEFERRED_RELEASE
|
||||
|
||||
#undef NO_FD_SET
|
||||
|
||||
#undef RESOURCE_BASE
|
||||
|
||||
#undef XINPUT_NONE
|
||||
#undef XINPUT_GXI
|
||||
#undef XINPUT_XFREE
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Most machines will be happy with int or void. IRIX requires '...' */
|
||||
#undef SIGNAL_ARG_TYPE
|
||||
|
||||
/* #undef PACKAGE */
|
||||
/* #undef VERSION */
|
||||
|
||||
|
||||
/* Leave that blank line there!! Autoheader needs it.
|
||||
If you're adding to this file, keep in mind:
|
||||
The entries are in sort -df order: alphabetical, case insensitive,
|
||||
ignoring punctuation (such as underscores). */
|
395
aclocal.m4
vendored
Normal file
395
aclocal.m4
vendored
Normal file
@ -0,0 +1,395 @@
|
||||
dnl aclocal.m4 generated automatically by aclocal 1.2
|
||||
|
||||
# Do all the work for Automake. This macro actually does too much --
|
||||
# some checks are only needed if your package does certain things.
|
||||
# But this isn't really a big deal.
|
||||
|
||||
# serial 1
|
||||
|
||||
dnl Usage:
|
||||
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
|
||||
|
||||
AC_DEFUN(AM_INIT_AUTOMAKE,
|
||||
[AC_REQUIRE([AM_PROG_INSTALL])
|
||||
PACKAGE=[$1]
|
||||
AC_SUBST(PACKAGE)
|
||||
VERSION=[$2]
|
||||
AC_SUBST(VERSION)
|
||||
dnl test to see if srcdir already configured
|
||||
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
|
||||
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
|
||||
fi
|
||||
ifelse([$3],,
|
||||
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
|
||||
AC_DEFINE_UNQUOTED(VERSION, "$VERSION"))
|
||||
AM_SANITY_CHECK
|
||||
AC_ARG_PROGRAM
|
||||
dnl FIXME This is truly gross.
|
||||
missing_dir=`cd $ac_aux_dir && pwd`
|
||||
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
|
||||
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
|
||||
AC_PROG_MAKE_SET])
|
||||
|
||||
|
||||
# serial 1
|
||||
|
||||
AC_DEFUN(AM_PROG_INSTALL,
|
||||
[AC_REQUIRE([AC_PROG_INSTALL])
|
||||
test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
|
||||
AC_SUBST(INSTALL_SCRIPT)dnl
|
||||
])
|
||||
|
||||
#
|
||||
# Check to make sure that the build environment is sane.
|
||||
#
|
||||
|
||||
AC_DEFUN(AM_SANITY_CHECK,
|
||||
[AC_MSG_CHECKING([whether build environment is sane])
|
||||
# Just in case
|
||||
sleep 1
|
||||
echo timestamp > conftestfile
|
||||
# Do `set' in a subshell so we don't clobber the current shell's
|
||||
# arguments. Must try -L first in case configure is actually a
|
||||
# symlink; some systems play weird games with the mod time of symlinks
|
||||
# (eg FreeBSD returns the mod time of the symlink's containing
|
||||
# directory).
|
||||
if (
|
||||
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
|
||||
if test "$@" = "X"; then
|
||||
# -L didn't work.
|
||||
set X `ls -t $srcdir/configure conftestfile`
|
||||
fi
|
||||
test "[$]2" = conftestfile
|
||||
)
|
||||
then
|
||||
# Ok.
|
||||
:
|
||||
else
|
||||
AC_MSG_ERROR([newly created file is older than distributed files!
|
||||
Check your system clock])
|
||||
fi
|
||||
rm -f conftest*
|
||||
AC_MSG_RESULT(yes)])
|
||||
|
||||
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
|
||||
dnl The program must properly implement --version.
|
||||
AC_DEFUN(AM_MISSING_PROG,
|
||||
[AC_MSG_CHECKING(for working $2)
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
# Redirect stdin to placate older versions of autoconf. Sigh.
|
||||
if ($2 --version) < /dev/null > /dev/null 2>&1; then
|
||||
$1=$2
|
||||
AC_MSG_RESULT(found)
|
||||
else
|
||||
$1="$3/missing $2"
|
||||
AC_MSG_RESULT(missing)
|
||||
fi
|
||||
AC_SUBST($1)])
|
||||
|
||||
# Like AC_CONFIG_HEADER, but automatically create stamp file.
|
||||
|
||||
AC_DEFUN(AM_CONFIG_HEADER,
|
||||
[AC_PREREQ([2.12])
|
||||
AC_CONFIG_HEADER([$1])
|
||||
dnl When config.status generates a header, we must update the stamp-h file.
|
||||
dnl This file resides in the same directory as the config header
|
||||
dnl that is generated. We must strip everything past the first ":",
|
||||
dnl and everything past the last "/".
|
||||
AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
|
||||
ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
|
||||
<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
|
||||
<<am_indx=1
|
||||
for am_file in <<$1>>; do
|
||||
case " <<$>>CONFIG_HEADERS " in
|
||||
*" <<$>>am_file "*<<)>>
|
||||
echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
|
||||
;;
|
||||
esac
|
||||
am_indx=`expr "<<$>>am_indx" + 1`
|
||||
done<<>>dnl>>)
|
||||
changequote([,]))])
|
||||
|
||||
|
||||
# serial 17 AM_PROG_LIBTOOL
|
||||
AC_DEFUN(AM_PROG_LIBTOOL,
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_REQUIRE([AC_PROG_RANLIB])
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([AM_PROG_LD])
|
||||
AC_REQUIRE([AM_PROG_NM])
|
||||
AC_REQUIRE([AC_PROG_LN_S])
|
||||
|
||||
# Always use our own libtool.
|
||||
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
|
||||
AC_SUBST(LIBTOOL)
|
||||
|
||||
dnl Allow the --disable-shared flag to stop us from building shared libs.
|
||||
AC_ARG_ENABLE(shared,
|
||||
[ --enable-shared build shared libraries [default=yes]],
|
||||
[if test "$enableval" = no; then
|
||||
libtool_enable_shared=no
|
||||
else
|
||||
libtool_enable_shared=yes
|
||||
fi])
|
||||
test -n "$libtool_enable_shared" && enable_shared="$libtool_enable_shared"
|
||||
libtool_shared=
|
||||
test "$enable_shared" = no && libtool_shared=" --disable-shared"
|
||||
|
||||
dnl Allow the --disable-static flag to stop us from building static libs.
|
||||
AC_ARG_ENABLE(static,
|
||||
[ --enable-static build static libraries [default=yes]],
|
||||
[if test "$enableval" = no; then
|
||||
libtool_enable_static=no
|
||||
else
|
||||
libtool_enable_static=yes
|
||||
fi])
|
||||
test -n "$libtool_enable_static" && enable_static="$libtool_enable_static"
|
||||
libtool_static=
|
||||
test "$enable_static" = no && libtool_static=" --disable-static"
|
||||
|
||||
libtool_flags="$libtool_shared$libtool_static"
|
||||
test "$silent" = yes && libtool_flags="$libtool_flags --silent"
|
||||
test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
|
||||
test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
|
||||
|
||||
# Some flags need to be propagated to the compiler or linker for good
|
||||
# libtool support.
|
||||
[case "$host" in
|
||||
*-*-irix6*)
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
flag_passed=no
|
||||
for f in -32 -64 -n32 ABI -cckr -mips1 -mips2 -mips3 -mips4; do
|
||||
case "$f" in
|
||||
ABI)
|
||||
test -n "$SGI_ABI" && flag_passed=yes
|
||||
if test "$flag_passed" = no && test "$ac_cv_prog_gcc" = yes; then
|
||||
# Choose the ABI flag according to GCC's specs.
|
||||
if $CC -dumpspecs 2>&1 | sed '/^\*link:$/,/^$/!d' | egrep -e '[ ]-32' >/dev/null; then
|
||||
LD="${LD-ld} -32"
|
||||
else
|
||||
LD="${LD-ld} -n32"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
if echo " $CC $CFLAGS " | egrep -e "[ ]$f[ ]" > /dev/null; then
|
||||
flag_passed=yes
|
||||
LD="${LD-ld} $f"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
;;
|
||||
|
||||
*-*-sco3.2v5*)
|
||||
# On SCO OpenServer 5, we need -belf to get full-featured binaries.
|
||||
CFLAGS="$CFLAGS -belf"
|
||||
;;
|
||||
esac]
|
||||
|
||||
# Actually configure libtool. ac_aux_dir is where install-sh is found.
|
||||
CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
|
||||
LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
|
||||
${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig \
|
||||
$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
|
||||
|| AC_MSG_ERROR([libtool configure failed])
|
||||
])
|
||||
|
||||
# AM_PROG_LD - find the path to the GNU or non-GNU linker
|
||||
AC_DEFUN(AM_PROG_LD,
|
||||
[AC_ARG_WITH(gnu-ld,
|
||||
[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
|
||||
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
ac_prog=ld
|
||||
if test "$ac_cv_prog_gcc" = yes; then
|
||||
# Check if gcc -print-prog-name=ld gives a path.
|
||||
AC_MSG_CHECKING([for ld used by GCC])
|
||||
ac_prog=`($CC -print-prog-name=ld) 2>&5`
|
||||
case "$ac_prog" in
|
||||
# Accept absolute paths.
|
||||
/*)
|
||||
test -z "$LD" && LD="$ac_prog"
|
||||
;;
|
||||
"")
|
||||
# If it fails, then pretend we aren't using GCC.
|
||||
ac_prog=ld
|
||||
;;
|
||||
*)
|
||||
# If it is relative, then search for the first ld in PATH.
|
||||
with_gnu_ld=unknown
|
||||
;;
|
||||
esac
|
||||
elif test "$with_gnu_ld" = yes; then
|
||||
AC_MSG_CHECKING([for GNU ld])
|
||||
else
|
||||
AC_MSG_CHECKING([for non-GNU ld])
|
||||
fi
|
||||
AC_CACHE_VAL(ac_cv_path_LD,
|
||||
[if test -z "$LD"; then
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -f "$ac_dir/$ac_prog"; then
|
||||
ac_cv_path_LD="$ac_dir/$ac_prog"
|
||||
# Check to see if the program is GNU ld. I'd rather use --version,
|
||||
# but apparently some GNU ld's only accept -v.
|
||||
# Break only if it was the GNU/non-GNU ld that we prefer.
|
||||
if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
|
||||
test "$with_gnu_ld" != no && break
|
||||
else
|
||||
test "$with_gnu_ld" != yes && break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
else
|
||||
ac_cv_path_LD="$LD" # Let the user override the test with a path.
|
||||
fi])
|
||||
LD="$ac_cv_path_LD"
|
||||
if test -n "$LD"; then
|
||||
AC_MSG_RESULT($LD)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
|
||||
AC_SUBST(LD)
|
||||
AM_PROG_LD_GNU
|
||||
])
|
||||
|
||||
AC_DEFUN(AM_PROG_LD_GNU,
|
||||
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
|
||||
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
|
||||
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
|
||||
ac_cv_prog_gnu_ld=yes
|
||||
else
|
||||
ac_cv_prog_gnu_ld=no
|
||||
fi])
|
||||
])
|
||||
|
||||
# AM_PROG_NM - find the path to a BSD-compatible name lister
|
||||
AC_DEFUN(AM_PROG_NM,
|
||||
[AC_MSG_CHECKING([for BSD-compatible nm])
|
||||
AC_CACHE_VAL(ac_cv_path_NM,
|
||||
[case "$NM" in
|
||||
/*)
|
||||
ac_cv_path_NM="$NM" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
|
||||
for ac_dir in /usr/ucb $PATH /bin; do
|
||||
test -z "$ac_dir" && dir=.
|
||||
if test -f $ac_dir/nm; then
|
||||
# Check to see if the nm accepts a BSD-compat flag.
|
||||
if ($ac_dir/nm -B /dev/null 2>&1; exit 0) | grep /dev/null >/dev/null; then
|
||||
ac_cv_path_NM="$ac_dir/nm -B"
|
||||
elif ($ac_dir/nm -p /dev/null 2>&1; exit 0) | grep /dev/null >/dev/null; then
|
||||
ac_cv_path_NM="$ac_dir/nm -p"
|
||||
else
|
||||
ac_cv_path_NM="$ac_dir/nm"
|
||||
fi
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
|
||||
;;
|
||||
esac])
|
||||
NM="$ac_cv_path_NM"
|
||||
AC_MSG_RESULT([$NM])
|
||||
AC_SUBST(NM)
|
||||
])
|
||||
|
||||
# Add --enable-maintainer-mode option to configure.
|
||||
# From Jim Meyering
|
||||
|
||||
# serial 1
|
||||
|
||||
AC_DEFUN(AM_MAINTAINER_MODE,
|
||||
[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
|
||||
dnl maintainer-mode is disabled by default
|
||||
AC_ARG_ENABLE(maintainer-mode,
|
||||
[ --enable-maintainer-mode enable make rules and dependencies not useful
|
||||
(and sometimes confusing) to the casual installer],
|
||||
USE_MAINTAINER_MODE=$enableval,
|
||||
USE_MAINTAINER_MODE=no)
|
||||
AC_MSG_RESULT($USE_MAINTAINER_MODE)
|
||||
if test $USE_MAINTAINER_MODE = yes; then
|
||||
MAINT=
|
||||
else
|
||||
MAINT='#M#'
|
||||
fi
|
||||
AC_SUBST(MAINT)dnl
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
# serial 1
|
||||
|
||||
# @defmac AC_PROG_CC_STDC
|
||||
# @maindex PROG_CC_STDC
|
||||
# @ovindex CC
|
||||
# If the C compiler in not in ANSI C mode by default, try to add an option
|
||||
# to output variable @code{CC} to make it so. This macro tries various
|
||||
# options that select ANSI C on some system or another. It considers the
|
||||
# compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and
|
||||
# handles function prototypes correctly.
|
||||
#
|
||||
# If you use this macro, you should check after calling it whether the C
|
||||
# compiler has been set to accept ANSI C; if not, the shell variable
|
||||
# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
|
||||
# code in ANSI C, you can make an un-ANSIfied copy of it by using the
|
||||
# program @code{ansi2knr}, which comes with Ghostscript.
|
||||
# @end defmac
|
||||
|
||||
AC_DEFUN(AM_PROG_CC_STDC,
|
||||
[AC_REQUIRE([AC_PROG_CC])
|
||||
AC_BEFORE([$0], [AC_C_INLINE])
|
||||
AC_BEFORE([$0], [AC_C_CONST])
|
||||
AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
|
||||
AC_CACHE_VAL(am_cv_prog_cc_stdc,
|
||||
[am_cv_prog_cc_stdc=no
|
||||
ac_save_CC="$CC"
|
||||
# Don't try gcc -ansi; that turns off useful extensions and
|
||||
# breaks some systems' header files.
|
||||
# AIX -qlanglvl=ansi
|
||||
# Ultrix and OSF/1 -std1
|
||||
# HP-UX -Aa -D_HPUX_SOURCE
|
||||
# SVR4 -Xc -D__EXTENSIONS__
|
||||
for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
|
||||
do
|
||||
CC="$ac_save_CC $ac_arg"
|
||||
AC_TRY_COMPILE(
|
||||
[#if !defined(__STDC__) || __STDC__ != 1
|
||||
choke me
|
||||
#endif
|
||||
/* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */
|
||||
#ifdef _SEQUENT_
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
], [
|
||||
int test (int i, double x);
|
||||
struct s1 {int (*f) (int a);};
|
||||
struct s2 {int (*f) (double a);};],
|
||||
[am_cv_prog_cc_stdc="$ac_arg"; break])
|
||||
done
|
||||
CC="$ac_save_CC"
|
||||
])
|
||||
if test -z "$am_cv_prog_cc_stdc"; then
|
||||
AC_MSG_RESULT([none needed])
|
||||
else
|
||||
AC_MSG_RESULT($am_cv_prog_cc_stdc)
|
||||
fi
|
||||
case "x$am_cv_prog_cc_stdc" in
|
||||
x|xno) ;;
|
||||
*) CC="$CC $am_cv_prog_cc_stdc" ;;
|
||||
esac
|
||||
])
|
||||
|
883
config.guess
vendored
Executable file
883
config.guess
vendored
Executable file
@ -0,0 +1,883 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Written by Per Bothner <bothner@cygnus.com>.
|
||||
# The master version of this file is at the FSF in /home/gd/gnu/lib.
|
||||
#
|
||||
# This script attempts to guess a canonical system name similar to
|
||||
# config.sub. If it succeeds, it prints the system name on stdout, and
|
||||
# exits with 0. Otherwise, it exits with 1.
|
||||
#
|
||||
# The plan is that this can be called by configure scripts if you
|
||||
# don't specify an explicit system type (host/target name).
|
||||
#
|
||||
# Only a few systems have been added to this list; please add others
|
||||
# (but try to keep the structure clean).
|
||||
#
|
||||
|
||||
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
|
||||
# (ghazi@noc.rutgers.edu 8/24/94.)
|
||||
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
|
||||
PATH=$PATH:/.attbin ; export PATH
|
||||
fi
|
||||
|
||||
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
|
||||
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
|
||||
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
|
||||
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
|
||||
|
||||
trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
|
||||
|
||||
# Note: order is significant - the case branches are not exclusive.
|
||||
|
||||
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
alpha:OSF1:*:*)
|
||||
if test $UNAME_RELEASE = "V4.0"; then
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
|
||||
fi
|
||||
# A Vn.n version is a released version.
|
||||
# A Tn.n version is a released field test version.
|
||||
# A Xn.n version is an unreleased experimental baselevel.
|
||||
# 1.2 uses "1.2" for uname -r.
|
||||
cat <<EOF >dummy.s
|
||||
.globl main
|
||||
.ent main
|
||||
main:
|
||||
.frame \$30,0,\$26,0
|
||||
.prologue 0
|
||||
.long 0x47e03d80 # implver $0
|
||||
lda \$2,259
|
||||
.long 0x47e20c21 # amask $2,$1
|
||||
srl \$1,8,\$2
|
||||
sll \$2,2,\$2
|
||||
sll \$0,3,\$0
|
||||
addl \$1,\$0,\$0
|
||||
addl \$2,\$0,\$0
|
||||
ret \$31,(\$26),1
|
||||
.end main
|
||||
EOF
|
||||
${CC-cc} dummy.s -o dummy 2>/dev/null
|
||||
if test "$?" = 0 ; then
|
||||
./dummy
|
||||
case "$?" in
|
||||
7)
|
||||
UNAME_MACHINE="alpha"
|
||||
;;
|
||||
15)
|
||||
UNAME_MACHINE="alphaev5"
|
||||
;;
|
||||
14)
|
||||
UNAME_MACHINE="alphaev56"
|
||||
;;
|
||||
10)
|
||||
UNAME_MACHINE="alphapca56"
|
||||
;;
|
||||
16)
|
||||
UNAME_MACHINE="alphaev6"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rm -f dummy.s dummy
|
||||
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]`
|
||||
exit 0 ;;
|
||||
21064:Windows_NT:50:3)
|
||||
echo alpha-dec-winnt3.5
|
||||
exit 0 ;;
|
||||
Amiga*:UNIX_System_V:4.0:*)
|
||||
echo m68k-cbm-sysv4
|
||||
exit 0;;
|
||||
amiga:NetBSD:*:*)
|
||||
echo m68k-cbm-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
amiga:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arc64:OpenBSD:*:*)
|
||||
echo mips64el-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
hkmips:OpenBSD:*:*)
|
||||
echo mips-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
pmax:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sgi:OpenBSD:*:*)
|
||||
echo mips-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
wgrisc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
|
||||
echo arm-acorn-riscix${UNAME_RELEASE}
|
||||
exit 0;;
|
||||
arm32:NetBSD:*:*)
|
||||
echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
SR2?01:HI-UX/MPP:*:*)
|
||||
echo hppa1.1-hitachi-hiuxmpp
|
||||
exit 0;;
|
||||
Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
|
||||
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
|
||||
if test "`(/bin/universe) 2>/dev/null`" = att ; then
|
||||
echo pyramid-pyramid-sysv3
|
||||
else
|
||||
echo pyramid-pyramid-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
NILE:*:*:dcosx)
|
||||
echo pyramid-pyramid-svr4
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
|
||||
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
i86pc:SunOS:5.*:*)
|
||||
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:6*:*)
|
||||
# According to config.sub, this is the proper way to canonicalize
|
||||
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
|
||||
# it's likely to be more like Solaris than SunOS4.
|
||||
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:*:*)
|
||||
case "`/usr/bin/arch -k`" in
|
||||
Series*|S4*)
|
||||
UNAME_RELEASE=`uname -v`
|
||||
;;
|
||||
esac
|
||||
# Japanese Language versions have a version number like `4.1.3-JL'.
|
||||
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
|
||||
exit 0 ;;
|
||||
sun3*:SunOS:*:*)
|
||||
echo m68k-sun-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun*:*:4.2BSD:*)
|
||||
UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
|
||||
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
|
||||
case "`/bin/arch`" in
|
||||
sun3)
|
||||
echo m68k-sun-sunos${UNAME_RELEASE}
|
||||
;;
|
||||
sun4)
|
||||
echo sparc-sun-sunos${UNAME_RELEASE}
|
||||
;;
|
||||
esac
|
||||
exit 0 ;;
|
||||
aushp:SunOS:*:*)
|
||||
echo sparc-auspex-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
atari*:NetBSD:*:*)
|
||||
echo m68k-atari-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
atari*:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3*:NetBSD:*:*)
|
||||
echo m68k-sun-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3*:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:NetBSD:*:*)
|
||||
echo m68k-apple-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mvme68k:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mvme88k:OpenBSD:*:*)
|
||||
echo m88k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
powerpc:machten:*:*)
|
||||
echo powerpc-apple-machten${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
RISC*:Mach:*:*)
|
||||
echo mips-dec-mach_bsd4.3
|
||||
exit 0 ;;
|
||||
RISC*:ULTRIX:*:*)
|
||||
echo mips-dec-ultrix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
VAX*:ULTRIX*:*:*)
|
||||
echo vax-dec-ultrix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
2020:CLIX:*:*)
|
||||
echo clipper-intergraph-clix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mips:*:*:UMIPS | mips:*:*:RISCos)
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
int main (argc, argv) int argc; char **argv; {
|
||||
#if defined (host_mips) && defined (MIPSEB)
|
||||
#if defined (SYSTYPE_SYSV)
|
||||
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#if defined (SYSTYPE_SVR4)
|
||||
printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
|
||||
printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
exit (-1);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy \
|
||||
&& ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
|
||||
&& rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo mips-mips-riscos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
Night_Hawk:Power_UNIX:*:*)
|
||||
echo powerpc-harris-powerunix
|
||||
exit 0 ;;
|
||||
m88k:CX/UX:7*:*)
|
||||
echo m88k-harris-cxux7
|
||||
exit 0 ;;
|
||||
m88k:*:4*:R4*)
|
||||
echo m88k-motorola-sysv4
|
||||
exit 0 ;;
|
||||
m88k:*:3*:R3*)
|
||||
echo m88k-motorola-sysv3
|
||||
exit 0 ;;
|
||||
AViiON:dgux:*:*)
|
||||
# DG/UX returns AViiON for all architectures
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
|
||||
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
|
||||
-o ${TARGET_BINARY_INTERFACE}x = x ] ; then
|
||||
echo m88k-dg-dgux${UNAME_RELEASE}
|
||||
else
|
||||
echo m88k-dg-dguxbcs${UNAME_RELEASE}
|
||||
fi
|
||||
else echo i586-dg-dgux${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
|
||||
echo m88k-dolphin-sysv3
|
||||
exit 0 ;;
|
||||
M88*:*:R3*:*)
|
||||
# Delta 88k system running SVR3
|
||||
echo m88k-motorola-sysv3
|
||||
exit 0 ;;
|
||||
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
|
||||
echo m88k-tektronix-sysv3
|
||||
exit 0 ;;
|
||||
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
|
||||
echo m68k-tektronix-bsd
|
||||
exit 0 ;;
|
||||
*:IRIX*:*:*)
|
||||
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
|
||||
exit 0 ;;
|
||||
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
|
||||
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
|
||||
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
|
||||
i?86:AIX:*:*)
|
||||
echo i386-ibm-aix
|
||||
exit 0 ;;
|
||||
*:AIX:2:3)
|
||||
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
#include <sys/systemcfg.h>
|
||||
|
||||
main()
|
||||
{
|
||||
if (!__power_pc())
|
||||
exit(1);
|
||||
puts("powerpc-ibm-aix3.2.5");
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo rs6000-ibm-aix3.2.5
|
||||
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
echo rs6000-ibm-aix3.2.4
|
||||
else
|
||||
echo rs6000-ibm-aix3.2
|
||||
fi
|
||||
exit 0 ;;
|
||||
*:AIX:*:4)
|
||||
if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
|
||||
IBM_ARCH=rs6000
|
||||
else
|
||||
IBM_ARCH=powerpc
|
||||
fi
|
||||
if [ -x /usr/bin/oslevel ] ; then
|
||||
IBM_REV=`/usr/bin/oslevel`
|
||||
else
|
||||
IBM_REV=4.${UNAME_RELEASE}
|
||||
fi
|
||||
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
|
||||
exit 0 ;;
|
||||
*:AIX:*:*)
|
||||
echo rs6000-ibm-aix
|
||||
exit 0 ;;
|
||||
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
|
||||
echo romp-ibm-bsd4.4
|
||||
exit 0 ;;
|
||||
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
|
||||
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
|
||||
exit 0 ;; # report: romp-ibm BSD 4.3
|
||||
*:BOSX:*:*)
|
||||
echo rs6000-bull-bosx
|
||||
exit 0 ;;
|
||||
DPX/2?00:B.O.S.:*:*)
|
||||
echo m68k-bull-sysv3
|
||||
exit 0 ;;
|
||||
9000/[34]??:4.3bsd:1.*:*)
|
||||
echo m68k-hp-bsd
|
||||
exit 0 ;;
|
||||
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
|
||||
echo m68k-hp-bsd4.4
|
||||
exit 0 ;;
|
||||
9000/[3478]??:HP-UX:*:*)
|
||||
case "${UNAME_MACHINE}" in
|
||||
9000/31? ) HP_ARCH=m68000 ;;
|
||||
9000/[34]?? ) HP_ARCH=m68k ;;
|
||||
9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;;
|
||||
9000/8?? ) HP_ARCH=hppa1.0 ;;
|
||||
esac
|
||||
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
|
||||
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
|
||||
exit 0 ;;
|
||||
3050*:HI-UX:*:*)
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
#include <unistd.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
long cpu = sysconf (_SC_CPU_VERSION);
|
||||
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
|
||||
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
|
||||
results, however. */
|
||||
if (CPU_IS_PA_RISC (cpu))
|
||||
{
|
||||
switch (cpu)
|
||||
{
|
||||
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
|
||||
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
|
||||
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
|
||||
default: puts ("hppa-hitachi-hiuxwe2"); break;
|
||||
}
|
||||
}
|
||||
else if (CPU_IS_HP_MC68K (cpu))
|
||||
puts ("m68k-hitachi-hiuxwe2");
|
||||
else puts ("unknown-hitachi-hiuxwe2");
|
||||
exit (0);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo unknown-hitachi-hiuxwe2
|
||||
exit 0 ;;
|
||||
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
|
||||
echo hppa1.1-hp-bsd
|
||||
exit 0 ;;
|
||||
9000/8??:4.3bsd:*:*)
|
||||
echo hppa1.0-hp-bsd
|
||||
exit 0 ;;
|
||||
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
|
||||
echo hppa1.1-hp-osf
|
||||
exit 0 ;;
|
||||
hp8??:OSF1:*:*)
|
||||
echo hppa1.0-hp-osf
|
||||
exit 0 ;;
|
||||
i?86:OSF1:*:*)
|
||||
if [ -x /usr/sbin/sysversion ] ; then
|
||||
echo ${UNAME_MACHINE}-unknown-osf1mk
|
||||
else
|
||||
echo ${UNAME_MACHINE}-unknown-osf1
|
||||
fi
|
||||
exit 0 ;;
|
||||
parisc*:Lites*:*:*)
|
||||
echo hppa1.1-hp-lites
|
||||
exit 0 ;;
|
||||
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
|
||||
echo c1-convex-bsd
|
||||
exit 0 ;;
|
||||
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
|
||||
if getsysinfo -f scalar_acc
|
||||
then echo c32-convex-bsd
|
||||
else echo c2-convex-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
|
||||
echo c34-convex-bsd
|
||||
exit 0 ;;
|
||||
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
|
||||
echo c38-convex-bsd
|
||||
exit 0 ;;
|
||||
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
|
||||
echo c4-convex-bsd
|
||||
exit 0 ;;
|
||||
CRAY*X-MP:*:*:*)
|
||||
echo xmp-cray-unicos
|
||||
exit 0 ;;
|
||||
CRAY*Y-MP:*:*:*)
|
||||
echo ymp-cray-unicos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
CRAY*[A-Z]90:*:*:*)
|
||||
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
|
||||
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
|
||||
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
|
||||
exit 0 ;;
|
||||
CRAY*TS:*:*:*)
|
||||
echo t90-cray-unicos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
CRAY-2:*:*:*)
|
||||
echo cray2-cray-unicos
|
||||
exit 0 ;;
|
||||
F300:UNIX_System_V:*:*)
|
||||
FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
|
||||
echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit 0 ;;
|
||||
F301:UNIX_System_V:*:*)
|
||||
echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
|
||||
exit 0 ;;
|
||||
hp3[0-9][05]:NetBSD:*:*)
|
||||
echo m68k-hp-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
hp300:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
i?86:BSD/386:*:* | *:BSD/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:FreeBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
|
||||
exit 0 ;;
|
||||
*:NetBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
*:OpenBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo i386-pc-cygwin32
|
||||
exit 0 ;;
|
||||
i*:MINGW*:*)
|
||||
echo i386-pc-mingw32
|
||||
exit 0 ;;
|
||||
p*:CYGWIN*:*)
|
||||
echo powerpcle-unknown-cygwin32
|
||||
exit 0 ;;
|
||||
prep*:SunOS:5.*:*)
|
||||
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
*:GNU:*:*)
|
||||
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
|
||||
exit 0 ;;
|
||||
*:Linux:*:*)
|
||||
# The BFD linker knows what the default object file format is, so
|
||||
# first see if it will tell us.
|
||||
ld_help_string=`ld --help 2>&1`
|
||||
ld_supported_emulations=`echo $ld_help_string \
|
||||
| sed -ne '/supported emulations:/!d
|
||||
s/[ ][ ]*/ /g
|
||||
s/.*supported emulations: *//
|
||||
s/ .*//
|
||||
p'`
|
||||
case "$ld_supported_emulations" in
|
||||
i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;;
|
||||
i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;;
|
||||
sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
|
||||
m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
|
||||
elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;;
|
||||
esac
|
||||
|
||||
if test "${UNAME_MACHINE}" = "alpha" ; then
|
||||
sed 's/^ //' <<EOF >dummy.s
|
||||
.globl main
|
||||
.ent main
|
||||
main:
|
||||
.frame \$30,0,\$26,0
|
||||
.prologue 0
|
||||
.long 0x47e03d80 # implver $0
|
||||
lda \$2,259
|
||||
.long 0x47e20c21 # amask $2,$1
|
||||
srl \$1,8,\$2
|
||||
sll \$2,2,\$2
|
||||
sll \$0,3,\$0
|
||||
addl \$1,\$0,\$0
|
||||
addl \$2,\$0,\$0
|
||||
ret \$31,(\$26),1
|
||||
.end main
|
||||
EOF
|
||||
LIBC=""
|
||||
${CC-cc} dummy.s -o dummy 2>/dev/null
|
||||
if test "$?" = 0 ; then
|
||||
./dummy
|
||||
case "$?" in
|
||||
7)
|
||||
UNAME_MACHINE="alpha"
|
||||
;;
|
||||
15)
|
||||
UNAME_MACHINE="alphaev5"
|
||||
;;
|
||||
14)
|
||||
UNAME_MACHINE="alphaev56"
|
||||
;;
|
||||
10)
|
||||
UNAME_MACHINE="alphapca56"
|
||||
;;
|
||||
16)
|
||||
UNAME_MACHINE="alphaev6"
|
||||
;;
|
||||
esac
|
||||
|
||||
objdump --private-headers dummy | \
|
||||
grep ld.so.1 > /dev/null
|
||||
if test "$?" = 0 ; then
|
||||
LIBC="libc1"
|
||||
fi
|
||||
fi
|
||||
rm -f dummy.s dummy
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
|
||||
elif test "${UNAME_MACHINE}" = "mips" ; then
|
||||
cat >dummy.c <<EOF
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
#ifdef __MIPSEB__
|
||||
printf ("%s-unknown-linux-gnu\n", argv[1]);
|
||||
#endif
|
||||
#ifdef __MIPSEL__
|
||||
printf ("%sel-unknown-linux-gnu\n", argv[1]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
else
|
||||
# Either a pre-BFD a.out linker (linux-gnuoldld)
|
||||
# or one that does not give us useful --help.
|
||||
# GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
|
||||
# If ld does not provide *any* "supported emulations:"
|
||||
# that means it is gnuoldld.
|
||||
echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
|
||||
test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
|
||||
|
||||
case "${UNAME_MACHINE}" in
|
||||
i?86)
|
||||
VENDOR=pc;
|
||||
;;
|
||||
*)
|
||||
VENDOR=unknown;
|
||||
;;
|
||||
esac
|
||||
# Determine whether the default compiler is a.out or elf
|
||||
cat >dummy.c <<EOF
|
||||
#include <features.h>
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
#ifdef __ELF__
|
||||
# ifdef __GLIBC__
|
||||
# if __GLIBC__ >= 2
|
||||
printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
|
||||
# else
|
||||
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
|
||||
# endif
|
||||
# else
|
||||
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
|
||||
# endif
|
||||
#else
|
||||
printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
fi ;;
|
||||
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
|
||||
# are messed up and put the nodename in both sysname and nodename.
|
||||
i?86:DYNIX/ptx:4*:*)
|
||||
echo i386-sequent-sysv4
|
||||
exit 0 ;;
|
||||
i?86:UNIX_SV:4.2MP:2.*)
|
||||
# Unixware is an offshoot of SVR4, but it has its own version
|
||||
# number series starting with 2...
|
||||
# I am not positive that other SVR4 systems won't match this,
|
||||
# I just have to hope. -- rms.
|
||||
# Use sysv4.2uw... so that sysv4* matches it.
|
||||
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
|
||||
exit 0 ;;
|
||||
i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
|
||||
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
|
||||
echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
|
||||
else
|
||||
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
i?86:*:3.2:*)
|
||||
if test -f /usr/options/cb.name; then
|
||||
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
|
||||
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
|
||||
elif /bin/uname -X 2>/dev/null >/dev/null ; then
|
||||
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
|
||||
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
|
||||
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
|
||||
&& UNAME_MACHINE=i586
|
||||
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
|
||||
else
|
||||
echo ${UNAME_MACHINE}-pc-sysv32
|
||||
fi
|
||||
exit 0 ;;
|
||||
pc:*:*:*)
|
||||
# uname -m prints for DJGPP always 'pc', but it prints nothing about
|
||||
# the processor, so we play safe by assuming i386.
|
||||
echo i386-pc-msdosdjgpp
|
||||
exit 0 ;;
|
||||
Intel:Mach:3*:*)
|
||||
echo i386-pc-mach3
|
||||
exit 0 ;;
|
||||
paragon:*:*:*)
|
||||
echo i860-intel-osf1
|
||||
exit 0 ;;
|
||||
i860:*:4.*:*) # i860-SVR4
|
||||
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
|
||||
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
|
||||
else # Add other i860-SVR4 vendors below as they are discovered.
|
||||
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
|
||||
fi
|
||||
exit 0 ;;
|
||||
mini*:CTIX:SYS*5:*)
|
||||
# "miniframe"
|
||||
echo m68010-convergent-sysv
|
||||
exit 0 ;;
|
||||
M68*:*:R3V[567]*:*)
|
||||
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
|
||||
3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
|
||||
OS_REL=''
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& echo i486-ncr-sysv4.3${OS_REL} && exit 0
|
||||
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
|
||||
&& echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
|
||||
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& echo i486-ncr-sysv4 && exit 0 ;;
|
||||
m68*:LynxOS:2.*:*)
|
||||
echo m68k-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mc68030:UNIX_System_V:4.*:*)
|
||||
echo m68k-atari-sysv4
|
||||
exit 0 ;;
|
||||
i?86:LynxOS:2.*:*)
|
||||
echo i386-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
TSUNAMI:LynxOS:2.*:*)
|
||||
echo sparc-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
|
||||
echo rs6000-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
SM[BE]S:UNIX_SV:*:*)
|
||||
echo mips-dde-sysv${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
RM*:SINIX-*:*:*)
|
||||
echo mips-sni-sysv4
|
||||
exit 0 ;;
|
||||
*:SINIX-*:*:*)
|
||||
if uname -p 2>/dev/null >/dev/null ; then
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null`
|
||||
echo ${UNAME_MACHINE}-sni-sysv4
|
||||
else
|
||||
echo ns32k-sni-sysv
|
||||
fi
|
||||
exit 0 ;;
|
||||
PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
|
||||
# says <Richard.M.Bartel@ccMail.Census.GOV>
|
||||
echo i586-unisys-sysv4
|
||||
exit 0 ;;
|
||||
*:UNIX_System_V:4*:FTX*)
|
||||
# From Gerald Hewes <hewes@openmarket.com>.
|
||||
# How about differentiating between stratus architectures? -djm
|
||||
echo hppa1.1-stratus-sysv4
|
||||
exit 0 ;;
|
||||
*:*:*:FTX*)
|
||||
# From seanf@swdc.stratus.com.
|
||||
echo i860-stratus-sysv4
|
||||
exit 0 ;;
|
||||
mc68*:A/UX:*:*)
|
||||
echo m68k-apple-aux${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
news*:NEWS-OS:*:6*)
|
||||
echo mips-sony-newsos6
|
||||
exit 0 ;;
|
||||
R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*)
|
||||
if [ -d /usr/nec ]; then
|
||||
echo mips-nec-sysv${UNAME_RELEASE}
|
||||
else
|
||||
echo mips-unknown-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
|
||||
|
||||
cat >dummy.c <<EOF
|
||||
#ifdef _SEQUENT_
|
||||
# include <sys/types.h>
|
||||
# include <sys/utsname.h>
|
||||
#endif
|
||||
main ()
|
||||
{
|
||||
#if defined (sony)
|
||||
#if defined (MIPSEB)
|
||||
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
|
||||
I don't know.... */
|
||||
printf ("mips-sony-bsd\n"); exit (0);
|
||||
#else
|
||||
#include <sys/param.h>
|
||||
printf ("m68k-sony-newsos%s\n",
|
||||
#ifdef NEWSOS4
|
||||
"4"
|
||||
#else
|
||||
""
|
||||
#endif
|
||||
); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__arm) && defined (__acorn) && defined (__unix)
|
||||
printf ("arm-acorn-riscix"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (hp300) && !defined (hpux)
|
||||
printf ("m68k-hp-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (NeXT)
|
||||
#if !defined (__ARCHITECTURE__)
|
||||
#define __ARCHITECTURE__ "m68k"
|
||||
#endif
|
||||
int version;
|
||||
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
|
||||
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
|
||||
exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (MULTIMAX) || defined (n16)
|
||||
#if defined (UMAXV)
|
||||
printf ("ns32k-encore-sysv\n"); exit (0);
|
||||
#else
|
||||
#if defined (CMU)
|
||||
printf ("ns32k-encore-mach\n"); exit (0);
|
||||
#else
|
||||
printf ("ns32k-encore-bsd\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__386BSD__)
|
||||
printf ("i386-pc-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (sequent)
|
||||
#if defined (i386)
|
||||
printf ("i386-sequent-dynix\n"); exit (0);
|
||||
#endif
|
||||
#if defined (ns32000)
|
||||
printf ("ns32k-sequent-dynix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (_SEQUENT_)
|
||||
struct utsname un;
|
||||
|
||||
uname(&un);
|
||||
|
||||
if (strncmp(un.version, "V2", 2) == 0) {
|
||||
printf ("i386-sequent-ptx2\n"); exit (0);
|
||||
}
|
||||
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
|
||||
printf ("i386-sequent-ptx1\n"); exit (0);
|
||||
}
|
||||
printf ("i386-sequent-ptx\n"); exit (0);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (vax)
|
||||
#if !defined (ultrix)
|
||||
printf ("vax-dec-bsd\n"); exit (0);
|
||||
#else
|
||||
printf ("vax-dec-ultrix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (alliant) && defined (i860)
|
||||
printf ("i860-alliant-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
exit (1);
|
||||
}
|
||||
EOF
|
||||
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
|
||||
# Apollos put the system type in the environment.
|
||||
|
||||
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
|
||||
|
||||
# Convex versions that predate uname can use getsysinfo(1)
|
||||
|
||||
if [ -x /usr/convex/getsysinfo ]
|
||||
then
|
||||
case `getsysinfo -f cpu_type` in
|
||||
c1*)
|
||||
echo c1-convex-bsd
|
||||
exit 0 ;;
|
||||
c2*)
|
||||
if getsysinfo -f scalar_acc
|
||||
then echo c32-convex-bsd
|
||||
else echo c2-convex-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
c34*)
|
||||
echo c34-convex-bsd
|
||||
exit 0 ;;
|
||||
c38*)
|
||||
echo c38-convex-bsd
|
||||
exit 0 ;;
|
||||
c4*)
|
||||
echo c4-convex-bsd
|
||||
exit 0 ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#echo '(Unable to guess system type)' 1>&2
|
||||
|
||||
exit 1
|
36
config.h.in
Normal file
36
config.h.in
Normal file
@ -0,0 +1,36 @@
|
||||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef const
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define if the X Window System is missing or not being used. */
|
||||
#undef X_DISPLAY_MISSING
|
||||
|
||||
/* Other stuff */
|
||||
#undef HAVE_IPC_H
|
||||
#undef HAVE_SHM_H
|
||||
#undef HAVE_XPM
|
||||
#undef HAVE_XSHM_H
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
#undef IPC_RMID_DEFERRED_RELEASE
|
||||
|
||||
#undef NO_FD_SET
|
||||
|
||||
#undef RESOURCE_BASE
|
||||
|
||||
#undef XINPUT_NONE
|
||||
#undef XINPUT_GXI
|
||||
#undef XINPUT_XFREE
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* #undef PACKAGE */
|
||||
/* #undef VERSION */
|
954
config.sub
vendored
Executable file
954
config.sub
vendored
Executable file
@ -0,0 +1,954 @@
|
||||
#! /bin/sh
|
||||
# Configuration validation subroutine script, version 1.1.
|
||||
# Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
# can handle that machine. It does not imply ALL GNU software can.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Configuration subroutine to validate and canonicalize a configuration type.
|
||||
# Supply the specified configuration type as an argument.
|
||||
# If it is invalid, we print an error message on stderr and exit with code 1.
|
||||
# Otherwise, we print the canonical config type on stdout and succeed.
|
||||
|
||||
# This file is supposed to be the same for all GNU packages
|
||||
# and recognize all the CPU types, system types and aliases
|
||||
# that are meaningful with *any* GNU software.
|
||||
# Each package is responsible for reporting which valid configurations
|
||||
# it does not support. The user should be able to distinguish
|
||||
# a failure to support a valid configuration from a meaningless
|
||||
# configuration.
|
||||
|
||||
# The goal of this file is to map all the various variations of a given
|
||||
# machine specification into a single specification in the form:
|
||||
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
|
||||
# or in some cases, the newer four-part form:
|
||||
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
|
||||
# It is wrong to echo any other type of specification.
|
||||
|
||||
if [ x$1 = x ]
|
||||
then
|
||||
echo Configuration name missing. 1>&2
|
||||
echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
|
||||
echo "or $0 ALIAS" 1>&2
|
||||
echo where ALIAS is a recognized configuration type. 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# First pass through any local machine types.
|
||||
case $1 in
|
||||
*local*)
|
||||
echo $1
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
|
||||
# Here we must recognize all the valid KERNEL-OS combinations.
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
linux-gnu*)
|
||||
os=-$maybe_os
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
*)
|
||||
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
|
||||
if [ $basic_machine != $1 ]
|
||||
then os=`echo $1 | sed 's/.*-/-/'`
|
||||
else os=; fi
|
||||
;;
|
||||
esac
|
||||
|
||||
### Let's recognize common machines as not being operating systems so
|
||||
### that things like config.sub decstation-3100 work. We also
|
||||
### recognize some manufacturers as not being operating systems, so we
|
||||
### can provide default operating systems below.
|
||||
case $os in
|
||||
-sun*os*)
|
||||
# Prevent following clause from handling this invalid input.
|
||||
;;
|
||||
-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
|
||||
-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
|
||||
-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
|
||||
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
|
||||
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
|
||||
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
|
||||
-apple)
|
||||
os=
|
||||
basic_machine=$1
|
||||
;;
|
||||
-hiux*)
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
-sco5)
|
||||
os=sco3.2v5
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco4)
|
||||
os=-sco3.2v4
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco3.2.[4-9]*)
|
||||
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco3.2v[4-9]*)
|
||||
# Don't forget version if it is 3.2v4 or newer.
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco*)
|
||||
os=-sco3.2v2
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-isc)
|
||||
os=-isc2.2
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-clix*)
|
||||
basic_machine=clipper-intergraph
|
||||
;;
|
||||
-isc*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-lynx*)
|
||||
os=-lynxos
|
||||
;;
|
||||
-ptx*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
|
||||
;;
|
||||
-windowsnt*)
|
||||
os=`echo $os | sed -e 's/windowsnt/winnt/'`
|
||||
;;
|
||||
-psos*)
|
||||
os=-psos
|
||||
;;
|
||||
esac
|
||||
|
||||
# Decode aliases for certain CPU-COMPANY combinations.
|
||||
case $basic_machine in
|
||||
# Recognize the basic CPU types without company name.
|
||||
# Some are omitted here because they have special meanings below.
|
||||
tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
|
||||
| arme[lb] | pyramid | mn10200 | mn10300 \
|
||||
| tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
|
||||
| alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \
|
||||
| i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
|
||||
| mips64 | mipsel | mips64el | mips64orion | mips64orionel \
|
||||
| mipstx39 | mipstx39el \
|
||||
| sparc | sparclet | sparclite | sparc64 | v850)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
# We use `pc' rather than `unknown'
|
||||
# because (1) that's what they normally are, and
|
||||
# (2) the word "unknown" tends to confuse beginning users.
|
||||
i[3456]86)
|
||||
basic_machine=$basic_machine-pc
|
||||
;;
|
||||
# Object if more than one company name word.
|
||||
*-*-*)
|
||||
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
# Recognize the basic CPU types with company name.
|
||||
vax-* | tahoe-* | i[3456]86-* | i860-* | m32r-* | m68k-* | m68000-* \
|
||||
| m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
|
||||
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
|
||||
| power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
|
||||
| xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \
|
||||
| alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \
|
||||
| ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
|
||||
| sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
|
||||
| sparc64-* | mips64-* | mipsel-* \
|
||||
| mips64el-* | mips64orion-* | mips64orionel-* \
|
||||
| mipstx39-* | mipstx39el-* \
|
||||
| f301-*)
|
||||
;;
|
||||
# Recognize the various machine names and aliases which stand
|
||||
# for a CPU type and a company and sometimes even an OS.
|
||||
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
|
||||
basic_machine=m68000-att
|
||||
;;
|
||||
3b*)
|
||||
basic_machine=we32k-att
|
||||
;;
|
||||
alliant | fx80)
|
||||
basic_machine=fx80-alliant
|
||||
;;
|
||||
altos | altos3068)
|
||||
basic_machine=m68k-altos
|
||||
;;
|
||||
am29k)
|
||||
basic_machine=a29k-none
|
||||
os=-bsd
|
||||
;;
|
||||
amdahl)
|
||||
basic_machine=580-amdahl
|
||||
os=-sysv
|
||||
;;
|
||||
amiga | amiga-*)
|
||||
basic_machine=m68k-cbm
|
||||
;;
|
||||
amigaos | amigados)
|
||||
basic_machine=m68k-cbm
|
||||
os=-amigaos
|
||||
;;
|
||||
amigaunix | amix)
|
||||
basic_machine=m68k-cbm
|
||||
os=-sysv4
|
||||
;;
|
||||
apollo68)
|
||||
basic_machine=m68k-apollo
|
||||
os=-sysv
|
||||
;;
|
||||
aux)
|
||||
basic_machine=m68k-apple
|
||||
os=-aux
|
||||
;;
|
||||
balance)
|
||||
basic_machine=ns32k-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
convex-c1)
|
||||
basic_machine=c1-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c2)
|
||||
basic_machine=c2-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c32)
|
||||
basic_machine=c32-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c34)
|
||||
basic_machine=c34-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c38)
|
||||
basic_machine=c38-convex
|
||||
os=-bsd
|
||||
;;
|
||||
cray | ymp)
|
||||
basic_machine=ymp-cray
|
||||
os=-unicos
|
||||
;;
|
||||
cray2)
|
||||
basic_machine=cray2-cray
|
||||
os=-unicos
|
||||
;;
|
||||
[ctj]90-cray)
|
||||
basic_machine=c90-cray
|
||||
os=-unicos
|
||||
;;
|
||||
crds | unos)
|
||||
basic_machine=m68k-crds
|
||||
;;
|
||||
da30 | da30-*)
|
||||
basic_machine=m68k-da30
|
||||
;;
|
||||
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
|
||||
basic_machine=mips-dec
|
||||
;;
|
||||
delta | 3300 | motorola-3300 | motorola-delta \
|
||||
| 3300-motorola | delta-motorola)
|
||||
basic_machine=m68k-motorola
|
||||
;;
|
||||
delta88)
|
||||
basic_machine=m88k-motorola
|
||||
os=-sysv3
|
||||
;;
|
||||
dpx20 | dpx20-*)
|
||||
basic_machine=rs6000-bull
|
||||
os=-bosx
|
||||
;;
|
||||
dpx2* | dpx2*-bull)
|
||||
basic_machine=m68k-bull
|
||||
os=-sysv3
|
||||
;;
|
||||
ebmon29k)
|
||||
basic_machine=a29k-amd
|
||||
os=-ebmon
|
||||
;;
|
||||
elxsi)
|
||||
basic_machine=elxsi-elxsi
|
||||
os=-bsd
|
||||
;;
|
||||
encore | umax | mmax)
|
||||
basic_machine=ns32k-encore
|
||||
;;
|
||||
fx2800)
|
||||
basic_machine=i860-alliant
|
||||
;;
|
||||
genix)
|
||||
basic_machine=ns32k-ns
|
||||
;;
|
||||
gmicro)
|
||||
basic_machine=tron-gmicro
|
||||
os=-sysv
|
||||
;;
|
||||
h3050r* | hiux*)
|
||||
basic_machine=hppa1.1-hitachi
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
h8300hms)
|
||||
basic_machine=h8300-hitachi
|
||||
os=-hms
|
||||
;;
|
||||
harris)
|
||||
basic_machine=m88k-harris
|
||||
os=-sysv3
|
||||
;;
|
||||
hp300-*)
|
||||
basic_machine=m68k-hp
|
||||
;;
|
||||
hp300bsd)
|
||||
basic_machine=m68k-hp
|
||||
os=-bsd
|
||||
;;
|
||||
hp300hpux)
|
||||
basic_machine=m68k-hp
|
||||
os=-hpux
|
||||
;;
|
||||
hp9k2[0-9][0-9] | hp9k31[0-9])
|
||||
basic_machine=m68000-hp
|
||||
;;
|
||||
hp9k3[2-9][0-9])
|
||||
basic_machine=m68k-hp
|
||||
;;
|
||||
hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
|
||||
basic_machine=hppa1.1-hp
|
||||
;;
|
||||
hp9k8[0-9][0-9] | hp8[0-9][0-9])
|
||||
basic_machine=hppa1.0-hp
|
||||
;;
|
||||
hppa-next)
|
||||
os=-nextstep3
|
||||
;;
|
||||
i370-ibm* | ibm*)
|
||||
basic_machine=i370-ibm
|
||||
os=-mvs
|
||||
;;
|
||||
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
|
||||
i[3456]86v32)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv32
|
||||
;;
|
||||
i[3456]86v4*)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv4
|
||||
;;
|
||||
i[3456]86v)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv
|
||||
;;
|
||||
i[3456]86sol2)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-solaris2
|
||||
;;
|
||||
iris | iris4d)
|
||||
basic_machine=mips-sgi
|
||||
case $os in
|
||||
-irix*)
|
||||
;;
|
||||
*)
|
||||
os=-irix4
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
isi68 | isi)
|
||||
basic_machine=m68k-isi
|
||||
os=-sysv
|
||||
;;
|
||||
m88k-omron*)
|
||||
basic_machine=m88k-omron
|
||||
;;
|
||||
magnum | m3230)
|
||||
basic_machine=mips-mips
|
||||
os=-sysv
|
||||
;;
|
||||
merlin)
|
||||
basic_machine=ns32k-utek
|
||||
os=-sysv
|
||||
;;
|
||||
miniframe)
|
||||
basic_machine=m68000-convergent
|
||||
;;
|
||||
mipsel*-linux*)
|
||||
basic_machine=mipsel-unknown
|
||||
os=-linux-gnu
|
||||
;;
|
||||
mips*-linux*)
|
||||
basic_machine=mips-unknown
|
||||
os=-linux-gnu
|
||||
;;
|
||||
mips3*-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
|
||||
;;
|
||||
mips3*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
|
||||
;;
|
||||
ncr3000)
|
||||
basic_machine=i486-ncr
|
||||
os=-sysv4
|
||||
;;
|
||||
news | news700 | news800 | news900)
|
||||
basic_machine=m68k-sony
|
||||
os=-newsos
|
||||
;;
|
||||
news1000)
|
||||
basic_machine=m68030-sony
|
||||
os=-newsos
|
||||
;;
|
||||
news-3600 | risc-news)
|
||||
basic_machine=mips-sony
|
||||
os=-newsos
|
||||
;;
|
||||
next | m*-next )
|
||||
basic_machine=m68k-next
|
||||
case $os in
|
||||
-nextstep* )
|
||||
;;
|
||||
-ns2*)
|
||||
os=-nextstep2
|
||||
;;
|
||||
*)
|
||||
os=-nextstep3
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
nh3000)
|
||||
basic_machine=m68k-harris
|
||||
os=-cxux
|
||||
;;
|
||||
nh[45]000)
|
||||
basic_machine=m88k-harris
|
||||
os=-cxux
|
||||
;;
|
||||
nindy960)
|
||||
basic_machine=i960-intel
|
||||
os=-nindy
|
||||
;;
|
||||
np1)
|
||||
basic_machine=np1-gould
|
||||
;;
|
||||
pa-hitachi)
|
||||
basic_machine=hppa1.1-hitachi
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
paragon)
|
||||
basic_machine=i860-intel
|
||||
os=-osf
|
||||
;;
|
||||
pbd)
|
||||
basic_machine=sparc-tti
|
||||
;;
|
||||
pbb)
|
||||
basic_machine=m68k-tti
|
||||
;;
|
||||
pc532 | pc532-*)
|
||||
basic_machine=ns32k-pc532
|
||||
;;
|
||||
pentium | p5)
|
||||
basic_machine=i586-intel
|
||||
;;
|
||||
pentiumpro | p6)
|
||||
basic_machine=i686-intel
|
||||
;;
|
||||
pentium-* | p5-*)
|
||||
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentiumpro-* | p6-*)
|
||||
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
k5)
|
||||
# We don't have specific support for AMD's K5 yet, so just call it a Pentium
|
||||
basic_machine=i586-amd
|
||||
;;
|
||||
nexen)
|
||||
# We don't have specific support for Nexgen yet, so just call it a Pentium
|
||||
basic_machine=i586-nexgen
|
||||
;;
|
||||
pn)
|
||||
basic_machine=pn-gould
|
||||
;;
|
||||
power) basic_machine=rs6000-ibm
|
||||
;;
|
||||
ppc) basic_machine=powerpc-unknown
|
||||
;;
|
||||
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ppcle | powerpclittle | ppc-le | powerpc-little)
|
||||
basic_machine=powerpcle-unknown
|
||||
;;
|
||||
ppcle-* | powerpclittle-*)
|
||||
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ps2)
|
||||
basic_machine=i386-ibm
|
||||
;;
|
||||
rm[46]00)
|
||||
basic_machine=mips-siemens
|
||||
;;
|
||||
rtpc | rtpc-*)
|
||||
basic_machine=romp-ibm
|
||||
;;
|
||||
sequent)
|
||||
basic_machine=i386-sequent
|
||||
;;
|
||||
sh)
|
||||
basic_machine=sh-hitachi
|
||||
os=-hms
|
||||
;;
|
||||
sps7)
|
||||
basic_machine=m68k-bull
|
||||
os=-sysv2
|
||||
;;
|
||||
spur)
|
||||
basic_machine=spur-unknown
|
||||
;;
|
||||
sun2)
|
||||
basic_machine=m68000-sun
|
||||
;;
|
||||
sun2os3)
|
||||
basic_machine=m68000-sun
|
||||
os=-sunos3
|
||||
;;
|
||||
sun2os4)
|
||||
basic_machine=m68000-sun
|
||||
os=-sunos4
|
||||
;;
|
||||
sun3os3)
|
||||
basic_machine=m68k-sun
|
||||
os=-sunos3
|
||||
;;
|
||||
sun3os4)
|
||||
basic_machine=m68k-sun
|
||||
os=-sunos4
|
||||
;;
|
||||
sun4os3)
|
||||
basic_machine=sparc-sun
|
||||
os=-sunos3
|
||||
;;
|
||||
sun4os4)
|
||||
basic_machine=sparc-sun
|
||||
os=-sunos4
|
||||
;;
|
||||
sun4sol2)
|
||||
basic_machine=sparc-sun
|
||||
os=-solaris2
|
||||
;;
|
||||
sun3 | sun3-*)
|
||||
basic_machine=m68k-sun
|
||||
;;
|
||||
sun4)
|
||||
basic_machine=sparc-sun
|
||||
;;
|
||||
sun386 | sun386i | roadrunner)
|
||||
basic_machine=i386-sun
|
||||
;;
|
||||
symmetry)
|
||||
basic_machine=i386-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
tx39)
|
||||
basic_machine=mipstx39-unknown
|
||||
;;
|
||||
tx39el)
|
||||
basic_machine=mipstx39el-unknown
|
||||
;;
|
||||
tower | tower-32)
|
||||
basic_machine=m68k-ncr
|
||||
;;
|
||||
udi29k)
|
||||
basic_machine=a29k-amd
|
||||
os=-udi
|
||||
;;
|
||||
ultra3)
|
||||
basic_machine=a29k-nyu
|
||||
os=-sym1
|
||||
;;
|
||||
vaxv)
|
||||
basic_machine=vax-dec
|
||||
os=-sysv
|
||||
;;
|
||||
vms)
|
||||
basic_machine=vax-dec
|
||||
os=-vms
|
||||
;;
|
||||
vpp*|vx|vx-*)
|
||||
basic_machine=f301-fujitsu
|
||||
;;
|
||||
vxworks960)
|
||||
basic_machine=i960-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
vxworks68)
|
||||
basic_machine=m68k-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
vxworks29k)
|
||||
basic_machine=a29k-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
xmp)
|
||||
basic_machine=xmp-cray
|
||||
os=-unicos
|
||||
;;
|
||||
xps | xps100)
|
||||
basic_machine=xps100-honeywell
|
||||
;;
|
||||
none)
|
||||
basic_machine=none-none
|
||||
os=-none
|
||||
;;
|
||||
|
||||
# Here we handle the default manufacturer of certain CPU types. It is in
|
||||
# some cases the only manufacturer, in others, it is the most popular.
|
||||
mips)
|
||||
if [ x$os = x-linux-gnu ]; then
|
||||
basic_machine=mips-unknown
|
||||
else
|
||||
basic_machine=mips-mips
|
||||
fi
|
||||
;;
|
||||
romp)
|
||||
basic_machine=romp-ibm
|
||||
;;
|
||||
rs6000)
|
||||
basic_machine=rs6000-ibm
|
||||
;;
|
||||
vax)
|
||||
basic_machine=vax-dec
|
||||
;;
|
||||
pdp11)
|
||||
basic_machine=pdp11-dec
|
||||
;;
|
||||
we32k)
|
||||
basic_machine=we32k-att
|
||||
;;
|
||||
sparc)
|
||||
basic_machine=sparc-sun
|
||||
;;
|
||||
cydra)
|
||||
basic_machine=cydra-cydrome
|
||||
;;
|
||||
orion)
|
||||
basic_machine=orion-highlevel
|
||||
;;
|
||||
orion105)
|
||||
basic_machine=clipper-highlevel
|
||||
;;
|
||||
*)
|
||||
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Here we canonicalize certain aliases for manufacturers.
|
||||
case $basic_machine in
|
||||
*-digital*)
|
||||
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
|
||||
;;
|
||||
*-commodore*)
|
||||
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Decode manufacturer-specific aliases for certain operating systems.
|
||||
|
||||
if [ x"$os" != x"" ]
|
||||
then
|
||||
case $os in
|
||||
# First match some system type aliases
|
||||
# that might get confused with valid system types.
|
||||
# -solaris* is a basic system type, with this one exception.
|
||||
-solaris1 | -solaris1.*)
|
||||
os=`echo $os | sed -e 's|solaris1|sunos4|'`
|
||||
;;
|
||||
-solaris)
|
||||
os=-solaris2
|
||||
;;
|
||||
-svr4*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-unixware*)
|
||||
os=-sysv4.2uw
|
||||
;;
|
||||
-gnu/linux*)
|
||||
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
|
||||
;;
|
||||
# First accept the basic system types.
|
||||
# The portable systems comes first.
|
||||
# Each alternative MUST END IN A *, to match a version number.
|
||||
# -sysv* is not here because it comes later, after sysvr4.
|
||||
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
|
||||
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
|
||||
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
|
||||
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
|
||||
| -aos* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
|
||||
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
|
||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -linux-gnu* | -uxpv*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-linux*)
|
||||
os=`echo $os | sed -e 's|linux|linux-gnu|'`
|
||||
;;
|
||||
-sunos5*)
|
||||
os=`echo $os | sed -e 's|sunos5|solaris2|'`
|
||||
;;
|
||||
-sunos6*)
|
||||
os=`echo $os | sed -e 's|sunos6|solaris3|'`
|
||||
;;
|
||||
-osfrose*)
|
||||
os=-osfrose
|
||||
;;
|
||||
-osf*)
|
||||
os=-osf
|
||||
;;
|
||||
-utek*)
|
||||
os=-bsd
|
||||
;;
|
||||
-dynix*)
|
||||
os=-bsd
|
||||
;;
|
||||
-acis*)
|
||||
os=-aos
|
||||
;;
|
||||
-ctix* | -uts*)
|
||||
os=-sysv
|
||||
;;
|
||||
-ns2 )
|
||||
os=-nextstep2
|
||||
;;
|
||||
# Preserve the version number of sinix5.
|
||||
-sinix5.*)
|
||||
os=`echo $os | sed -e 's|sinix|sysv|'`
|
||||
;;
|
||||
-sinix*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-triton*)
|
||||
os=-sysv3
|
||||
;;
|
||||
-oss*)
|
||||
os=-sysv3
|
||||
;;
|
||||
-svr4)
|
||||
os=-sysv4
|
||||
;;
|
||||
-svr3)
|
||||
os=-sysv3
|
||||
;;
|
||||
-sysvr4)
|
||||
os=-sysv4
|
||||
;;
|
||||
# This must come after -sysvr4.
|
||||
-sysv*)
|
||||
;;
|
||||
-xenix)
|
||||
os=-xenix
|
||||
;;
|
||||
-none)
|
||||
;;
|
||||
*)
|
||||
# Get rid of the `-' at the beginning of $os.
|
||||
os=`echo $os | sed 's/[^-]*-//'`
|
||||
echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
|
||||
# Here we handle the default operating systems that come with various machines.
|
||||
# The value should be what the vendor currently ships out the door with their
|
||||
# machine or put another way, the most popular os provided with the machine.
|
||||
|
||||
# Note that if you're going to try to match "-MANUFACTURER" here (say,
|
||||
# "-sun"), then you have to tell the case statement up towards the top
|
||||
# that MANUFACTURER isn't an operating system. Otherwise, code above
|
||||
# will signal an error saying that MANUFACTURER isn't an operating
|
||||
# system, and we'll never get to this point.
|
||||
|
||||
case $basic_machine in
|
||||
*-acorn)
|
||||
os=-riscix1.2
|
||||
;;
|
||||
arm*-semi)
|
||||
os=-aout
|
||||
;;
|
||||
pdp11-*)
|
||||
os=-none
|
||||
;;
|
||||
*-dec | vax-*)
|
||||
os=-ultrix4.2
|
||||
;;
|
||||
m68*-apollo)
|
||||
os=-domain
|
||||
;;
|
||||
i386-sun)
|
||||
os=-sunos4.0.2
|
||||
;;
|
||||
m68000-sun)
|
||||
os=-sunos3
|
||||
# This also exists in the configure program, but was not the
|
||||
# default.
|
||||
# os=-sunos4
|
||||
;;
|
||||
*-tti) # must be before sparc entry or we get the wrong os.
|
||||
os=-sysv3
|
||||
;;
|
||||
sparc-* | *-sun)
|
||||
os=-sunos4.1.1
|
||||
;;
|
||||
*-ibm)
|
||||
os=-aix
|
||||
;;
|
||||
*-hp)
|
||||
os=-hpux
|
||||
;;
|
||||
*-hitachi)
|
||||
os=-hiux
|
||||
;;
|
||||
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
|
||||
os=-sysv
|
||||
;;
|
||||
*-cbm)
|
||||
os=-amigaos
|
||||
;;
|
||||
*-dg)
|
||||
os=-dgux
|
||||
;;
|
||||
*-dolphin)
|
||||
os=-sysv3
|
||||
;;
|
||||
m68k-ccur)
|
||||
os=-rtu
|
||||
;;
|
||||
m88k-omron*)
|
||||
os=-luna
|
||||
;;
|
||||
*-next )
|
||||
os=-nextstep
|
||||
;;
|
||||
*-sequent)
|
||||
os=-ptx
|
||||
;;
|
||||
*-crds)
|
||||
os=-unos
|
||||
;;
|
||||
*-ns)
|
||||
os=-genix
|
||||
;;
|
||||
i370-*)
|
||||
os=-mvs
|
||||
;;
|
||||
*-next)
|
||||
os=-nextstep3
|
||||
;;
|
||||
*-gould)
|
||||
os=-sysv
|
||||
;;
|
||||
*-highlevel)
|
||||
os=-bsd
|
||||
;;
|
||||
*-encore)
|
||||
os=-bsd
|
||||
;;
|
||||
*-sgi)
|
||||
os=-irix
|
||||
;;
|
||||
*-siemens)
|
||||
os=-sysv4
|
||||
;;
|
||||
*-masscomp)
|
||||
os=-rtu
|
||||
;;
|
||||
f301-fujitsu)
|
||||
os=-uxpv
|
||||
;;
|
||||
*)
|
||||
os=-none
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Here we handle the case where we know the os, and the CPU type, but not the
|
||||
# manufacturer. We pick the logical manufacturer.
|
||||
vendor=unknown
|
||||
case $basic_machine in
|
||||
*-unknown)
|
||||
case $os in
|
||||
-riscix*)
|
||||
vendor=acorn
|
||||
;;
|
||||
-sunos*)
|
||||
vendor=sun
|
||||
;;
|
||||
-aix*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-hpux*)
|
||||
vendor=hp
|
||||
;;
|
||||
-hiux*)
|
||||
vendor=hitachi
|
||||
;;
|
||||
-unos*)
|
||||
vendor=crds
|
||||
;;
|
||||
-dgux*)
|
||||
vendor=dg
|
||||
;;
|
||||
-luna*)
|
||||
vendor=omron
|
||||
;;
|
||||
-genix*)
|
||||
vendor=ns
|
||||
;;
|
||||
-mvs*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-ptx*)
|
||||
vendor=sequent
|
||||
;;
|
||||
-vxsim* | -vxworks*)
|
||||
vendor=wrs
|
||||
;;
|
||||
-aux*)
|
||||
vendor=apple
|
||||
;;
|
||||
esac
|
||||
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
|
||||
;;
|
||||
esac
|
||||
|
||||
echo $basic_machine$os
|
214
configure.in
Normal file
214
configure.in
Normal file
@ -0,0 +1,214 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(gdk/gdktypes.h)
|
||||
|
||||
# Configure glib
|
||||
AC_CONFIG_SUBDIRS(glib)
|
||||
|
||||
dnl Initialize automake stuff
|
||||
AM_INIT_AUTOMAKE(gtk+, 971109)
|
||||
|
||||
# Specify a configuration file
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
||||
dnl Initialize libtool
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
dnl Initialize maintainer mode
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
AC_ARG_ENABLE(shm, [ --enable-shm support shared memory if available [default=yes]],
|
||||
echo $enable_shm, enable_shm="yes")
|
||||
AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging [default=no]],
|
||||
if eval "test x$enable_debug = xyes"; then
|
||||
DEBUGFLAG="-g"
|
||||
fi)
|
||||
AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]],
|
||||
, enable_ansi=no)
|
||||
|
||||
AC_ARG_WITH(xinput, [ --with-xinput[=no/gxi/xfree] support XInput ])
|
||||
|
||||
if test -n "$DEBUGFLAG"; then
|
||||
CFLAGS="$DEBUGFLAG"
|
||||
else
|
||||
CFLAGS="$CFLAGS -DNDEBUG"
|
||||
fi
|
||||
|
||||
# Build time sanity check...
|
||||
AM_SANITY_CHECK
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_STDC
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
if eval "test x$GCC = xyes"; then
|
||||
test `echo "$CFLAGS" | grep "\-Wall" > /dev/null 2> /dev/null`
|
||||
if test ! $?; then
|
||||
CFLAGS="$CFLAGS -Wall"
|
||||
fi
|
||||
|
||||
if eval "test x$enable_ansi = xyes"; then
|
||||
test `echo "$CFLAGS" | grep "\-ansi" > /dev/null 2> /dev/null`
|
||||
if test ! $?; then
|
||||
CFLAGS="$CFLAGS -ansi"
|
||||
fi
|
||||
|
||||
test `echo "$CFLAGS" | grep "\-pedantic" > /dev/null 2> /dev/null`
|
||||
if test ! $?; then
|
||||
CFLAGS="$CFLAGS -pedantic"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Find the X11 include and library directories
|
||||
AC_PATH_X
|
||||
AC_PATH_XTRA
|
||||
|
||||
if test "x$x_includes" = "x"; then
|
||||
x_includes="/usr/include"
|
||||
fi
|
||||
|
||||
saved_cflags="$CFLAGS"
|
||||
saved_ldflags="$LDFLAGS"
|
||||
|
||||
CFLAGS="$X_CFLAGS"
|
||||
LDFLAGS="$X_LDFLAGS $X_LIBS"
|
||||
|
||||
# Checks for libraries.
|
||||
# Check for the X11 library
|
||||
AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", no_x11_lib=yes, $X_EXTRA_LIBS)
|
||||
|
||||
if eval "test x$enable_shm = xyes"; then
|
||||
# Check for the Xext library (needed for XShm extention)
|
||||
AC_CHECK_LIB(Xext, XShmAttach, x_libs="-lXext $x_libs", no_xext_lib=yes, $x_libs)
|
||||
fi
|
||||
|
||||
x_cflags="$X_CFLAGS"
|
||||
x_ldflags="$X_LDFLAGS $X_LIBS"
|
||||
|
||||
# set up things for XInput
|
||||
|
||||
if eval "test x$with_xinput = xgxi -o x$with_xinput = xyes"; then
|
||||
AC_DEFINE(XINPUT_GXI)
|
||||
xinput_progs=gxid
|
||||
x_libs="-lXi $x_libs"
|
||||
elif eval "test x$with_xinput = xxfree"; then
|
||||
AC_DEFINE(XINPUT_XFREE)
|
||||
x_libs="-lXi $x_libs"
|
||||
else
|
||||
AC_DEFINE(XINPUT_NONE)
|
||||
fi
|
||||
|
||||
|
||||
AC_SUBST(x_cflags)
|
||||
AC_SUBST(x_includes)
|
||||
AC_SUBST(x_ldflags)
|
||||
AC_SUBST(x_libs)
|
||||
AC_SUBST(xinput_progs)
|
||||
|
||||
CFLAGS="$saved_cflags"
|
||||
LDFLAGS="$saved_ldflags"
|
||||
|
||||
if eval "test x$enable_shm = xyes"; then
|
||||
# Check for shared memory
|
||||
AC_CHECK_HEADER(sys/ipc.h, AC_DEFINE(HAVE_IPC_H), no_sys_ipc=yes)
|
||||
AC_CHECK_HEADER(sys/shm.h, AC_DEFINE(HAVE_SHM_H), no_sys_shm=yes)
|
||||
|
||||
# Check whether shmctl IPC_RMID allowes subsequent attaches
|
||||
if test "$ac_cv_header_sys_shm_h" = "yes"; then
|
||||
AC_MSG_CHECKING(whether shmctl IPC_RMID allowes subsequent attaches)
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
int main()
|
||||
{
|
||||
int id;
|
||||
char *shmaddr;
|
||||
id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0777);
|
||||
if (id == -1)
|
||||
exit (2);
|
||||
shmaddr = shmat (id, 0, 0);
|
||||
shmctl (id, IPC_RMID, 0);
|
||||
if ((char*) shmat (id, 0, 0) == (char*) -1)
|
||||
{
|
||||
shmdt (shmaddr);
|
||||
exit (1);
|
||||
}
|
||||
shmdt (shmaddr);
|
||||
shmdt (shmaddr);
|
||||
exit (0);
|
||||
}
|
||||
],
|
||||
AC_DEFINE(IPC_RMID_DEFERRED_RELEASE)
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no),
|
||||
AC_MSG_RESULT(assuming no))
|
||||
fi
|
||||
|
||||
# Check for the X shared memory extension header file
|
||||
AC_MSG_CHECKING(X11/extensions/XShm.h)
|
||||
if eval "test x$no_ext_lib = xyes"; then
|
||||
AC_MSG_RESULT(no)
|
||||
no_xshm=yes
|
||||
else
|
||||
if eval "test -f $x_includes/X11/extensions/XShm.h"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_XSHM_H)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
no_xshm=yes
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for private display resource base variable
|
||||
AC_MSG_CHECKING(resource base field in XDisplay)
|
||||
AC_CACHE_VAL(gtk_cv_display_resource_base,
|
||||
[AC_TRY_RUN([
|
||||
#define XLIB_ILLEGAL_ACCESS
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
Display *display;
|
||||
|
||||
return 0;
|
||||
|
||||
display->resource_base;
|
||||
}],
|
||||
gtk_cv_display_resource_base="resource_base",
|
||||
gtk_cv_display_resource_base="private3")])
|
||||
AC_MSG_RESULT($gtk_cv_display_resource_base)
|
||||
AC_DEFINE_UNQUOTED(RESOURCE_BASE, gdk_display->$gtk_cv_display_resource_base)
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
|
||||
# Checks for library functions.
|
||||
AC_TYPE_SIGNAL
|
||||
|
||||
# Check for sys/select.h
|
||||
|
||||
AC_MSG_CHECKING([fd_set and sys/select])
|
||||
AC_TRY_COMPILE([#include <sys/types.h>],
|
||||
[fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
|
||||
if test $gtk_ok = no; then
|
||||
AC_HEADER_EGREP(fd_mask, sys/select.h, gtk_ok=yes)
|
||||
if test $gtk_ok = yes; then
|
||||
AC_DEFINE(HAVE_SYS_SELECT_H)
|
||||
fi
|
||||
fi
|
||||
AC_MSG_RESULT($gtk_ok)
|
||||
if test $gtk_ok = no; then
|
||||
AC_DEFINE(NO_FD_SET)
|
||||
fi
|
||||
|
||||
AC_OUTPUT(Makefile gtk+.xconfig docs/Makefile gdk/Makefile gtk/Makefile)
|
1
docs/.cvsignore
Normal file
1
docs/.cvsignore
Normal file
@ -0,0 +1 @@
|
||||
Makefile
|
10
docs/Makefile.am
Normal file
10
docs/Makefile.am
Normal file
@ -0,0 +1,10 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
info_TEXINFOS = gdk.texi gtk.texi
|
||||
|
||||
EXTRA_DIST = texinfo.tex macros.texi
|
||||
|
||||
files:
|
||||
@files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
|
||||
echo $$p; \
|
||||
done
|
326
docs/gdk.texi
Normal file
326
docs/gdk.texi
Normal file
@ -0,0 +1,326 @@
|
||||
\input texinfo @c -*-texinfo-*-
|
||||
@c %**start of header
|
||||
@setfilename gdk.info
|
||||
@settitle GDK
|
||||
@setchapternewpage odd
|
||||
@c %**end of header
|
||||
|
||||
@set edition 1.0
|
||||
@set update-date 16 May 1996
|
||||
@set update-month May 1996
|
||||
|
||||
@ifinfo
|
||||
This file documents GDK, the General Drawing Kit
|
||||
|
||||
Copyright (C) 1996 Peter Mattis
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of this
|
||||
manual provided the copyright notice and this permission notice are
|
||||
preserved on all copies
|
||||
|
||||
@ignore
|
||||
Permission is granted to process this file throught TeX and print the
|
||||
results, provided the printed document carries copying permission notice
|
||||
identical to this one except for the removal of this paragraph (this
|
||||
paragraph not being relevant to the printed manual).
|
||||
|
||||
@end ignore
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided that the
|
||||
entire resulting derived work is distributed under the terms of a
|
||||
permission notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions,
|
||||
except that this permission notice may be stated in a translation
|
||||
approved by Peter Mattis.
|
||||
@end ifinfo
|
||||
|
||||
@titlepage
|
||||
@title The General Drawing Kit
|
||||
@subtitle Version 1.0
|
||||
@subtitle @value{update-month}
|
||||
@author by Peter Mattis
|
||||
|
||||
@page
|
||||
@vskip 0pt plus 1filll
|
||||
Copyright @copyright{} 1996 Peter Mattis
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of this
|
||||
manual provided the copyright notice and this permission notice are
|
||||
preserved on all copies.
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided that the
|
||||
entire resulting derived work is distributed under the terms of a
|
||||
permission notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions,
|
||||
except that this permission notice may be stated in a translation
|
||||
approved by Peter Mattis.
|
||||
@end titlepage
|
||||
|
||||
@dircategory User Interface Toolkit
|
||||
@direntry
|
||||
* GDK: (gdk). The General Drawing Kit
|
||||
@end direntry
|
||||
|
||||
@node Top, Copying, (dir), (dir)
|
||||
@top The General Drawing Kit
|
||||
@ifinfo
|
||||
This is edition @value{edition} of the GDK documentation,
|
||||
@w{@value{update-date}}.
|
||||
@end ifinfo
|
||||
|
||||
@menu
|
||||
* Copying:: Your rights.
|
||||
* Overview:: What is GDK?
|
||||
* Initialization:: Initialization and exit.
|
||||
* Events:: Event handling.
|
||||
* Visuals:: Understanding and using visuals.
|
||||
* Windows:: Creating and using windows.
|
||||
* Graphics Contexts:: Creating and modifying GCs.
|
||||
* Pixmaps:: Creating pixmaps.
|
||||
* Images:: Creating images.
|
||||
* Color:: Specifying color.
|
||||
* Fonts:: Creating fonts.
|
||||
* Drawing:: Drawing commands.
|
||||
* XInput Support:: Using extended devices.
|
||||
* Miscellany:: Other stuff.
|
||||
* Examples:: Using GDK.
|
||||
* Function Index:: Index of functions
|
||||
* Concept Index:: Index of concepts
|
||||
@end menu
|
||||
|
||||
@node Copying, Overview, Top, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Copying
|
||||
|
||||
GDK is @dfn{free}; this means that everyone is free to use it and free
|
||||
to redestribute it on a free basis. GDK is not in the public domain; it
|
||||
is copyrighted and there are restrictions on its distribution, but these
|
||||
restrictions are designed to permit everything that a good cooperating
|
||||
citizen would want to do. What is not allowed is to try to prevent
|
||||
others from further sharing any version of GDK that they might get from
|
||||
you.
|
||||
|
||||
Specifically, we want to make sure that you have the right to give away
|
||||
copies of GDK, that you receive source code or else can get it if you
|
||||
want it, that you can change GDK or use pieces of it in new free
|
||||
programs, and that you know you can do these things.
|
||||
|
||||
To make sure that everyone has such rights, we have to forbid you to
|
||||
deprive anyone else of these rights. For example, if you distribute
|
||||
copies of GDK, you must give the recipients all the rights that you
|
||||
have. You must make sure that they, too, receive or can get the source
|
||||
code. And you must tell them their rights.
|
||||
|
||||
Also, for my own protection, we must make certain that everyone finds
|
||||
out that there is no warranty for GDK. If GDK is modified by someone
|
||||
else and passed on, we want their recipients to know that what they have
|
||||
is not what we distributed, so that any problems introduced by others
|
||||
will no reflect on our reputation.
|
||||
|
||||
The precise conditions of the licenses for GDK are found in the General
|
||||
Public Licenses that accompanies it.
|
||||
|
||||
|
||||
@node Overview, Initialization, Copying, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter What is GDK?
|
||||
@cindex Overview
|
||||
|
||||
GDK is designed as a wrapper library that lies on top of Xlib. It
|
||||
performs many common and desired operations for a programmer instead
|
||||
of the programmer having to explicitly ask for such functionality from
|
||||
Xlib directly. For example, GDK provides a common interface to both
|
||||
regular and shared memory XImage types. By doing so, an application
|
||||
can nearly transparently use the fastest image type available. GDK
|
||||
also provides routines for determining the best available color depth
|
||||
and the best available visual which is not always the default visual
|
||||
for a screen.
|
||||
|
||||
@node Initialization, Events, Overview, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Initialization and exit
|
||||
@cindex Initialization
|
||||
@cindex Exit
|
||||
|
||||
Initializing GDK is easy. Simply call @code{gdk_init} passing in the
|
||||
@var{argc} and @var{argv} parameters. Exit is similarly easy. Just
|
||||
call @code{gdk_exit}.
|
||||
|
||||
@deftypefun void gdk_init (int *@var{argc}, char ***@var{argv})
|
||||
Initializes the GDK library. The arguments @var{argc} and @var{argv}
|
||||
are scanned and any arguments that GDK recognizes are handled and
|
||||
removed. The @var{argc} and @var{argv} parameters are the values
|
||||
passed to @code{main} upon program invocation.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void gdk_exit (int @var{errorcode})
|
||||
Exit GDK and perform any necessary cleanup. @code{gdk_exit} will call
|
||||
the systems @code{exit} function passing @var{errorcode} as the
|
||||
parameter.
|
||||
@end deftypefun
|
||||
|
||||
@example
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
@{
|
||||
/* Initialize GDK. */
|
||||
gdk_init (&argc, &argv);
|
||||
|
||||
/* Exit from GDK...this call will never return. */
|
||||
gdk_exit (0);
|
||||
|
||||
/* Keep compiler from issuing a warning */
|
||||
return 0;
|
||||
@}
|
||||
@end example
|
||||
|
||||
|
||||
@node Events, Visuals, Initialization, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Event handling
|
||||
@cindex Events
|
||||
|
||||
Events are the means by which GDK lets the programmer know of user
|
||||
interaction. An event is normally a button or key press or some other
|
||||
indirect user action, such as a the mouse cursor entering or leaving a
|
||||
window.
|
||||
|
||||
There exist only a few functions for getting events and event
|
||||
information. These are @code{gdk_events_pending},
|
||||
@code{gdk_event_get}, @code{gdk_events_record} and
|
||||
@code{gdk_events_playback}. The latter two functions are useful for
|
||||
automatic testing of a software package and should normally not be
|
||||
needed in a program.
|
||||
|
||||
@deftypefun gint gdk_events_pending (void)
|
||||
Returns the number of events pending on the event queue.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun gint gdk_event_get (GdkEvent *@var{event})
|
||||
Return the next available event in the @var{event}
|
||||
structure. @code{gdk_event_get} will return @code{TRUE} on success and
|
||||
@code{FALSE} on failure. Success and failure is determined by whether
|
||||
an event arrived before the timeout period expired.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void gdk_events_record (char *@var{filename})
|
||||
Turn on recording of events. User events and certain system events will
|
||||
be saved in the file named by the variable @var{filename}. This stream
|
||||
of events can later be played back and ``should'' produce the same
|
||||
results as when the original events were handled. However, the
|
||||
programmer does need to be careful in that the state of the program must
|
||||
be the same when @code{gdk_events_record} is called and when
|
||||
@code{gdk_events_playback} is called. For this reason,
|
||||
@code{gdk_events_record} is normally not called directly, but is instead
|
||||
invoked indirectly by specifying the ``-record'' command line option.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void gdk_events_playback (char *@var{filename})
|
||||
Start playback of events from a file. (See the above description of
|
||||
@code{gdk_events_record}). Normally this function is not called directly
|
||||
but is invoked by the ``-playback'' command line option.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void gdk_events_stop (void)
|
||||
Stop recording and playback of events.
|
||||
@end deftypefun
|
||||
|
||||
@example
|
||||
void
|
||||
handle_event ()
|
||||
@{
|
||||
GdkEvent event;
|
||||
|
||||
if (gdk_event_get (&event))
|
||||
@{
|
||||
switch (event.type)
|
||||
@{
|
||||
@dots{}
|
||||
@}
|
||||
@}
|
||||
@}
|
||||
@end example
|
||||
|
||||
|
||||
@node Visuals, Windows, Events, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Understanding and using visuals
|
||||
@cindex Visuals
|
||||
|
||||
@node Windows, Graphics Contexts, Visuals, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Creating and using windows
|
||||
@cindex Windows
|
||||
|
||||
@node Graphics Contexts, Pixmaps, Windows, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Creating and modifying GCs
|
||||
@cindex Graphics Contexts
|
||||
@cindex GC
|
||||
|
||||
@node Pixmaps, Images, Graphics Contexts, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Creating pixmaps
|
||||
@cindex Pixmaps
|
||||
|
||||
@node Images, Color, Pixmaps, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Creating images
|
||||
@cindex Images
|
||||
|
||||
@node Color, Fonts, Images, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Specifying color
|
||||
@cindex Color
|
||||
|
||||
@node Fonts, Drawing, Color, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Creating Fonts
|
||||
@cindex Fonts
|
||||
|
||||
@node Drawing, XInput Support, Fonts, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Drawing Commands
|
||||
@cindex Drawing
|
||||
|
||||
@node XInput Support, Miscellany, Drawing, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Using extended devices
|
||||
@cindex Overview
|
||||
@cindex Using extended device capabilities
|
||||
@cindex Controlling extended devices
|
||||
|
||||
@node Miscellany, Examples, XInput Support, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Other stuff
|
||||
@cindex Timers
|
||||
@cindex Debugging
|
||||
@cindex Miscellaneous
|
||||
|
||||
|
||||
@node Examples, Function Index, Miscellany, Top
|
||||
@comment node-name, next, previous, up
|
||||
@chapter Using GDK
|
||||
@cindex Examples
|
||||
|
||||
|
||||
@node Function Index, Concept Index, Examples, Top
|
||||
@comment node-name, next, previous, up
|
||||
@unnumbered Variable Index
|
||||
|
||||
@printindex fn
|
||||
|
||||
@node Concept Index, , Function Index, Top
|
||||
@comment node-name, next, previous, up
|
||||
@unnumbered Concept Index
|
||||
|
||||
@printindex cp
|
||||
|
||||
@summarycontents
|
||||
@contents
|
||||
@bye
|
3285
docs/gtk.texi
Normal file
3285
docs/gtk.texi
Normal file
File diff suppressed because it is too large
Load Diff
18
docs/macros.texi
Normal file
18
docs/macros.texi
Normal file
@ -0,0 +1,18 @@
|
||||
@macro gtkstdmacros {p, q}
|
||||
|
||||
@deftypefun Gtk\p\* GTK_\q\ (gpointer @var{obj})
|
||||
Cast a generic pointer to @code{Gtk\p\*}. @xref{Standard Macros}, for
|
||||
more info.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun Gtk\p\Class* GTK_\q\_CLASS (gpointer @var{class})
|
||||
Cast a generic pointer to @code{Gtk\p\Class*}. @xref{Standard Macros},
|
||||
for more info.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun gint GTK_IS_\q\ (gpointer @var{obj})
|
||||
Determine if a generic pointer refers to a @code{Gtk\p\}
|
||||
object. @xref{Standard Macros}, for more info.
|
||||
@end deftypefun
|
||||
|
||||
@end macro
|
4692
docs/texinfo.tex
Normal file
4692
docs/texinfo.tex
Normal file
File diff suppressed because it is too large
Load Diff
6
gdk/.cvsignore
Normal file
6
gdk/.cvsignore
Normal file
@ -0,0 +1,6 @@
|
||||
*.lo
|
||||
Makefile
|
||||
.deps
|
||||
_libs
|
||||
libgdk.la
|
||||
|
75
gdk/Makefile.am
Normal file
75
gdk/Makefile.am
Normal file
@ -0,0 +1,75 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
gdkincludedir = $(includedir)/gdk
|
||||
|
||||
lib_LTLIBRARIES = libgdk.la
|
||||
|
||||
libgdk_la_SOURCES = \
|
||||
gdk.c \
|
||||
gdkcolor.c \
|
||||
gdkcursor.c \
|
||||
gdkdraw.c \
|
||||
gdkfont.c \
|
||||
gdkgc.c \
|
||||
gdkglobals.c \
|
||||
gdkimage.c \
|
||||
gdkinput.c \
|
||||
gdkpixmap.c \
|
||||
gdkproperty.c \
|
||||
gdkrectangle.c \
|
||||
gdkselection.c \
|
||||
gdkvisual.c \
|
||||
gdkwindow.c \
|
||||
gdkxid.c \
|
||||
gxid_lib.c
|
||||
## this last one is ifdef'd out unless XINPUT_GXI is defined
|
||||
## It's easier than trying to get automake to handle compiling
|
||||
## it conditionally
|
||||
|
||||
gdkinclude_HEADERS = \
|
||||
gdk.h \
|
||||
gdkcursors.h \
|
||||
gdkkeysyms.h \
|
||||
gdkprivate.h \
|
||||
gdktypes.h \
|
||||
gdkinput.h \
|
||||
gdkinputnone.h \
|
||||
gdkinputcommon.h\
|
||||
gdkinputgxi.h \
|
||||
gdkinputxfree.h \
|
||||
gxid_lib.h \
|
||||
gxid_proto.h \
|
||||
gdkx.h
|
||||
|
||||
libgdk_la_LDFLAGS = -version-info 1:0:0 \
|
||||
@x_ldflags@ @x_libs@
|
||||
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/glib @x_cflags@
|
||||
|
||||
EXTRA_PROGRAMS = gxid
|
||||
|
||||
bin_PROGRAMS = @xinput_progs@
|
||||
|
||||
gxid_SOURCES = gxid.c
|
||||
|
||||
gxid_LDADD = \
|
||||
@x_ldflags@ \
|
||||
@x_libs@ \
|
||||
-lm
|
||||
|
||||
BUILT_SOURCES = gdkcursors.h gdkkeysyms.h
|
||||
|
||||
EXTRA_DIST = makecursors makecursors.sed makekeysyms makekeysyms.sed
|
||||
|
||||
gdkcursors.h:
|
||||
$(srcdir)/makecursors @x_includes@/X11/cursorfont.h > $@
|
||||
|
||||
gdkkeysyms.h:
|
||||
$(srcdir)/makekeysyms @x_includes@/X11/keysymdef.h > $@
|
||||
|
||||
.PHONY: files
|
||||
|
||||
files:
|
||||
@files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
|
||||
echo $$p; \
|
||||
done
|
614
gdk/gdk.h
Normal file
614
gdk/gdk.h
Normal file
@ -0,0 +1,614 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef __GDK_H__
|
||||
#define __GDK_H__
|
||||
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/* Initialization, exit and events
|
||||
*/
|
||||
void gdk_init (int *argc,
|
||||
char ***argv);
|
||||
void gdk_exit (int error_code);
|
||||
gchar* gdk_set_locale (void);
|
||||
|
||||
gint gdk_events_pending (void);
|
||||
gint gdk_event_get (GdkEvent *event,
|
||||
GdkEventFunc pred,
|
||||
gpointer data);
|
||||
void gdk_event_put (GdkEvent *event);
|
||||
|
||||
GdkEvent *gdk_event_copy (GdkEvent *event);
|
||||
void gdk_event_free (GdkEvent *event);
|
||||
|
||||
void gdk_set_debug_level (gint level);
|
||||
void gdk_set_show_events (gint show_events);
|
||||
void gdk_set_use_xshm (gint use_xshm);
|
||||
|
||||
gint gdk_get_debug_level (void);
|
||||
gint gdk_get_show_events (void);
|
||||
gint gdk_get_use_xshm (void);
|
||||
|
||||
guint32 gdk_time_get (void);
|
||||
guint32 gdk_timer_get (void);
|
||||
void gdk_timer_set (guint32 milliseconds);
|
||||
void gdk_timer_enable (void);
|
||||
void gdk_timer_disable (void);
|
||||
|
||||
gint gdk_input_add (gint source,
|
||||
GdkInputCondition condition,
|
||||
GdkInputFunction function,
|
||||
gpointer data);
|
||||
void gdk_input_remove (gint tag);
|
||||
|
||||
gint gdk_pointer_grab (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
GdkCursor * cursor,
|
||||
guint32 time);
|
||||
void gdk_pointer_ungrab (guint32 time);
|
||||
|
||||
gint gdk_keyboard_grab (GdkWindow * window,
|
||||
gint owner_events,
|
||||
guint32 time);
|
||||
void gdk_keyboard_ungrab (guint32 time);
|
||||
|
||||
gint gdk_screen_width (void);
|
||||
gint gdk_screen_height (void);
|
||||
|
||||
void gdk_flush (void);
|
||||
void gdk_beep (void);
|
||||
|
||||
void gdk_key_repeat_disable (void);
|
||||
void gdk_key_repeat_restore (void);
|
||||
|
||||
|
||||
/* Visuals
|
||||
*/
|
||||
gint gdk_visual_get_best_depth (void);
|
||||
GdkVisualType gdk_visual_get_best_type (void);
|
||||
GdkVisual* gdk_visual_get_system (void);
|
||||
GdkVisual* gdk_visual_get_best (void);
|
||||
GdkVisual* gdk_visual_get_best_with_depth (gint depth);
|
||||
GdkVisual* gdk_visual_get_best_with_type (GdkVisualType visual_type);
|
||||
GdkVisual* gdk_visual_get_best_with_both (gint depth,
|
||||
GdkVisualType visual_type);
|
||||
|
||||
/* Actually, these are no-ops... */
|
||||
GdkVisual* gdk_visual_ref (GdkVisual *visual);
|
||||
void gdk_visual_unref (GdkVisual *visual);
|
||||
|
||||
void gdk_query_depths (gint **depths,
|
||||
gint *count);
|
||||
void gdk_query_visual_types (GdkVisualType **visual_types,
|
||||
gint *count);
|
||||
void gdk_query_visuals (GdkVisual **visuals,
|
||||
gint *count);
|
||||
|
||||
|
||||
/* Windows
|
||||
*/
|
||||
GdkWindow* gdk_window_new (GdkWindow *parent,
|
||||
GdkWindowAttr *attributes,
|
||||
gint attributes_mask);
|
||||
|
||||
GdkWindow * gdk_window_foreign_new (guint32 anid);
|
||||
void gdk_window_destroy (GdkWindow *window);
|
||||
GdkWindow* gdk_window_ref (GdkWindow *window);
|
||||
void gdk_window_unref (GdkWindow *window);
|
||||
|
||||
void gdk_window_show (GdkWindow *window);
|
||||
void gdk_window_hide (GdkWindow *window);
|
||||
void gdk_window_move (GdkWindow *window,
|
||||
gint x,
|
||||
gint y);
|
||||
void gdk_window_resize (GdkWindow *window,
|
||||
gint width,
|
||||
gint height);
|
||||
void gdk_window_move_resize (GdkWindow *window,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
void gdk_window_reparent (GdkWindow *window,
|
||||
GdkWindow *new_parent,
|
||||
gint x,
|
||||
gint y);
|
||||
void gdk_window_clear (GdkWindow *window);
|
||||
void gdk_window_clear_area (GdkWindow *window,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
void gdk_window_clear_area_e(GdkWindow *window,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
void gdk_window_copy_area (GdkWindow *window,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
GdkWindow *source_window,
|
||||
gint source_x,
|
||||
gint source_y,
|
||||
gint width,
|
||||
gint height);
|
||||
void gdk_window_raise (GdkWindow *window);
|
||||
void gdk_window_lower (GdkWindow *window);
|
||||
|
||||
void gdk_window_set_user_data (GdkWindow *window,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
/*
|
||||
* This allows for making shaped (partially transparent) windows
|
||||
* - cool feature, needed for Drag and Drag for example.
|
||||
* The shape_mask can be the mask
|
||||
* from gdk_pixmap_create_from_xpm. Stefan Wille
|
||||
*/
|
||||
void gdk_window_shape_combine_mask (GdkWindow *window,
|
||||
GdkBitmap *shape_mask,
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
|
||||
/*
|
||||
* Drag & Drop
|
||||
* Algorithm (drop source):
|
||||
* A window being dragged will be sent a GDK_DRAG_BEGIN message.
|
||||
* It will then do gdk_dnd_drag_addwindow() for any other windows that are to be
|
||||
* dragged.
|
||||
* When we get a DROP_ENTER incoming, we send it on to the window in question.
|
||||
* That window needs to use gdk_dnd_drop_enter_reply() to indicate the state of
|
||||
* things (it must call that even if it's not going to accept the drop)
|
||||
*
|
||||
* These two turn on/off drag or drop, and if enabling it also
|
||||
* sets the list of types supported. The list of types passed in
|
||||
* should be in order of decreasing preference.
|
||||
*/
|
||||
void gdk_window_dnd_drag_set (GdkWindow *window,
|
||||
guint8 drag_enable,
|
||||
gchar **typelist,
|
||||
guint numtypes);
|
||||
|
||||
/*
|
||||
*XXX todo: add a GDK_DROP_ENTER which can look at actual data
|
||||
*/
|
||||
void gdk_window_dnd_drop_set (GdkWindow *window,
|
||||
guint8 drop_enable,
|
||||
gchar **typelist,
|
||||
guint numtypes,
|
||||
guint8 destructive_op);
|
||||
|
||||
/*
|
||||
* This is used by the GDK_DRAG_BEGIN handler. An example of usage would be a
|
||||
* file manager where multiple icons were selected and the drag began.
|
||||
* The icon that the drag actually began on would gdk_dnd_drag_addwindow
|
||||
* for all the other icons that were being dragged...
|
||||
*/
|
||||
void gdk_dnd_drag_addwindow (GdkWindow *window);
|
||||
void gdk_window_dnd_data_set (GdkWindow *window,
|
||||
GdkEvent *event,
|
||||
gpointer data,
|
||||
gulong data_numbytes);
|
||||
|
||||
|
||||
void gdk_window_set_hints (GdkWindow *window,
|
||||
gint x,
|
||||
gint y,
|
||||
gint min_width,
|
||||
gint min_height,
|
||||
gint max_width,
|
||||
gint max_height,
|
||||
gint flags);
|
||||
void gdk_window_set_title (GdkWindow *window,
|
||||
const gchar *title);
|
||||
void gdk_window_set_background (GdkWindow *window,
|
||||
GdkColor *color);
|
||||
void gdk_window_set_back_pixmap (GdkWindow *window,
|
||||
GdkPixmap *pixmap,
|
||||
gint parent_relative);
|
||||
void gdk_window_set_cursor (GdkWindow *window,
|
||||
GdkCursor *cursor);
|
||||
void gdk_window_set_colormap (GdkWindow *window,
|
||||
GdkColormap *colormap);
|
||||
void gdk_window_get_user_data (GdkWindow *window,
|
||||
gpointer *data);
|
||||
void gdk_window_get_geometry (GdkWindow *window,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gint *width,
|
||||
gint *height,
|
||||
gint *depth);
|
||||
void gdk_window_get_position (GdkWindow *window,
|
||||
gint *x,
|
||||
gint *y);
|
||||
void gdk_window_get_size (GdkWindow *window,
|
||||
gint *width,
|
||||
gint *height);
|
||||
GdkVisual* gdk_window_get_visual (GdkWindow *window);
|
||||
GdkColormap* gdk_window_get_colormap (GdkWindow *window);
|
||||
GdkWindowType gdk_window_get_type (GdkWindow *window);
|
||||
gint gdk_window_get_origin (GdkWindow *window,
|
||||
gint *x,
|
||||
gint *y);
|
||||
GdkWindow* gdk_window_get_pointer (GdkWindow *window,
|
||||
gint *x,
|
||||
gint *y,
|
||||
GdkModifierType *mask);
|
||||
GdkWindow* gdk_window_get_parent (GdkWindow *window);
|
||||
GdkWindow* gdk_window_get_toplevel (GdkWindow *window);
|
||||
GList* gdk_window_get_children (GdkWindow *window);
|
||||
GdkEventMask gdk_window_get_events (GdkWindow *window);
|
||||
void gdk_window_set_events (GdkWindow *window,
|
||||
GdkEventMask event_mask);
|
||||
|
||||
/* Cursors
|
||||
*/
|
||||
GdkCursor* gdk_cursor_new (GdkCursorType cursor_type);
|
||||
void gdk_cursor_destroy (GdkCursor *cursor);
|
||||
|
||||
|
||||
/* GCs
|
||||
*/
|
||||
GdkGC* gdk_gc_new (GdkWindow *window);
|
||||
GdkGC* gdk_gc_new_with_values (GdkWindow *window,
|
||||
GdkGCValues *values,
|
||||
GdkGCValuesMask values_mask);
|
||||
void gdk_gc_destroy (GdkGC *gc);
|
||||
void gdk_gc_get_values (GdkGC *gc,
|
||||
GdkGCValues *values);
|
||||
void gdk_gc_set_foreground (GdkGC *gc,
|
||||
GdkColor *color);
|
||||
void gdk_gc_set_background (GdkGC *gc,
|
||||
GdkColor *color);
|
||||
void gdk_gc_set_font (GdkGC *gc,
|
||||
GdkFont *font);
|
||||
void gdk_gc_set_function (GdkGC *gc,
|
||||
GdkFunction function);
|
||||
void gdk_gc_set_fill (GdkGC *gc,
|
||||
GdkFill fill);
|
||||
void gdk_gc_set_tile (GdkGC *gc,
|
||||
GdkPixmap *tile);
|
||||
void gdk_gc_set_stipple (GdkGC *gc,
|
||||
GdkPixmap *stipple);
|
||||
void gdk_gc_set_ts_origin (GdkGC *gc,
|
||||
gint x,
|
||||
gint y);
|
||||
void gdk_gc_set_clip_origin (GdkGC *gc,
|
||||
gint x,
|
||||
gint y);
|
||||
void gdk_gc_set_clip_mask (GdkGC *gc,
|
||||
GdkBitmap *mask);
|
||||
void gdk_gc_set_clip_rectangle (GdkGC *gc,
|
||||
GdkRectangle *rectangle);
|
||||
void gdk_gc_set_subwindow (GdkGC *gc,
|
||||
GdkSubwindowMode mode);
|
||||
void gdk_gc_set_exposures (GdkGC *gc,
|
||||
gint exposures);
|
||||
void gdk_gc_set_line_attributes (GdkGC *gc,
|
||||
gint line_width,
|
||||
GdkLineStyle line_style,
|
||||
GdkCapStyle cap_style,
|
||||
GdkJoinStyle join_style);
|
||||
|
||||
|
||||
/* Pixmaps
|
||||
*/
|
||||
GdkPixmap* gdk_pixmap_new (GdkWindow *window,
|
||||
gint width,
|
||||
gint height,
|
||||
gint depth);
|
||||
GdkBitmap* gdk_bitmap_create_from_data (GdkWindow *window,
|
||||
gchar *data,
|
||||
gint width,
|
||||
gint height);
|
||||
GdkPixmap* gdk_pixmap_create_from_data (GdkWindow *window,
|
||||
gchar *data,
|
||||
gint width,
|
||||
gint height,
|
||||
gint depth,
|
||||
GdkColor *fg,
|
||||
GdkColor *bg);
|
||||
GdkPixmap* gdk_pixmap_create_from_xpm (GdkWindow *window,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
const gchar *filename);
|
||||
GdkPixmap* gdk_pixmap_create_from_xpm_d (GdkWindow *window,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
gchar **data);
|
||||
void gdk_pixmap_destroy (GdkPixmap *pixmap);
|
||||
|
||||
|
||||
|
||||
/* Images
|
||||
*/
|
||||
GdkImage* gdk_image_new_bitmap(GdkVisual *,
|
||||
gpointer,
|
||||
gint,
|
||||
gint);
|
||||
GdkImage* gdk_image_new (GdkImageType type,
|
||||
GdkVisual *visual,
|
||||
gint width,
|
||||
gint height);
|
||||
GdkImage* gdk_image_get (GdkWindow *window,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
void gdk_image_put_pixel (GdkImage *image,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 pixel);
|
||||
guint32 gdk_image_get_pixel (GdkImage *image,
|
||||
gint x,
|
||||
gint y);
|
||||
void gdk_image_destroy (GdkImage *image);
|
||||
|
||||
|
||||
/* Color
|
||||
*/
|
||||
GdkColormap* gdk_colormap_new (GdkVisual *visual,
|
||||
gint allocate);
|
||||
void gdk_colormap_destroy (GdkColormap *colormap);
|
||||
|
||||
GdkColormap* gdk_colormap_ref (GdkColormap *cmap);
|
||||
void gdk_colormap_unref (GdkColormap *cmap);
|
||||
|
||||
GdkColormap* gdk_colormap_get_system (void);
|
||||
gint gdk_colormap_get_system_size (void);
|
||||
|
||||
void gdk_colormap_change (GdkColormap *colormap,
|
||||
gint ncolors);
|
||||
void gdk_colors_store (GdkColormap *colormap,
|
||||
GdkColor *colors,
|
||||
gint ncolors);
|
||||
gint gdk_colors_alloc (GdkColormap *colormap,
|
||||
gint contiguous,
|
||||
gulong *planes,
|
||||
gint nplanes,
|
||||
gulong *pixels,
|
||||
gint npixels);
|
||||
void gdk_colors_free (GdkColormap *colormap,
|
||||
gulong *pixels,
|
||||
gint npixels,
|
||||
gulong planes);
|
||||
gint gdk_color_white (GdkColormap *colormap,
|
||||
GdkColor *color);
|
||||
gint gdk_color_black (GdkColormap *colormap,
|
||||
GdkColor *color);
|
||||
gint gdk_color_parse (const gchar *spec,
|
||||
GdkColor *color);
|
||||
gint gdk_color_alloc (GdkColormap *colormap,
|
||||
GdkColor *color);
|
||||
gint gdk_color_change (GdkColormap *colormap,
|
||||
GdkColor *color);
|
||||
gint gdk_color_equal (GdkColor *colora,
|
||||
GdkColor *colorb);
|
||||
|
||||
|
||||
/* Fonts
|
||||
*/
|
||||
GdkFont* gdk_font_load (const gchar *font_name);
|
||||
GdkFont* gdk_fontset_load (gchar *fontset_name);
|
||||
void gdk_font_free (GdkFont *font);
|
||||
void gdk_fontset_free (GdkFont *font);
|
||||
GdkFont* gdk_font_ref (GdkFont *font);
|
||||
gint gdk_font_id (GdkFont *font);
|
||||
gint gdk_font_equal (GdkFont *fonta,
|
||||
GdkFont *fontb);
|
||||
gint gdk_string_width (GdkFont *font,
|
||||
const gchar *string);
|
||||
gint gdk_text_width (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length);
|
||||
gint gdk_char_width (GdkFont *font,
|
||||
gchar character);
|
||||
gint gdk_string_measure (GdkFont *font,
|
||||
const gchar *string);
|
||||
gint gdk_text_measure (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length);
|
||||
gint gdk_char_measure (GdkFont *font,
|
||||
gchar character);
|
||||
|
||||
|
||||
/* Drawing
|
||||
*/
|
||||
void gdk_draw_point (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y);
|
||||
void gdk_draw_line (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2);
|
||||
void gdk_draw_rectangle (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint filled,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
void gdk_draw_arc (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint filled,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint angle1,
|
||||
gint angle2);
|
||||
void gdk_draw_polygon (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint filled,
|
||||
GdkPoint *points,
|
||||
gint npoints);
|
||||
void gdk_draw_string (GdkDrawable *drawable,
|
||||
GdkFont *font,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
const gchar *string);
|
||||
void gdk_draw_text (GdkDrawable *drawable,
|
||||
GdkFont *font,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
const gchar *text,
|
||||
gint text_length);
|
||||
void gdk_draw_pixmap (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkDrawable *src,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height);
|
||||
void gdk_draw_bitmap (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkDrawable *src,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height);
|
||||
void gdk_draw_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height);
|
||||
void gdk_draw_points (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkPoint *points,
|
||||
gint npoints);
|
||||
void gdk_draw_segments (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkSegment *segs,
|
||||
gint nsegs);
|
||||
|
||||
|
||||
/* Selections
|
||||
*/
|
||||
gint gdk_selection_owner_set (GdkWindow *owner,
|
||||
GdkAtom selection,
|
||||
guint32 time,
|
||||
gint send_event);
|
||||
GdkWindow* gdk_selection_owner_get (GdkAtom selection);
|
||||
void gdk_selection_convert (GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time);
|
||||
gint gdk_selection_property_get (GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *prop_type,
|
||||
gint *prop_format);
|
||||
void gdk_selection_send_notify (guint32 requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time);
|
||||
|
||||
/* Properties
|
||||
*/
|
||||
GdkAtom gdk_atom_intern (const gchar *atom_name,
|
||||
gint only_if_exists);
|
||||
gchar* gdk_atom_name (GdkAtom atom);
|
||||
gint gdk_property_get (GdkWindow *window,
|
||||
GdkAtom property,
|
||||
GdkAtom type,
|
||||
gulong offset,
|
||||
gulong length,
|
||||
gint pdelete,
|
||||
GdkAtom *actual_property_type,
|
||||
gint *actual_format,
|
||||
gint *actual_length,
|
||||
guchar **data);
|
||||
|
||||
void gdk_property_change (GdkWindow *window,
|
||||
GdkAtom property,
|
||||
GdkAtom type,
|
||||
gint format,
|
||||
GdkPropMode mode,
|
||||
guchar *data,
|
||||
gint nelements);
|
||||
void gdk_property_delete (GdkWindow *window,
|
||||
GdkAtom property);
|
||||
|
||||
|
||||
/* Rectangle utilities
|
||||
*/
|
||||
gint gdk_rectangle_intersect (GdkRectangle *src1,
|
||||
GdkRectangle *src2,
|
||||
GdkRectangle *dest);
|
||||
|
||||
/* XInput support
|
||||
*/
|
||||
|
||||
void gdk_input_init (void);
|
||||
void gdk_input_exit (void);
|
||||
GList *gdk_input_list_devices (void);
|
||||
void gdk_input_set_extension_events (GdkWindow *window,
|
||||
gint mask,
|
||||
GdkExtensionMode mode);
|
||||
void gdk_input_set_source (guint32 deviceid,
|
||||
GdkInputSource source);
|
||||
gint gdk_input_set_mode (guint32 deviceid,
|
||||
GdkInputMode mode);
|
||||
void gdk_input_set_axes (guint32 deviceid,
|
||||
GdkAxisUse *axes);
|
||||
void gdk_input_window_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask);
|
||||
|
||||
GdkTimeCoord *gdk_input_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return);
|
||||
|
||||
/* Miscellaneous */
|
||||
void gdk_event_send_clientmessage_toall(GdkEvent *event);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif /* __GDK_H__ */
|
718
gdk/gdkcolor.c
Normal file
718
gdk/gdkcolor.c
Normal file
@ -0,0 +1,718 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
static gint gdk_colormap_match_color (GdkColormap *cmap,
|
||||
GdkColor *color,
|
||||
const gchar *available);
|
||||
static void gdk_colormap_add (GdkColormap *cmap);
|
||||
static void gdk_colormap_remove (GdkColormap *cmap);
|
||||
static guint gdk_colormap_hash (Colormap *cmap);
|
||||
static gint gdk_colormap_cmp (Colormap *a,
|
||||
Colormap *b);
|
||||
|
||||
static GHashTable *colormap_hash = NULL;
|
||||
|
||||
|
||||
GdkColormap*
|
||||
gdk_colormap_new (GdkVisual *visual,
|
||||
gint private_cmap)
|
||||
{
|
||||
GdkColormap *colormap;
|
||||
GdkColormapPrivate *private;
|
||||
Visual *xvisual;
|
||||
XColor default_colors[256];
|
||||
int size;
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (visual != NULL, NULL);
|
||||
|
||||
private = g_new (GdkColormapPrivate, 1);
|
||||
colormap = (GdkColormap*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->visual = visual;
|
||||
private->next_color = 0;
|
||||
private->ref_count = 1;
|
||||
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
||||
|
||||
switch (visual->type)
|
||||
{
|
||||
case GDK_VISUAL_GRAYSCALE:
|
||||
case GDK_VISUAL_PSEUDO_COLOR:
|
||||
private->private_val = private_cmap;
|
||||
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
|
||||
xvisual, (private_cmap) ? (AllocAll) : (AllocNone));
|
||||
|
||||
if (private_cmap)
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
default_colors[i].pixel = i;
|
||||
|
||||
XQueryColors (private->xdisplay,
|
||||
DefaultColormap (private->xdisplay, gdk_screen),
|
||||
default_colors, visual->colormap_size);
|
||||
|
||||
for (i = 0; i < visual->colormap_size; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = default_colors[i].pixel;
|
||||
colormap->colors[i].red = default_colors[i].red;
|
||||
colormap->colors[i].green = default_colors[i].green;
|
||||
colormap->colors[i].blue = default_colors[i].blue;
|
||||
}
|
||||
|
||||
gdk_colormap_change (colormap, visual->colormap_size);
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_DIRECT_COLOR:
|
||||
private->private_val = TRUE;
|
||||
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
|
||||
xvisual, AllocAll);
|
||||
|
||||
size = 1 << visual->red_prec;
|
||||
for (i = 0; i < size; i++)
|
||||
colormap->colors[i].red = i * 65535 / (size - 1);
|
||||
|
||||
size = 1 << visual->green_prec;
|
||||
for (i = 0; i < size; i++)
|
||||
colormap->colors[i].green = i * 65535 / (size - 1);
|
||||
|
||||
size = 1 << visual->blue_prec;
|
||||
for (i = 0; i < size; i++)
|
||||
colormap->colors[i].blue = i * 65535 / (size - 1);
|
||||
|
||||
gdk_colormap_change (colormap, visual->colormap_size);
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_STATIC_GRAY:
|
||||
case GDK_VISUAL_STATIC_COLOR:
|
||||
case GDK_VISUAL_TRUE_COLOR:
|
||||
private->private_val = FALSE;
|
||||
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
|
||||
xvisual, AllocNone);
|
||||
break;
|
||||
}
|
||||
|
||||
gdk_colormap_add (colormap);
|
||||
|
||||
return colormap;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_real_destroy (GdkColormap *colormap)
|
||||
{
|
||||
GdkColormapPrivate *private = (GdkColormapPrivate*) colormap;
|
||||
|
||||
g_return_if_fail (colormap != NULL);
|
||||
|
||||
if (private->ref_count > 0)
|
||||
return;
|
||||
|
||||
gdk_colormap_remove (colormap);
|
||||
XFreeColormap (private->xdisplay, private->xcolormap);
|
||||
g_free (colormap);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_destroy (GdkColormap *colormap)
|
||||
{
|
||||
gdk_colormap_unref (colormap);
|
||||
}
|
||||
|
||||
GdkColormap*
|
||||
gdk_colormap_ref (GdkColormap *cmap)
|
||||
{
|
||||
GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
|
||||
g_return_val_if_fail (cmap != NULL, NULL);
|
||||
|
||||
private->ref_count += 1;
|
||||
return cmap;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_unref (GdkColormap *cmap)
|
||||
{
|
||||
GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
|
||||
g_return_if_fail (cmap != NULL);
|
||||
|
||||
private->ref_count -= 1;
|
||||
if (private->ref_count == 0)
|
||||
gdk_colormap_real_destroy (cmap);
|
||||
}
|
||||
|
||||
GdkColormap*
|
||||
gdk_colormap_get_system (void)
|
||||
{
|
||||
static GdkColormap *colormap = NULL;
|
||||
GdkColormapPrivate *private;
|
||||
XColor xpalette[256];
|
||||
gint i;
|
||||
|
||||
if (!colormap)
|
||||
{
|
||||
private = g_new (GdkColormapPrivate, 1);
|
||||
colormap = (GdkColormap*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->xcolormap = DefaultColormap (gdk_display, gdk_screen);
|
||||
private->visual = gdk_visual_get_system ();
|
||||
private->private_val = FALSE;
|
||||
private->next_color = 0;
|
||||
private->ref_count = 1;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
xpalette[i].pixel = i;
|
||||
xpalette[i].red = 0;
|
||||
xpalette[i].green = 0;
|
||||
xpalette[i].blue = 0;
|
||||
}
|
||||
|
||||
XQueryColors (gdk_display, private->xcolormap, xpalette, 256);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = xpalette[i].pixel;
|
||||
colormap->colors[i].red = xpalette[i].red;
|
||||
colormap->colors[i].green = xpalette[i].green;
|
||||
colormap->colors[i].blue = xpalette[i].blue;
|
||||
}
|
||||
|
||||
gdk_colormap_add (colormap);
|
||||
}
|
||||
|
||||
return colormap;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_colormap_get_system_size (void)
|
||||
{
|
||||
return DisplayCells (gdk_display, gdk_screen);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_change (GdkColormap *colormap,
|
||||
gint ncolors)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
GdkVisual *visual;
|
||||
XColor palette[256];
|
||||
gint shift;
|
||||
int max_colors;
|
||||
int size;
|
||||
int i;
|
||||
|
||||
g_return_if_fail (colormap != NULL);
|
||||
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
switch (private->visual->type)
|
||||
{
|
||||
case GDK_VISUAL_GRAYSCALE:
|
||||
case GDK_VISUAL_PSEUDO_COLOR:
|
||||
for (i = 0; i < ncolors; i++)
|
||||
{
|
||||
palette[i].pixel = colormap->colors[i].pixel;
|
||||
palette[i].red = colormap->colors[i].red;
|
||||
palette[i].green = colormap->colors[i].green;
|
||||
palette[i].blue = colormap->colors[i].blue;
|
||||
palette[i].flags = DoRed | DoGreen | DoBlue;
|
||||
}
|
||||
|
||||
XStoreColors (private->xdisplay, private->xcolormap, palette, ncolors);
|
||||
private->next_color = MAX (private->next_color, ncolors);
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_DIRECT_COLOR:
|
||||
visual = private->visual;
|
||||
|
||||
shift = visual->red_shift;
|
||||
max_colors = 1 << visual->red_prec;
|
||||
size = (ncolors < max_colors) ? (ncolors) : (max_colors);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
palette[i].pixel = i << shift;
|
||||
palette[i].red = colormap->colors[i].red;
|
||||
palette[i].flags = DoRed;
|
||||
}
|
||||
|
||||
XStoreColors (private->xdisplay, private->xcolormap, palette, size);
|
||||
|
||||
shift = visual->green_shift;
|
||||
max_colors = 1 << visual->green_prec;
|
||||
size = (ncolors < max_colors) ? (ncolors) : (max_colors);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
palette[i].pixel = i << shift;
|
||||
palette[i].green = colormap->colors[i].green;
|
||||
palette[i].flags = DoGreen;
|
||||
}
|
||||
|
||||
XStoreColors (private->xdisplay, private->xcolormap, palette, size);
|
||||
|
||||
shift = visual->blue_shift;
|
||||
max_colors = 1 << visual->blue_prec;
|
||||
size = (ncolors < max_colors) ? (ncolors) : (max_colors);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
palette[i].pixel = i << shift;
|
||||
palette[i].blue = colormap->colors[i].blue;
|
||||
palette[i].flags = DoBlue;
|
||||
}
|
||||
|
||||
XStoreColors (private->xdisplay, private->xcolormap, palette, size);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colors_store (GdkColormap *colormap,
|
||||
GdkColor *colors,
|
||||
gint ncolors)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < ncolors; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = colors[i].pixel;
|
||||
colormap->colors[i].red = colors[i].red;
|
||||
colormap->colors[i].green = colors[i].green;
|
||||
colormap->colors[i].blue = colors[i].blue;
|
||||
}
|
||||
|
||||
gdk_colormap_change (colormap, ncolors);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_colors_alloc (GdkColormap *colormap,
|
||||
gint contiguous,
|
||||
gulong *planes,
|
||||
gint nplanes,
|
||||
gulong *pixels,
|
||||
gint npixels)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, 0);
|
||||
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
|
||||
return_val = XAllocColorCells (private->xdisplay, private->xcolormap,
|
||||
contiguous, planes, nplanes, pixels, npixels);
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colors_free (GdkColormap *colormap,
|
||||
gulong *pixels,
|
||||
gint npixels,
|
||||
gulong planes)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
|
||||
g_return_if_fail (colormap != NULL);
|
||||
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
|
||||
XFreeColors (private->xdisplay, private->xcolormap,
|
||||
pixels, npixels, planes);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_white (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
|
||||
if (color)
|
||||
{
|
||||
color->pixel = WhitePixel (gdk_display, gdk_screen);
|
||||
color->red = 65535;
|
||||
color->green = 65535;
|
||||
color->blue = 65535;
|
||||
|
||||
return_val = gdk_color_alloc (colormap, color);
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_black (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
|
||||
if (color)
|
||||
{
|
||||
color->pixel = BlackPixel (gdk_display, gdk_screen);
|
||||
color->red = 0;
|
||||
color->green = 0;
|
||||
color->blue = 0;
|
||||
|
||||
return_val = gdk_color_alloc (colormap, color);
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_parse (const gchar *spec,
|
||||
GdkColor *color)
|
||||
{
|
||||
Colormap xcolormap;
|
||||
XColor xcolor;
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (spec != NULL, FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
xcolormap = DefaultColormap (gdk_display, gdk_screen);
|
||||
|
||||
if (XParseColor (gdk_display, xcolormap, spec, &xcolor))
|
||||
{
|
||||
return_val = TRUE;
|
||||
color->red = xcolor.red;
|
||||
color->green = xcolor.green;
|
||||
color->blue = xcolor.blue;
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_alloc (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
GdkVisual *visual;
|
||||
XColor xcolor;
|
||||
gchar available[256];
|
||||
gint available_init;
|
||||
gint return_val;
|
||||
gint i, index;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
xcolor.red = color->red;
|
||||
xcolor.green = color->green;
|
||||
xcolor.blue = color->blue;
|
||||
xcolor.pixel = color->pixel;
|
||||
xcolor.flags = DoRed | DoGreen | DoBlue;
|
||||
|
||||
return_val = FALSE;
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
|
||||
switch (private->visual->type)
|
||||
{
|
||||
case GDK_VISUAL_GRAYSCALE:
|
||||
case GDK_VISUAL_PSEUDO_COLOR:
|
||||
if (private->private_val)
|
||||
{
|
||||
if (private->next_color > 255)
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
available[i] = TRUE;
|
||||
|
||||
index = gdk_colormap_match_color (colormap, color, available);
|
||||
if (index != -1)
|
||||
{
|
||||
available[index] = FALSE;
|
||||
*color = colormap->colors[index];
|
||||
return_val = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return_val = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xcolor.pixel = 255 - private->next_color;
|
||||
color->pixel = xcolor.pixel;
|
||||
private->next_color += 1;
|
||||
|
||||
XStoreColor (private->xdisplay, private->xcolormap, &xcolor);
|
||||
return_val = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
available_init = 1;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor))
|
||||
{
|
||||
color->pixel = xcolor.pixel;
|
||||
color->red = xcolor.red;
|
||||
color->green = xcolor.green;
|
||||
color->blue = xcolor.blue;
|
||||
|
||||
colormap->colors[color->pixel] = *color;
|
||||
|
||||
return_val = TRUE;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (available_init)
|
||||
{
|
||||
available_init = 0;
|
||||
for (i = 0; i < 256; i++)
|
||||
available[i] = TRUE;
|
||||
}
|
||||
|
||||
index = gdk_colormap_match_color (colormap, color, available);
|
||||
if (index != -1)
|
||||
{
|
||||
available[index] = FALSE;
|
||||
xcolor.red = colormap->colors[index].red;
|
||||
xcolor.green = colormap->colors[index].green;
|
||||
xcolor.blue = colormap->colors[index].blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return_val = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_DIRECT_COLOR:
|
||||
visual = private->visual;
|
||||
xcolor.pixel = (((xcolor.red >> (16 - visual->red_prec)) << visual->red_shift) +
|
||||
((xcolor.green >> (16 - visual->green_prec)) << visual->green_shift) +
|
||||
((xcolor.blue >> (16 - visual->blue_prec)) << visual->blue_shift));
|
||||
color->pixel = xcolor.pixel;
|
||||
return_val = TRUE;
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_STATIC_GRAY:
|
||||
case GDK_VISUAL_STATIC_COLOR:
|
||||
case GDK_VISUAL_TRUE_COLOR:
|
||||
if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor))
|
||||
{
|
||||
color->pixel = xcolor.pixel;
|
||||
return_val = TRUE;
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_change (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
XColor xcolor;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
xcolor.pixel = color->pixel;
|
||||
xcolor.red = color->red;
|
||||
xcolor.green = color->green;
|
||||
xcolor.blue = color->blue;
|
||||
xcolor.flags = DoRed | DoGreen | DoBlue;
|
||||
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
XStoreColor (private->xdisplay, private->xcolormap, &xcolor);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_equal (GdkColor *colora,
|
||||
GdkColor *colorb)
|
||||
{
|
||||
g_return_val_if_fail (colora != NULL, FALSE);
|
||||
g_return_val_if_fail (colorb != NULL, FALSE);
|
||||
|
||||
return ((colora->red == colorb->red) &&
|
||||
(colora->green == colorb->green) &&
|
||||
(colora->blue == colorb->blue));
|
||||
}
|
||||
|
||||
GdkColormap*
|
||||
gdkx_colormap_get (Colormap xcolormap)
|
||||
{
|
||||
GdkColormap *colormap;
|
||||
GdkColormapPrivate *private;
|
||||
XColor xpalette[256];
|
||||
gint i;
|
||||
|
||||
colormap = gdk_colormap_lookup (xcolormap);
|
||||
if (colormap)
|
||||
return colormap;
|
||||
|
||||
if (xcolormap == DefaultColormap (gdk_display, gdk_screen))
|
||||
return gdk_colormap_get_system ();
|
||||
|
||||
private = g_new (GdkColormapPrivate, 1);
|
||||
colormap = (GdkColormap*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->xcolormap = xcolormap;
|
||||
private->visual = NULL;
|
||||
private->private_val = TRUE;
|
||||
private->next_color = 0;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
xpalette[i].pixel = i;
|
||||
xpalette[i].red = 0;
|
||||
xpalette[i].green = 0;
|
||||
xpalette[i].blue = 0;
|
||||
}
|
||||
|
||||
XQueryColors (gdk_display, private->xcolormap, xpalette, 256);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = xpalette[i].pixel;
|
||||
colormap->colors[i].red = xpalette[i].red;
|
||||
colormap->colors[i].green = xpalette[i].green;
|
||||
colormap->colors[i].blue = xpalette[i].blue;
|
||||
}
|
||||
|
||||
gdk_colormap_add (colormap);
|
||||
|
||||
return colormap;
|
||||
}
|
||||
|
||||
|
||||
static gint
|
||||
gdk_colormap_match_color (GdkColormap *cmap,
|
||||
GdkColor *color,
|
||||
const gchar *available)
|
||||
{
|
||||
GdkColor *colors;
|
||||
guint sum, max;
|
||||
gint rdiff, gdiff, bdiff;
|
||||
gint i, index;
|
||||
|
||||
g_return_val_if_fail (cmap != NULL, 0);
|
||||
g_return_val_if_fail (color != NULL, 0);
|
||||
|
||||
colors = cmap->colors;
|
||||
max = 3 * (65536);
|
||||
index = -1;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
if ((!available) || (available && available[i]))
|
||||
{
|
||||
rdiff = (color->red - colors[i].red);
|
||||
gdiff = (color->green - colors[i].green);
|
||||
bdiff = (color->blue - colors[i].blue);
|
||||
|
||||
sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
|
||||
|
||||
if (sum < max)
|
||||
{
|
||||
index = i;
|
||||
max = sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
GdkColormap*
|
||||
gdk_colormap_lookup (Colormap xcolormap)
|
||||
{
|
||||
GdkColormap *cmap;
|
||||
|
||||
if (!colormap_hash)
|
||||
return NULL;
|
||||
|
||||
cmap = g_hash_table_lookup (colormap_hash, &xcolormap);
|
||||
return cmap;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_colormap_add (GdkColormap *cmap)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
|
||||
if (!colormap_hash)
|
||||
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
|
||||
(GCompareFunc) gdk_colormap_cmp);
|
||||
|
||||
private = (GdkColormapPrivate*) cmap;
|
||||
|
||||
g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_colormap_remove (GdkColormap *cmap)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
|
||||
if (!colormap_hash)
|
||||
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
|
||||
(GCompareFunc) gdk_colormap_cmp);
|
||||
|
||||
private = (GdkColormapPrivate*) cmap;
|
||||
|
||||
g_hash_table_remove (colormap_hash, &private->xcolormap);
|
||||
}
|
||||
|
||||
static guint
|
||||
gdk_colormap_hash (Colormap *cmap)
|
||||
{
|
||||
return *cmap;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_colormap_cmp (Colormap *a,
|
||||
Colormap *b)
|
||||
{
|
||||
return (*a == *b);
|
||||
}
|
52
gdk/gdkcursor.c
Normal file
52
gdk/gdkcursor.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
GdkCursor*
|
||||
gdk_cursor_new (GdkCursorType cursor_type)
|
||||
{
|
||||
GdkCursorPrivate *private;
|
||||
GdkCursor *cursor;
|
||||
Cursor xcursor;
|
||||
|
||||
xcursor = XCreateFontCursor (gdk_display, cursor_type);
|
||||
private = g_new (GdkCursorPrivate, 1);
|
||||
private->xdisplay = gdk_display;
|
||||
private->xcursor = xcursor;
|
||||
cursor = (GdkCursor*) private;
|
||||
cursor->type = cursor_type;
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_cursor_destroy (GdkCursor *cursor)
|
||||
{
|
||||
GdkCursorPrivate *private;
|
||||
|
||||
g_return_if_fail (cursor != NULL);
|
||||
|
||||
private = (GdkCursorPrivate *) cursor;
|
||||
XFreeCursor (private->xdisplay, private->xcursor);
|
||||
|
||||
g_free (private);
|
||||
}
|
383
gdk/gdkdraw.c
Normal file
383
gdk/gdkdraw.c
Normal file
@ -0,0 +1,383 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xos.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
void
|
||||
gdk_draw_point (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
XDrawPoint (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_draw_line (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
XDrawLine (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_draw_rectangle (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint filled,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
if (width == -1)
|
||||
width = drawable_private->width;
|
||||
if (height == -1)
|
||||
height = drawable_private->height;
|
||||
|
||||
if (filled)
|
||||
XFillRectangle (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, x, y, width, height);
|
||||
else
|
||||
XDrawRectangle (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, x, y, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_draw_arc (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint filled,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
gint angle1,
|
||||
gint angle2)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
if (width == -1)
|
||||
width = drawable_private->width;
|
||||
if (height == -1)
|
||||
height = drawable_private->height;
|
||||
|
||||
if (filled)
|
||||
XFillArc (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, x, y, width, height, angle1, angle2);
|
||||
else
|
||||
XDrawArc (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, x, y, width, height, angle1, angle2);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_draw_polygon (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint filled,
|
||||
GdkPoint *points,
|
||||
gint npoints)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
if (filled)
|
||||
{
|
||||
XFillPolygon (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, (XPoint*) points, npoints, Complex, CoordModeOrigin);
|
||||
}
|
||||
else
|
||||
{
|
||||
XDrawLines (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, (XPoint*) points, npoints, CoordModeOrigin);
|
||||
|
||||
if ((points[0].x != points[npoints-1].x) ||
|
||||
(points[0].y != points[npoints-1].y))
|
||||
XDrawLine (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, points[npoints-1].x, points[npoints-1].y,
|
||||
points[0].x, points[0].y);
|
||||
}
|
||||
}
|
||||
|
||||
/* gdk_draw_string
|
||||
*
|
||||
* Modified by Li-Da Lho to draw 16 bits and Multibyte strings
|
||||
*
|
||||
* Interface changed: add "GdkFont *font" to specify font or fontset explicitely
|
||||
*/
|
||||
void
|
||||
gdk_draw_string (GdkDrawable *drawable,
|
||||
GdkFont *font,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
const gchar *string)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkFontPrivate *font_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (font != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
g_return_if_fail (string != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
font_private = (GdkFontPrivate*) font;
|
||||
|
||||
if (font->type == GDK_FONT_FONT)
|
||||
{
|
||||
XFontStruct *xfont = (XFontStruct *) font_private->xfont;
|
||||
XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid);
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
XDrawString (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, x, y, string, strlen (string));
|
||||
}
|
||||
else
|
||||
{
|
||||
XDrawString16 (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, x, y, (XChar2b *) string,
|
||||
strlen (string) / 2);
|
||||
}
|
||||
}
|
||||
else if (font->type == GDK_FONT_FONTSET)
|
||||
{
|
||||
XFontSet fontset = (XFontSet) font_private->xfont;
|
||||
XmbDrawString (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
fontset, gc_private->xgc, x, y, string, strlen (string));
|
||||
}
|
||||
else
|
||||
g_error("undefined font type\n");
|
||||
}
|
||||
|
||||
/* gdk_draw_text
|
||||
*
|
||||
* Modified by Li-Da Lho to draw 16 bits and Multibyte strings
|
||||
*
|
||||
* Interface changed: add "GdkFont *font" to specify font or fontset explicitely
|
||||
*/
|
||||
void
|
||||
gdk_draw_text (GdkDrawable *drawable,
|
||||
GdkFont *font,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkFontPrivate *font_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (font != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
g_return_if_fail (text != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
font_private = (GdkFontPrivate*) font;
|
||||
|
||||
if (font->type == GDK_FONT_FONT)
|
||||
{
|
||||
XFontStruct *xfont = (XFontStruct *) font_private->xfont;
|
||||
XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid);
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
XDrawString (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, x, y, text, text_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
XDrawString16 (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, x, y, (XChar2b *) text, text_length / 2);
|
||||
}
|
||||
}
|
||||
else if (font->type == GDK_FONT_FONTSET)
|
||||
{
|
||||
XFontSet fontset = (XFontSet) font_private->xfont;
|
||||
XmbDrawString (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
fontset, gc_private->xgc, x, y, text, text_length);
|
||||
}
|
||||
else
|
||||
g_error("undefined font type\n");
|
||||
}
|
||||
|
||||
void
|
||||
gdk_draw_pixmap (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkPixmap *src,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkWindowPrivate *src_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
src_private = (GdkWindowPrivate*) src;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
if (width == -1)
|
||||
width = src_private->width;
|
||||
if (height == -1)
|
||||
height = src_private->height;
|
||||
|
||||
XCopyArea (drawable_private->xdisplay,
|
||||
src_private->xwindow,
|
||||
drawable_private->xwindow,
|
||||
gc_private->xgc,
|
||||
xsrc, ysrc,
|
||||
width, height,
|
||||
xdest, ydest);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_draw_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkImagePrivate *image_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (image != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
image_private = (GdkImagePrivate*) image;
|
||||
|
||||
g_return_if_fail (image_private->image_put != NULL);
|
||||
|
||||
if (width == -1)
|
||||
width = image->width;
|
||||
if (height == -1)
|
||||
height = image->height;
|
||||
|
||||
(* image_private->image_put) (drawable, gc, image, xsrc, ysrc,
|
||||
xdest, ydest, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_draw_points (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkPoint *points,
|
||||
gint npoints)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail ((points != NULL) && (npoints > 0));
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
XDrawPoints (drawable_private->xdisplay,
|
||||
drawable_private->xwindow,
|
||||
gc_private->xgc,
|
||||
(XPoint *) points,
|
||||
npoints,
|
||||
CoordModeOrigin);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_draw_segments (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkSegment *segs,
|
||||
gint nsegs)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
if (nsegs <= 0)
|
||||
return;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (segs != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
XDrawSegments (drawable_private->xdisplay,
|
||||
drawable_private->xwindow,
|
||||
gc_private->xgc,
|
||||
(XSegment *) segs,
|
||||
nsegs);
|
||||
}
|
379
gdk/gdkfont.c
Normal file
379
gdk/gdkfont.c
Normal file
@ -0,0 +1,379 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xos.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
GdkFont*
|
||||
gdk_font_load (const gchar *font_name)
|
||||
{
|
||||
GdkFont *font;
|
||||
GdkFontPrivate *private;
|
||||
|
||||
private = g_new (GdkFontPrivate, 1);
|
||||
font = (GdkFont*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->xfont = XLoadQueryFont (private->xdisplay, font_name);
|
||||
private->ref_count = 1;
|
||||
|
||||
if (!private->xfont)
|
||||
{
|
||||
g_free (font);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
font->type = GDK_FONT_FONT;
|
||||
font->ascent = ((XFontStruct *) private->xfont)->ascent;
|
||||
font->descent = ((XFontStruct *) private->xfont)->descent;
|
||||
}
|
||||
|
||||
gdk_xid_table_insert (&((XFontStruct *) private->xfont)->fid, font);
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
GdkFont*
|
||||
gdk_fontset_load(gchar *fontset_name)
|
||||
{
|
||||
GdkFont *font;
|
||||
GdkFontPrivate *private;
|
||||
XFontSet fontset;
|
||||
gint missing_charset_count;
|
||||
gchar **missing_charset_list;
|
||||
gchar *def_string;
|
||||
|
||||
private = g_new (GdkFontPrivate, 1);
|
||||
font = (GdkFont*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
fontset = XCreateFontSet (gdk_display, fontset_name,
|
||||
&missing_charset_list, &missing_charset_count,
|
||||
&def_string);
|
||||
|
||||
if (missing_charset_count)
|
||||
{
|
||||
g_print ("Missing charsets in FontSet creation");
|
||||
XFreeStringList (missing_charset_list);
|
||||
}
|
||||
|
||||
private->ref_count = 1;
|
||||
|
||||
if (!fontset)
|
||||
{
|
||||
g_free (font);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
XFontSetExtents *extent = XExtentsOfFontSet(fontset);
|
||||
|
||||
private->xfont = fontset;
|
||||
font->type = GDK_FONT_FONTSET;
|
||||
/* how to define ascent and descent for fontset ??? */
|
||||
font->ascent = extent->max_logical_extent.height;
|
||||
font->descent = font->ascent / 4 ;
|
||||
}
|
||||
return font;
|
||||
}
|
||||
void
|
||||
gdk_font_free (GdkFont *font)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
|
||||
g_return_if_fail (font != NULL);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
private->ref_count -= 1;
|
||||
if (private->ref_count == 0)
|
||||
{
|
||||
gdk_xid_table_remove (((XFontStruct *) private->xfont)->fid);
|
||||
XFreeFont (private->xdisplay, (XFontStruct *) private->xfont);
|
||||
g_free (font);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_fontset_free (GdkFont *font)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
|
||||
g_return_if_fail (font != NULL);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
private->ref_count -= 1;
|
||||
if (private->ref_count == 0)
|
||||
{
|
||||
XFreeFontSet (private->xdisplay, (XFontSet) private->xfont);
|
||||
g_free (font);
|
||||
}
|
||||
}
|
||||
|
||||
GdkFont*
|
||||
gdk_font_ref (GdkFont *font)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
|
||||
g_return_val_if_fail (font != NULL, NULL);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
private->ref_count += 1;
|
||||
return font;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_font_id (GdkFont *font)
|
||||
{
|
||||
GdkFontPrivate *font_private;
|
||||
|
||||
g_return_val_if_fail (font != NULL, 0);
|
||||
|
||||
font_private = (GdkFontPrivate*) font;
|
||||
|
||||
if (font->type == GDK_FONT_FONT)
|
||||
{
|
||||
return ((XFontStruct *) font_private->xfont)->fid;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_font_equal (GdkFont *fonta,
|
||||
GdkFont *fontb)
|
||||
{
|
||||
GdkFontPrivate *privatea;
|
||||
GdkFontPrivate *privateb;
|
||||
|
||||
g_return_val_if_fail (fonta != NULL, FALSE);
|
||||
g_return_val_if_fail (fontb != NULL, FALSE);
|
||||
|
||||
privatea = (GdkFontPrivate*) fonta;
|
||||
privateb = (GdkFontPrivate*) fontb;
|
||||
|
||||
if (fonta->type == GDK_FONT_FONT && fontb->type == GDK_FONT_FONT)
|
||||
{
|
||||
return (((XFontStruct *) privatea->xfont)->fid ==
|
||||
((XFontStruct *) privateb->xfont)->fid);
|
||||
}
|
||||
else if (fonta->type == GDK_FONT_FONTSET && fontb->type == GDK_FONT_FONTSET)
|
||||
{
|
||||
/* how to compare two fontsets ?? by basename or XFontSet ?? */
|
||||
return (((XFontSet) privatea->xfont) == ((XFontSet) privateb->xfont));
|
||||
}
|
||||
else
|
||||
/* fontset != font */
|
||||
return 0;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_string_width (GdkFont *font,
|
||||
const gchar *string)
|
||||
{
|
||||
GdkFontPrivate *font_private;
|
||||
gint width;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (string != NULL, -1);
|
||||
|
||||
font_private = (GdkFontPrivate*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
xfont = (XFontStruct *) font_private->xfont;
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
width = XTextWidth (xfont, string, strlen (string));
|
||||
}
|
||||
else
|
||||
{
|
||||
width = XTextWidth16 (xfont, (XChar2b *) string, strlen (string) / 2);
|
||||
}
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) font_private->xfont;
|
||||
width = XmbTextEscapement (fontset, string, strlen(string));
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_width (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
gint width;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (text != NULL, -1);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
width = XTextWidth (xfont, text, text_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
width = XTextWidth16 (xfont, (XChar2b *) text, text_length / 2);
|
||||
}
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) private->xfont;
|
||||
width = XmbTextEscapement (fontset, text, text_length);
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
/* Problem: What if a character is a 16 bits character ?? */
|
||||
gint
|
||||
gdk_char_width (GdkFont *font,
|
||||
gchar character)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
XCharStruct *chars;
|
||||
gint width;
|
||||
guint ch = character & 0xff; /* get rid of sign-extension */
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
/* only 8 bits characters are considered here */
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
if ((xfont->min_byte1 == 0) &&
|
||||
(xfont->max_byte1 == 0) &&
|
||||
(ch >= xfont->min_char_or_byte2) &&
|
||||
(ch <= xfont->max_char_or_byte2))
|
||||
{
|
||||
chars = xfont->per_char;
|
||||
if (chars)
|
||||
width = chars[ch - xfont->min_char_or_byte2].width;
|
||||
else
|
||||
width = xfont->min_bounds.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = XTextWidth (xfont, &character, 1);
|
||||
}
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) private->xfont;
|
||||
width = XmbTextEscapement (fontset, &character, 1) ;
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_string_measure (GdkFont *font,
|
||||
const gchar *string)
|
||||
{
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (string != NULL, -1);
|
||||
|
||||
return gdk_text_measure (font, string, strlen (string));
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_measure (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
XCharStruct overall;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
XRectangle ink, log;
|
||||
int direction;
|
||||
int font_ascent;
|
||||
int font_descent;
|
||||
gint width;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (text != NULL, -1);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
XTextExtents (xfont, text, text_length,
|
||||
&direction, &font_ascent, &font_descent,
|
||||
&overall);
|
||||
}
|
||||
else
|
||||
{
|
||||
XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
|
||||
&direction, &font_ascent, &font_descent,
|
||||
&overall);
|
||||
}
|
||||
width = overall.rbearing;
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) private->xfont;
|
||||
XmbTextExtents (fontset, text, text_length, &ink, &log);
|
||||
width = log.width;
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_char_measure (GdkFont *font,
|
||||
gchar character)
|
||||
{
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
|
||||
return gdk_text_measure (font, &character, 1);
|
||||
}
|
636
gdk/gdkgc.c
Normal file
636
gdk/gdkgc.c
Normal file
@ -0,0 +1,636 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
GdkGC*
|
||||
gdk_gc_new (GdkWindow *window)
|
||||
{
|
||||
return gdk_gc_new_with_values (window, NULL, 0);
|
||||
}
|
||||
|
||||
GdkGC*
|
||||
gdk_gc_new_with_values (GdkWindow *window,
|
||||
GdkGCValues *values,
|
||||
GdkGCValuesMask values_mask)
|
||||
{
|
||||
GdkGC *gc;
|
||||
GdkGCPrivate *private;
|
||||
Window xwindow;
|
||||
XGCValues xvalues;
|
||||
unsigned long xvalues_mask;
|
||||
|
||||
private = g_new (GdkGCPrivate, 1);
|
||||
gc = (GdkGC*) private;
|
||||
|
||||
xwindow = ((GdkWindowPrivate*) window)->xwindow;
|
||||
private->xdisplay = ((GdkWindowPrivate*) window)->xdisplay;
|
||||
|
||||
xvalues.function = GXcopy;
|
||||
xvalues.fill_style = FillSolid;
|
||||
xvalues.arc_mode = ArcPieSlice;
|
||||
xvalues.subwindow_mode = ClipByChildren;
|
||||
xvalues.graphics_exposures = True;
|
||||
xvalues_mask = GCFunction | GCFillStyle | GCArcMode | GCSubwindowMode | GCGraphicsExposures;
|
||||
|
||||
if (values_mask & GDK_GC_FOREGROUND)
|
||||
{
|
||||
xvalues.foreground = values->foreground.pixel;
|
||||
xvalues_mask |= GCForeground;
|
||||
}
|
||||
if (values_mask & GDK_GC_BACKGROUND)
|
||||
{
|
||||
xvalues.background = values->background.pixel;
|
||||
xvalues_mask |= GCBackground;
|
||||
}
|
||||
if ((values_mask & GDK_GC_FONT) && (values->font->type == GDK_FONT_FONT))
|
||||
{
|
||||
xvalues.font = ((XFontStruct *) ((GdkFontPrivate*) values->font)->xfont)->fid;
|
||||
xvalues_mask |= GCFont;
|
||||
}
|
||||
if (values_mask & GDK_GC_FUNCTION)
|
||||
{
|
||||
switch (values->function)
|
||||
{
|
||||
case GDK_COPY:
|
||||
xvalues.function = GXcopy;
|
||||
break;
|
||||
case GDK_INVERT:
|
||||
xvalues.function = GXinvert;
|
||||
break;
|
||||
case GDK_XOR:
|
||||
xvalues.function = GXxor;
|
||||
break;
|
||||
}
|
||||
xvalues_mask |= GCFunction;
|
||||
}
|
||||
if (values_mask & GDK_GC_FILL)
|
||||
{
|
||||
switch (values->fill)
|
||||
{
|
||||
case GDK_SOLID:
|
||||
xvalues.fill_style = FillSolid;
|
||||
break;
|
||||
case GDK_TILED:
|
||||
xvalues.fill_style = FillTiled;
|
||||
break;
|
||||
case GDK_STIPPLED:
|
||||
xvalues.fill_style = FillStippled;
|
||||
break;
|
||||
case GDK_OPAQUE_STIPPLED:
|
||||
xvalues.fill_style = FillOpaqueStippled;
|
||||
break;
|
||||
}
|
||||
xvalues_mask |= GCFillStyle;
|
||||
}
|
||||
if (values_mask & GDK_GC_TILE)
|
||||
{
|
||||
xvalues.tile = ((GdkPixmapPrivate*) values->tile)->xwindow;
|
||||
xvalues_mask |= GCTile;
|
||||
}
|
||||
if (values_mask & GDK_GC_STIPPLE)
|
||||
{
|
||||
xvalues.stipple = ((GdkPixmapPrivate*) values->stipple)->xwindow;
|
||||
xvalues_mask |= GCStipple;
|
||||
}
|
||||
if (values_mask & GDK_GC_CLIP_MASK)
|
||||
{
|
||||
xvalues.clip_mask = ((GdkPixmapPrivate*) values->clip_mask)->xwindow;
|
||||
xvalues_mask |= GCClipMask;
|
||||
}
|
||||
if (values_mask & GDK_GC_SUBWINDOW)
|
||||
{
|
||||
xvalues.subwindow_mode = values->subwindow_mode;
|
||||
xvalues_mask |= GCSubwindowMode;
|
||||
}
|
||||
if (values_mask & GDK_GC_TS_X_ORIGIN)
|
||||
{
|
||||
xvalues.ts_x_origin = values->ts_x_origin;
|
||||
xvalues_mask |= GCTileStipXOrigin;
|
||||
}
|
||||
if (values_mask & GDK_GC_TS_Y_ORIGIN)
|
||||
{
|
||||
xvalues.ts_y_origin = values->ts_y_origin;
|
||||
xvalues_mask |= GCTileStipYOrigin;
|
||||
}
|
||||
if (values_mask & GDK_GC_CLIP_X_ORIGIN)
|
||||
{
|
||||
xvalues.clip_x_origin = values->clip_x_origin;
|
||||
xvalues_mask |= GCClipXOrigin;
|
||||
}
|
||||
if (values_mask & GDK_GC_CLIP_Y_ORIGIN)
|
||||
{
|
||||
xvalues.clip_y_origin = values->clip_y_origin;
|
||||
xvalues_mask |= GCClipYOrigin;
|
||||
}
|
||||
if (values_mask & GDK_GC_EXPOSURES)
|
||||
{
|
||||
xvalues.graphics_exposures = values->graphics_exposures;
|
||||
xvalues_mask |= GCGraphicsExposures;
|
||||
}
|
||||
if (values_mask & GDK_GC_LINE_WIDTH)
|
||||
{
|
||||
xvalues.line_width = values->line_width;
|
||||
xvalues_mask |= GCLineWidth;
|
||||
}
|
||||
if (values_mask & GDK_GC_LINE_STYLE)
|
||||
{
|
||||
switch (values->line_style)
|
||||
{
|
||||
case GDK_LINE_SOLID:
|
||||
xvalues.line_style = LineSolid;
|
||||
break;
|
||||
case GDK_LINE_ON_OFF_DASH:
|
||||
xvalues.line_style = LineOnOffDash;
|
||||
break;
|
||||
case GDK_LINE_DOUBLE_DASH:
|
||||
xvalues.line_style = LineDoubleDash;
|
||||
break;
|
||||
}
|
||||
xvalues_mask |= GCLineStyle;
|
||||
}
|
||||
if (values_mask & GDK_GC_CAP_STYLE)
|
||||
{
|
||||
switch (values->cap_style)
|
||||
{
|
||||
case GDK_CAP_NOT_LAST:
|
||||
xvalues.cap_style = CapNotLast;
|
||||
break;
|
||||
case GDK_CAP_BUTT:
|
||||
xvalues.cap_style = CapButt;
|
||||
break;
|
||||
case GDK_CAP_ROUND:
|
||||
xvalues.cap_style = CapRound;
|
||||
break;
|
||||
case GDK_CAP_PROJECTING:
|
||||
xvalues.cap_style = CapProjecting;
|
||||
break;
|
||||
}
|
||||
xvalues_mask |= GCCapStyle;
|
||||
}
|
||||
if (values_mask & GDK_GC_JOIN_STYLE)
|
||||
{
|
||||
switch (values->join_style)
|
||||
{
|
||||
case GDK_JOIN_MITER:
|
||||
xvalues.join_style = JoinMiter;
|
||||
break;
|
||||
case GDK_JOIN_ROUND:
|
||||
xvalues.join_style = JoinRound;
|
||||
break;
|
||||
case GDK_JOIN_BEVEL:
|
||||
xvalues.join_style = JoinBevel;
|
||||
break;
|
||||
}
|
||||
xvalues_mask |= GCJoinStyle;
|
||||
}
|
||||
|
||||
private->xgc = XCreateGC (private->xdisplay, xwindow, xvalues_mask, &xvalues);
|
||||
|
||||
return gc;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_destroy (GdkGC *gc)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
XFreeGC (private->xdisplay, private->xgc);
|
||||
|
||||
memset (gc, 0, sizeof (GdkGCPrivate));
|
||||
g_free (gc);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_get_values (GdkGC *gc,
|
||||
GdkGCValues *values)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
XGCValues xvalues;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
g_return_if_fail (values != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
|
||||
if (XGetGCValues (private->xdisplay, private->xgc,
|
||||
GCForeground | GCBackground | GCFont |
|
||||
GCFunction | GCTile | GCStipple | /* GCClipMask | */
|
||||
GCSubwindowMode | GCGraphicsExposures |
|
||||
GCTileStipXOrigin | GCTileStipYOrigin |
|
||||
GCClipXOrigin | GCClipYOrigin |
|
||||
GCLineWidth | GCLineStyle | GCCapStyle |
|
||||
GCFillStyle | GCJoinStyle, &xvalues))
|
||||
{
|
||||
values->foreground.pixel = xvalues.foreground;
|
||||
values->background.pixel = xvalues.background;
|
||||
values->font = gdk_font_lookup (xvalues.font);
|
||||
|
||||
switch (xvalues.function)
|
||||
{
|
||||
case GXcopy:
|
||||
values->function = GDK_COPY;
|
||||
break;
|
||||
case GXinvert:
|
||||
values->function = GDK_INVERT;
|
||||
break;
|
||||
case GXxor:
|
||||
values->function = GDK_XOR;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (xvalues.fill_style)
|
||||
{
|
||||
case FillSolid:
|
||||
values->fill = GDK_SOLID;
|
||||
break;
|
||||
case FillTiled:
|
||||
values->fill = GDK_TILED;
|
||||
break;
|
||||
case FillStippled:
|
||||
values->fill = GDK_STIPPLED;
|
||||
break;
|
||||
case FillOpaqueStippled:
|
||||
values->fill = GDK_OPAQUE_STIPPLED;
|
||||
break;
|
||||
}
|
||||
|
||||
values->tile = gdk_pixmap_lookup (xvalues.tile);
|
||||
values->stipple = gdk_pixmap_lookup (xvalues.stipple);
|
||||
values->clip_mask = NULL;
|
||||
values->subwindow_mode = xvalues.subwindow_mode;
|
||||
values->ts_x_origin = xvalues.ts_x_origin;
|
||||
values->ts_y_origin = xvalues.ts_y_origin;
|
||||
values->clip_x_origin = xvalues.clip_x_origin;
|
||||
values->clip_y_origin = xvalues.clip_y_origin;
|
||||
values->graphics_exposures = xvalues.graphics_exposures;
|
||||
values->line_width = xvalues.line_width;
|
||||
|
||||
switch (xvalues.line_style)
|
||||
{
|
||||
case LineSolid:
|
||||
values->line_style = GDK_LINE_SOLID;
|
||||
break;
|
||||
case LineOnOffDash:
|
||||
values->line_style = GDK_LINE_ON_OFF_DASH;
|
||||
break;
|
||||
case LineDoubleDash:
|
||||
values->line_style = GDK_LINE_DOUBLE_DASH;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (xvalues.cap_style)
|
||||
{
|
||||
case CapNotLast:
|
||||
values->cap_style = GDK_CAP_NOT_LAST;
|
||||
break;
|
||||
case CapButt:
|
||||
values->cap_style = GDK_CAP_BUTT;
|
||||
break;
|
||||
case CapRound:
|
||||
values->cap_style = GDK_CAP_ROUND;
|
||||
break;
|
||||
case CapProjecting:
|
||||
values->cap_style = GDK_CAP_PROJECTING;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (xvalues.join_style)
|
||||
{
|
||||
case JoinMiter:
|
||||
values->join_style = GDK_JOIN_MITER;
|
||||
break;
|
||||
case JoinRound:
|
||||
values->join_style = GDK_JOIN_ROUND;
|
||||
break;
|
||||
case JoinBevel:
|
||||
values->join_style = GDK_JOIN_BEVEL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memset (values, 0, sizeof (GdkGCValues));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_foreground (GdkGC *gc,
|
||||
GdkColor *color)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
XSetForeground (private->xdisplay, private->xgc, color->pixel);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_background (GdkGC *gc,
|
||||
GdkColor *color)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
XSetBackground (private->xdisplay, private->xgc, color->pixel);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_font (GdkGC *gc,
|
||||
GdkFont *font)
|
||||
{
|
||||
GdkGCPrivate *gc_private;
|
||||
GdkFontPrivate *font_private;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
g_return_if_fail (font != NULL);
|
||||
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
font_private = (GdkFontPrivate*) font;
|
||||
|
||||
XSetFont (gc_private->xdisplay, gc_private->xgc,
|
||||
((XFontStruct *) font_private->xfont)->fid);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_function (GdkGC *gc,
|
||||
GdkFunction function)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
|
||||
switch (function)
|
||||
{
|
||||
case GDK_COPY:
|
||||
XSetFunction (private->xdisplay, private->xgc, GXcopy);
|
||||
break;
|
||||
case GDK_INVERT:
|
||||
XSetFunction (private->xdisplay, private->xgc, GXinvert);
|
||||
break;
|
||||
case GDK_XOR:
|
||||
XSetFunction (private->xdisplay, private->xgc, GXor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_fill (GdkGC *gc,
|
||||
GdkFill fill)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
|
||||
switch (fill)
|
||||
{
|
||||
case GDK_SOLID:
|
||||
XSetFillStyle (private->xdisplay, private->xgc, FillSolid);
|
||||
break;
|
||||
case GDK_TILED:
|
||||
XSetFillStyle (private->xdisplay, private->xgc, FillTiled);
|
||||
break;
|
||||
case GDK_STIPPLED:
|
||||
XSetFillStyle (private->xdisplay, private->xgc, FillStippled);
|
||||
break;
|
||||
case GDK_OPAQUE_STIPPLED:
|
||||
XSetFillStyle (private->xdisplay, private->xgc, FillOpaqueStippled);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_tile (GdkGC *gc,
|
||||
GdkPixmap *tile)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
GdkPixmapPrivate *pixmap_private;
|
||||
Pixmap pixmap;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
|
||||
pixmap = None;
|
||||
if (tile)
|
||||
{
|
||||
pixmap_private = (GdkPixmapPrivate*) tile;
|
||||
pixmap = pixmap_private->xwindow;
|
||||
}
|
||||
|
||||
XSetTile (private->xdisplay, private->xgc, pixmap);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_stipple (GdkGC *gc,
|
||||
GdkPixmap *stipple)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
GdkPixmapPrivate *pixmap_private;
|
||||
Pixmap pixmap;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
|
||||
pixmap = None;
|
||||
if (stipple)
|
||||
{
|
||||
pixmap_private = (GdkPixmapPrivate*) stipple;
|
||||
pixmap = pixmap_private->xwindow;
|
||||
}
|
||||
|
||||
XSetStipple (private->xdisplay, private->xgc, pixmap);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_ts_origin (GdkGC *gc,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
|
||||
XSetTSOrigin (private->xdisplay, private->xgc, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_clip_origin (GdkGC *gc,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
|
||||
XSetClipOrigin (private->xdisplay, private->xgc, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_clip_mask (GdkGC *gc,
|
||||
GdkBitmap *mask)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
Pixmap xmask;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
|
||||
if (mask)
|
||||
xmask = ((GdkWindowPrivate*) mask)->xwindow;
|
||||
else
|
||||
xmask = None;
|
||||
|
||||
XSetClipMask (private->xdisplay, private->xgc, xmask);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gdk_gc_set_clip_rectangle (GdkGC *gc,
|
||||
GdkRectangle *rectangle)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
XRectangle xrectangle;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
|
||||
xrectangle.x = rectangle->x;
|
||||
xrectangle.y = rectangle->y;
|
||||
xrectangle.width = rectangle->width;
|
||||
xrectangle.height = rectangle->height;
|
||||
|
||||
XSetClipRectangles (private->xdisplay, private->xgc, 0, 0,
|
||||
&xrectangle, 1, Unsorted);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_subwindow (GdkGC *gc,
|
||||
GdkSubwindowMode mode)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
|
||||
XSetSubwindowMode (private->xdisplay, private->xgc, mode);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_exposures (GdkGC *gc,
|
||||
gint exposures)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
|
||||
XSetGraphicsExposures (private->xdisplay, private->xgc, exposures);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gc_set_line_attributes (GdkGC *gc,
|
||||
gint line_width,
|
||||
GdkLineStyle line_style,
|
||||
GdkCapStyle cap_style,
|
||||
GdkJoinStyle join_style)
|
||||
{
|
||||
GdkGCPrivate *private;
|
||||
int xline_style;
|
||||
int xcap_style;
|
||||
int xjoin_style;
|
||||
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
private = (GdkGCPrivate*) gc;
|
||||
|
||||
switch (line_style)
|
||||
{
|
||||
case GDK_LINE_SOLID:
|
||||
xline_style = LineSolid;
|
||||
break;
|
||||
case GDK_LINE_ON_OFF_DASH:
|
||||
xline_style = LineOnOffDash;
|
||||
break;
|
||||
case GDK_LINE_DOUBLE_DASH:
|
||||
xline_style = LineDoubleDash;
|
||||
break;
|
||||
default:
|
||||
xline_style = None;
|
||||
}
|
||||
|
||||
switch (cap_style)
|
||||
{
|
||||
case GDK_CAP_NOT_LAST:
|
||||
xcap_style = CapNotLast;
|
||||
break;
|
||||
case GDK_CAP_BUTT:
|
||||
xcap_style = CapButt;
|
||||
break;
|
||||
case GDK_CAP_ROUND:
|
||||
xcap_style = CapRound;
|
||||
break;
|
||||
case GDK_CAP_PROJECTING:
|
||||
xcap_style = CapProjecting;
|
||||
break;
|
||||
default:
|
||||
xcap_style = None;
|
||||
}
|
||||
|
||||
switch (join_style)
|
||||
{
|
||||
case GDK_JOIN_MITER:
|
||||
xjoin_style = JoinMiter;
|
||||
break;
|
||||
case GDK_JOIN_ROUND:
|
||||
xjoin_style = JoinRound;
|
||||
break;
|
||||
case GDK_JOIN_BEVEL:
|
||||
xjoin_style = JoinBevel;
|
||||
break;
|
||||
default:
|
||||
xjoin_style = None;
|
||||
}
|
||||
|
||||
XSetLineAttributes (private->xdisplay, private->xgc, line_width,
|
||||
xline_style, xcap_style, xjoin_style);
|
||||
}
|
47
gdk/gdkglobals.c
Normal file
47
gdk/gdkglobals.c
Normal file
@ -0,0 +1,47 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include "gdktypes.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
gint gdk_debug_level = 0;
|
||||
gint gdk_show_events = FALSE;
|
||||
gint gdk_use_xshm = TRUE;
|
||||
gchar *gdk_display_name = NULL;
|
||||
Display *gdk_display = NULL;
|
||||
gint gdk_screen;
|
||||
Window gdk_root_window;
|
||||
Window gdk_leader_window;
|
||||
GdkWindowPrivate gdk_root_parent;
|
||||
Atom gdk_wm_delete_window;
|
||||
Atom gdk_wm_take_focus;
|
||||
Atom gdk_wm_protocols;
|
||||
Atom gdk_wm_window_protocols[2];
|
||||
Atom gdk_selection_property;
|
||||
GdkDndGlobals gdk_dnd = {None,None,None,
|
||||
None,None,None,
|
||||
None,
|
||||
None,None,
|
||||
NULL,
|
||||
0, 0,
|
||||
{0,0}};
|
||||
gchar *gdk_progname = NULL;
|
||||
gchar *gdk_progclass = NULL;
|
||||
gint gdk_error_code;
|
||||
gint gdk_error_warnings = TRUE;
|
492
gdk/gdkimage.c
Normal file
492
gdk/gdkimage.c
Normal file
@ -0,0 +1,492 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include "../config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined (HAVE_IPC_H) && defined (HAVE_SHM_H) && defined (HAVE_XSHM_H)
|
||||
#define USE_SHM
|
||||
#endif
|
||||
|
||||
#ifdef USE_SHM
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#endif /* USE_SHM */
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#ifdef USE_SHM
|
||||
#include <X11/extensions/XShm.h>
|
||||
#endif /* USE_SHM */
|
||||
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
static void gdk_image_put_normal (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height);
|
||||
static void gdk_image_put_shared (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
|
||||
static GList *image_list = NULL;
|
||||
|
||||
|
||||
void
|
||||
gdk_image_exit ()
|
||||
{
|
||||
GdkImage *image;
|
||||
|
||||
while (image_list)
|
||||
{
|
||||
image = image_list->data;
|
||||
gdk_image_destroy (image);
|
||||
}
|
||||
}
|
||||
|
||||
GdkImage *
|
||||
gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h)
|
||||
/*
|
||||
* Desc: create a new bitmap image
|
||||
*/
|
||||
{
|
||||
Visual *xvisual;
|
||||
GdkImage *image;
|
||||
GdkImagePrivate *private;
|
||||
private = g_new(GdkImagePrivate, 1);
|
||||
image = (GdkImage *) private;
|
||||
private->xdisplay = gdk_display;
|
||||
private->image_put = gdk_image_put_normal;
|
||||
image->type = GDK_IMAGE_NORMAL;
|
||||
image->visual = visual;
|
||||
image->width = w;
|
||||
image->height = h;
|
||||
image->depth = 1;
|
||||
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
||||
private->ximage = XCreateImage(private->xdisplay, xvisual, 1, XYBitmap,
|
||||
0, 0, w ,h, 8, 0);
|
||||
private->ximage->data = data;
|
||||
private->ximage->bitmap_bit_order = MSBFirst;
|
||||
private->ximage->byte_order = MSBFirst;
|
||||
image->byte_order = MSBFirst;
|
||||
image->mem = private->ximage->data;
|
||||
image->bpl = private->ximage->bytes_per_line;
|
||||
image->bpp = 1;
|
||||
return(image);
|
||||
} /* gdk_image_new_bitmap() */
|
||||
|
||||
static int
|
||||
gdk_image_check_xshm(Display *display)
|
||||
/*
|
||||
* Desc: query the server for support for the MIT_SHM extension
|
||||
* Return: 0 = not available
|
||||
* 1 = shared XImage support available
|
||||
* 2 = shared Pixmap support available also
|
||||
*/
|
||||
{
|
||||
#ifdef USE_SHM
|
||||
int major, minor, ignore;
|
||||
Bool pixmaps;
|
||||
|
||||
if (XQueryExtension(display, "MIT-SHM", &ignore, &ignore, &ignore))
|
||||
{
|
||||
if (XShmQueryVersion(display, &major, &minor, &pixmaps )==True)
|
||||
{
|
||||
return (pixmaps==True) ? 2 : 1;
|
||||
}
|
||||
}
|
||||
#endif /* USE_SHM */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_image_init ()
|
||||
{
|
||||
if (gdk_use_xshm)
|
||||
{
|
||||
if (!gdk_image_check_xshm (gdk_display))
|
||||
{
|
||||
g_warning ("MIT-SHM Extension not availible on server");
|
||||
gdk_use_xshm = False;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GdkImage*
|
||||
gdk_image_new (GdkImageType type,
|
||||
GdkVisual *visual,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkImage *image;
|
||||
GdkImagePrivate *private;
|
||||
#ifdef USE_SHM
|
||||
XShmSegmentInfo *x_shm_info;
|
||||
#endif /* USE_SHM */
|
||||
Visual *xvisual;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GDK_IMAGE_FASTEST:
|
||||
image = gdk_image_new (GDK_IMAGE_SHARED, visual, width, height);
|
||||
|
||||
if (!image)
|
||||
image = gdk_image_new (GDK_IMAGE_NORMAL, visual, width, height);
|
||||
break;
|
||||
|
||||
default:
|
||||
private = g_new (GdkImagePrivate, 1);
|
||||
image = (GdkImage*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->image_put = NULL;
|
||||
|
||||
image->type = type;
|
||||
image->visual = visual;
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
image->depth = visual->depth;
|
||||
|
||||
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GDK_IMAGE_SHARED:
|
||||
#ifdef USE_SHM
|
||||
if (gdk_use_xshm)
|
||||
{
|
||||
private->image_put = gdk_image_put_shared;
|
||||
|
||||
private->x_shm_info = g_new (XShmSegmentInfo, 1);
|
||||
x_shm_info = private->x_shm_info;
|
||||
|
||||
private->ximage = XShmCreateImage (private->xdisplay, xvisual, visual->depth,
|
||||
ZPixmap, NULL, x_shm_info, width, height);
|
||||
if (private->ximage == NULL)
|
||||
{
|
||||
g_warning ("XShmCreateImage failed");
|
||||
|
||||
g_free (image);
|
||||
gdk_use_xshm = False;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
x_shm_info->shmid = shmget (IPC_PRIVATE,
|
||||
private->ximage->bytes_per_line * private->ximage->height,
|
||||
IPC_CREAT | 0777);
|
||||
|
||||
if (x_shm_info->shmid == -1)
|
||||
{
|
||||
g_warning ("shmget failed!");
|
||||
|
||||
XDestroyImage (private->ximage);
|
||||
g_free (private->x_shm_info);
|
||||
g_free (image);
|
||||
|
||||
gdk_use_xshm = False;
|
||||
gdk_use_xshm = False;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
x_shm_info->readOnly = False;
|
||||
x_shm_info->shmaddr = shmat (x_shm_info->shmid, 0, 0);
|
||||
private->ximage->data = x_shm_info->shmaddr;
|
||||
|
||||
if (x_shm_info->shmaddr == (char*) -1)
|
||||
{
|
||||
g_warning ("shmat failed!");
|
||||
|
||||
XDestroyImage (private->ximage);
|
||||
shmctl (x_shm_info->shmid, IPC_RMID, 0);
|
||||
|
||||
g_free (private->x_shm_info);
|
||||
g_free (image);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef IPC_RMID_DEFERRED_RELEASE
|
||||
if (x_shm_info->shmaddr != (char*) -1)
|
||||
shmctl (x_shm_info->shmid, IPC_RMID, 0);
|
||||
#endif
|
||||
|
||||
gdk_error_code = 0;
|
||||
gdk_error_warnings = 0;
|
||||
|
||||
XShmAttach (private->xdisplay, x_shm_info);
|
||||
XSync (private->xdisplay, False);
|
||||
|
||||
gdk_error_warnings = 1;
|
||||
if (gdk_error_code == -1)
|
||||
{
|
||||
g_warning ("XShmAttach failed!");
|
||||
|
||||
XDestroyImage (private->ximage);
|
||||
shmdt (x_shm_info->shmaddr);
|
||||
shmctl (x_shm_info->shmid, IPC_RMID, 0);
|
||||
|
||||
g_free (private->x_shm_info);
|
||||
g_free (image);
|
||||
|
||||
gdk_use_xshm = False;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (image)
|
||||
image_list = g_list_prepend (image_list, image);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (image);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
#else /* USE_SHM */
|
||||
g_free (image);
|
||||
return NULL;
|
||||
#endif /* USE_SHM */
|
||||
case GDK_IMAGE_NORMAL:
|
||||
private->image_put = gdk_image_put_normal;
|
||||
|
||||
private->ximage = XCreateImage (private->xdisplay, xvisual, visual->depth,
|
||||
ZPixmap, 0, 0, width, height, 32, 0);
|
||||
|
||||
private->ximage->data = g_new (char, private->ximage->bytes_per_line *
|
||||
private->ximage->height);
|
||||
break;
|
||||
|
||||
case GDK_IMAGE_FASTEST:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if (image)
|
||||
{
|
||||
image->byte_order = private->ximage->byte_order;
|
||||
image->mem = private->ximage->data;
|
||||
image->bpl = private->ximage->bytes_per_line;
|
||||
|
||||
switch (private->ximage->bits_per_pixel)
|
||||
{
|
||||
case 8:
|
||||
image->bpp = 1;
|
||||
break;
|
||||
case 16:
|
||||
image->bpp = 2;
|
||||
break;
|
||||
case 24:
|
||||
image->bpp = 3;
|
||||
break;
|
||||
case 32:
|
||||
image->bpp = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
GdkImage*
|
||||
gdk_image_get (GdkWindow *window,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkImage *image;
|
||||
GdkImagePrivate *private;
|
||||
GdkWindowPrivate *win_private;
|
||||
|
||||
g_return_val_if_fail (window != NULL, NULL);
|
||||
|
||||
win_private = (GdkWindowPrivate *) window;
|
||||
|
||||
private = g_new (GdkImagePrivate, 1);
|
||||
image = (GdkImage*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->image_put = gdk_image_put_normal;
|
||||
private->ximage = XGetImage (private->xdisplay,
|
||||
win_private->xwindow,
|
||||
x, y, width, height,
|
||||
AllPlanes, ZPixmap);
|
||||
|
||||
image->type = GDK_IMAGE_NORMAL;
|
||||
image->visual = gdk_window_get_visual (window);
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
image->depth = private->ximage->depth;
|
||||
|
||||
image->mem = private->ximage->data;
|
||||
image->bpl = private->ximage->bytes_per_line;
|
||||
image->bpp = 1;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
guint32
|
||||
gdk_image_get_pixel (GdkImage *image,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
guint32 pixel;
|
||||
GdkImagePrivate *private;
|
||||
|
||||
g_return_val_if_fail (image != NULL, 0);
|
||||
|
||||
private = (GdkImagePrivate *) image;
|
||||
|
||||
pixel = XGetPixel (private->ximage, x, y);
|
||||
|
||||
return pixel;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_image_put_pixel (GdkImage *image,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 pixel)
|
||||
{
|
||||
GdkImagePrivate *private;
|
||||
|
||||
g_return_if_fail (image != NULL);
|
||||
|
||||
private = (GdkImagePrivate *) image;
|
||||
|
||||
pixel = XPutPixel (private->ximage, x, y, pixel);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_image_destroy (GdkImage *image)
|
||||
{
|
||||
GdkImagePrivate *private;
|
||||
#ifdef USE_SHM
|
||||
XShmSegmentInfo *x_shm_info;
|
||||
#endif /* USE_SHM */
|
||||
|
||||
g_return_if_fail (image != NULL);
|
||||
|
||||
private = (GdkImagePrivate*) image;
|
||||
switch (image->type)
|
||||
{
|
||||
case GDK_IMAGE_NORMAL:
|
||||
XDestroyImage (private->ximage);
|
||||
break;
|
||||
|
||||
case GDK_IMAGE_SHARED:
|
||||
#ifdef USE_SHM
|
||||
XShmDetach (private->xdisplay, private->x_shm_info);
|
||||
XDestroyImage (private->ximage);
|
||||
|
||||
x_shm_info = private->x_shm_info;
|
||||
shmdt (x_shm_info->shmaddr);
|
||||
shmctl (x_shm_info->shmid, IPC_RMID, 0);
|
||||
|
||||
g_free (private->x_shm_info);
|
||||
|
||||
image_list = g_list_remove (image_list, image);
|
||||
#else /* USE_SHM */
|
||||
g_error ("trying to destroy shared memory image when gdk was compiled without shared memory support");
|
||||
#endif /* USE_SHM */
|
||||
break;
|
||||
|
||||
case GDK_IMAGE_FASTEST:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
g_free (image);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_image_put_normal (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkImagePrivate *image_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (image != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
image_private = (GdkImagePrivate*) image;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
g_return_if_fail (image->type == GDK_IMAGE_NORMAL);
|
||||
|
||||
XPutImage (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, image_private->ximage,
|
||||
xsrc, ysrc, xdest, ydest, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_image_put_shared (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
#ifdef USE_SHM
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkImagePrivate *image_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (image != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
image_private = (GdkImagePrivate*) image;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
g_return_if_fail (image->type == GDK_IMAGE_SHARED);
|
||||
|
||||
XShmPutImage (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, image_private->ximage,
|
||||
xsrc, ysrc, xdest, ydest, width, height, False);
|
||||
#else /* USE_SHM */
|
||||
g_error ("trying to draw shared memory image when gdk was compiled without shared memory support");
|
||||
#endif /* USE_SHM */
|
||||
}
|
324
gdk/gdkinput.c
Normal file
324
gdk/gdkinput.c
Normal file
@ -0,0 +1,324 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "../config.h"
|
||||
#include "gdk.h"
|
||||
#include "gdkx.h"
|
||||
#include "gdkprivate.h"
|
||||
#include "gdkinput.h"
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
|
||||
static gint gdk_input_enable_window (GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_disable_window (GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static GdkInputWindow *gdk_input_window_find (GdkWindow *window);
|
||||
static GdkDevicePrivate *gdk_input_find_device (guint32 id);
|
||||
|
||||
|
||||
/* Incorporate the specific routines depending on compilation options */
|
||||
|
||||
static GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y };
|
||||
|
||||
static GdkDeviceInfo gdk_input_core_info =
|
||||
{
|
||||
GDK_CORE_POINTER,
|
||||
"Core Pointer",
|
||||
GDK_SOURCE_MOUSE,
|
||||
GDK_MODE_SCREEN,
|
||||
TRUE,
|
||||
2,
|
||||
gdk_input_core_axes
|
||||
};
|
||||
|
||||
/* Global variables */
|
||||
|
||||
GdkInputVTable gdk_input_vtable;
|
||||
/* information about network port and host for gxid daemon */
|
||||
gchar *gdk_input_gxid_host;
|
||||
gint gdk_input_gxid_port;
|
||||
gint gdk_input_ignore_core;
|
||||
|
||||
/* Local variables */
|
||||
|
||||
static GList *gdk_input_devices;
|
||||
static GList *gdk_input_windows;
|
||||
|
||||
#include "gdkinputnone.h"
|
||||
#include "gdkinputcommon.h"
|
||||
#include "gdkinputxfree.h"
|
||||
#include "gdkinputgxi.h"
|
||||
|
||||
GList *
|
||||
gdk_input_list_devices ()
|
||||
{
|
||||
return gdk_input_devices;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_set_source (guint32 deviceid, GdkInputSource source)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
|
||||
gdkdev->info.source = source;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_input_set_mode (guint32 deviceid, GdkInputMode mode)
|
||||
{
|
||||
if (deviceid == GDK_CORE_POINTER)
|
||||
return FALSE;
|
||||
|
||||
if (gdk_input_vtable.set_mode)
|
||||
return gdk_input_vtable.set_mode(deviceid,mode);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_set_axes (guint32 deviceid, GdkAxisUse *axes)
|
||||
{
|
||||
if (deviceid != GDK_CORE_POINTER && gdk_input_vtable.set_axes)
|
||||
gdk_input_vtable.set_axes (deviceid, axes);
|
||||
}
|
||||
|
||||
GdkTimeCoord *
|
||||
gdk_input_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return)
|
||||
{
|
||||
XTimeCoord *xcoords;
|
||||
GdkTimeCoord *coords;
|
||||
int i;
|
||||
|
||||
if (deviceid == GDK_CORE_POINTER)
|
||||
{
|
||||
xcoords = XGetMotionEvents (gdk_display,
|
||||
((GdkWindowPrivate *)window)->xwindow,
|
||||
start, stop, nevents_return);
|
||||
if (xcoords)
|
||||
{
|
||||
coords = g_new (GdkTimeCoord, *nevents_return);
|
||||
for (i=0; i<*nevents_return; i++)
|
||||
{
|
||||
coords[i].time = xcoords[i].time;
|
||||
coords[i].x = xcoords[i].x;
|
||||
coords[i].y = xcoords[i].y;
|
||||
coords[i].pressure = 0.5;
|
||||
coords[i].xtilt = 0.0;
|
||||
coords[i].ytilt = 0.0;
|
||||
}
|
||||
|
||||
XFree(xcoords);
|
||||
|
||||
return coords;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gdk_input_vtable.motion_events)
|
||||
{
|
||||
return gdk_input_vtable.motion_events(window,
|
||||
deviceid, start, stop,
|
||||
nevents_return);
|
||||
}
|
||||
else
|
||||
{
|
||||
*nevents_return = 0;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
if (gdk_input_vtable.enable_window)
|
||||
return gdk_input_vtable.enable_window (window, gdkdev);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
if (gdk_input_vtable.disable_window)
|
||||
return gdk_input_vtable.disable_window(window,gdkdev);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static GdkInputWindow *
|
||||
gdk_input_window_find(GdkWindow *window)
|
||||
{
|
||||
GList *tmp_list;
|
||||
|
||||
for (tmp_list=gdk_input_windows; tmp_list; tmp_list=tmp_list->next)
|
||||
if (((GdkInputWindow *)(tmp_list->data))->window == window)
|
||||
return (GdkInputWindow *)(tmp_list->data);
|
||||
|
||||
return NULL; /* Not found */
|
||||
}
|
||||
|
||||
/* FIXME: this routine currently needs to be called between creation
|
||||
and the corresponding configure event (because it doesn't get the
|
||||
root_relative_geometry). This should work with
|
||||
gtk_window_set_extension_events, but will likely fail in other
|
||||
cases */
|
||||
|
||||
void
|
||||
gdk_input_set_extension_events (GdkWindow *window, gint mask,
|
||||
GdkExtensionMode mode)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GdkInputWindow *iw;
|
||||
|
||||
g_return_if_fail (window != NULL);
|
||||
|
||||
if (mode == GDK_EXTENSION_EVENTS_NONE)
|
||||
mask = 0;
|
||||
|
||||
if (mask != 0)
|
||||
{
|
||||
iw = g_new(GdkInputWindow,1);
|
||||
|
||||
iw->window = window;
|
||||
iw->mode = mode;
|
||||
|
||||
iw->obscuring = NULL;
|
||||
iw->num_obscuring = 0;
|
||||
iw->grabbed = FALSE;
|
||||
|
||||
gdk_input_windows = g_list_append(gdk_input_windows,iw);
|
||||
((GdkWindowPrivate *)window)->extension_events = mask;
|
||||
|
||||
/* Add enter window events to the event mask */
|
||||
/* FIXME, this is not needed for XINPUT_NONE */
|
||||
gdk_window_set_events (window,
|
||||
gdk_window_get_events (window) |
|
||||
GDK_ENTER_NOTIFY_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
iw = gdk_input_window_find (window);
|
||||
if (iw)
|
||||
{
|
||||
gdk_input_windows = g_list_remove(gdk_input_windows,iw);
|
||||
g_free(iw);
|
||||
}
|
||||
|
||||
((GdkWindowPrivate *)window)->extension_events = 0;
|
||||
}
|
||||
|
||||
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
||||
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
|
||||
{
|
||||
if (mask != 0 && gdkdev->info.mode != GDK_MODE_DISABLED
|
||||
&& (gdkdev->info.has_cursor || mode == GDK_EXTENSION_EVENTS_ALL))
|
||||
gdk_input_enable_window(window,gdkdev);
|
||||
else
|
||||
gdk_input_disable_window(window,gdkdev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_window_destroy (GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
input_window = gdk_input_window_find (window);
|
||||
g_return_if_fail (input_window != NULL);
|
||||
|
||||
gdk_input_windows = g_list_remove(gdk_input_windows,input_window);
|
||||
g_free(input_window);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_exit (void)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
|
||||
{
|
||||
gdk_input_set_mode(gdkdev->info.deviceid,GDK_MODE_DISABLED);
|
||||
|
||||
g_free(gdkdev->info.name);
|
||||
#ifndef XINPUT_NONE
|
||||
g_free(gdkdev->axes);
|
||||
#endif
|
||||
g_free(gdkdev->info.axes);
|
||||
g_free(gdkdev);
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free(gdk_input_devices);
|
||||
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
g_free(tmp_list->data);
|
||||
}
|
||||
g_list_free(gdk_input_windows);
|
||||
}
|
||||
|
||||
static GdkDevicePrivate *
|
||||
gdk_input_find_device(guint32 id)
|
||||
{
|
||||
GList *tmp_list = gdk_input_devices;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
||||
if (gdkdev->info.deviceid == id)
|
||||
return gdkdev;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_window_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
if (gdk_input_vtable.get_pointer)
|
||||
gdk_input_vtable.get_pointer (window, deviceid, x, y, pressure,
|
||||
xtilt, ytilt, mask);
|
||||
}
|
143
gdk/gdkinput.h
Normal file
143
gdk/gdkinput.h
Normal file
@ -0,0 +1,143 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_INPUT_H__
|
||||
#define __GDK_INPUT_H__
|
||||
|
||||
#ifndef XINPUT_NONE
|
||||
#include <X11/extensions/XInput.h>
|
||||
#endif
|
||||
|
||||
typedef struct _GdkAxisInfo GdkAxisInfo;
|
||||
typedef struct _GdkInputVTable GdkInputVTable;
|
||||
typedef struct _GdkDevicePrivate GdkDevicePrivate;
|
||||
typedef struct _GdkInputWindow GdkInputWindow;
|
||||
|
||||
struct _GdkInputVTable {
|
||||
gint (*set_mode) (guint32 deviceid, GdkInputMode mode);
|
||||
void (*set_axes) (guint32 deviceid, GdkAxisUse *axes);
|
||||
GdkTimeCoord* (*motion_events) (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return);
|
||||
void (*get_pointer) (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask);
|
||||
gint (*grab_pointer) (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time);
|
||||
void (*ungrab_pointer) (guint32 time);
|
||||
|
||||
void (*configure_event) (XConfigureEvent *xevent, GdkWindow *window);
|
||||
void (*enter_event) (XCrossingEvent *xevent, GdkWindow *window);
|
||||
gint (*other_event) (GdkEvent *event, XEvent *xevent, GdkWindow *window);
|
||||
/* Handle an unidentified event. Returns TRUE if handled, FALSE
|
||||
otherwise */
|
||||
gint (*window_none_event) (GdkEvent *event, XEvent *xevent);
|
||||
gint (*enable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
|
||||
gint (*disable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
|
||||
};
|
||||
|
||||
/* information about a device axis */
|
||||
struct _GdkAxisInfo
|
||||
{
|
||||
/* reported x resolution */
|
||||
gint xresolution;
|
||||
|
||||
/* reported x minimum/maximum values */
|
||||
gint xmin_value, xmax_value;
|
||||
|
||||
/* calibrated resolution (for aspect ration) - only relative values
|
||||
between axes used */
|
||||
gint resolution;
|
||||
|
||||
/* calibrated minimum/maximum values */
|
||||
gint min_value, max_value;
|
||||
};
|
||||
|
||||
#define GDK_INPUT_NUM_EVENTC 6
|
||||
|
||||
struct _GdkDevicePrivate {
|
||||
GdkDeviceInfo info;
|
||||
|
||||
#ifndef XINPUT_NONE
|
||||
/* information about the axes */
|
||||
GdkAxisInfo *axes;
|
||||
|
||||
/* reverse lookup on axis use type */
|
||||
gint axis_for_use[GDK_AXIS_LAST];
|
||||
|
||||
/* Information about XInput device */
|
||||
XDevice *xdevice;
|
||||
|
||||
int buttonpress_type, buttonrelease_type, motionnotify_type,
|
||||
proximityin_type, proximityout_type, changenotify_type;
|
||||
|
||||
/* true if we need to select a different set of events, but
|
||||
can't because this is the core pointer */
|
||||
gint needs_update;
|
||||
|
||||
/* Mask of buttons (used for button grabs) */
|
||||
gint button_state;
|
||||
|
||||
/* true if we've claimed the device as active. (used only for XINPUT_GXI) */
|
||||
gint claimed;
|
||||
#endif /* !XINPUT_NONE */
|
||||
};
|
||||
|
||||
struct _GdkInputWindow
|
||||
{
|
||||
/* gdk window */
|
||||
GdkWindow *window;
|
||||
|
||||
/* Extension mode (GDK_EXTENSION_EVENTS_ALL/CURSOR) */
|
||||
GdkExtensionMode mode;
|
||||
|
||||
/* position relative to root window */
|
||||
gint16 root_x;
|
||||
gint16 root_y;
|
||||
|
||||
/* rectangles relative to window of windows obscuring this one */
|
||||
GdkRectangle *obscuring;
|
||||
gint num_obscuring;
|
||||
|
||||
/* Is there a pointer grab for this window ? */
|
||||
gint grabbed;
|
||||
};
|
||||
|
||||
/* Global data */
|
||||
|
||||
extern GdkInputVTable gdk_input_vtable;
|
||||
/* information about network port and host for gxid daemon */
|
||||
extern gchar *gdk_input_gxid_host;
|
||||
extern gint gdk_input_gxid_port;
|
||||
extern gint gdk_input_ignore_core;
|
||||
|
||||
/* Function declarations */
|
||||
|
||||
void gdk_input_window_destroy (GdkWindow *window);
|
||||
|
||||
#endif __GDK_INPUT_H__
|
687
gdk/gdkinputcommon.h
Normal file
687
gdk/gdkinputcommon.h
Normal file
@ -0,0 +1,687 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#if defined(XINPUT_GXI) || defined(XINPUT_XFREE)
|
||||
|
||||
/* Forward declarations */
|
||||
static void gdk_input_get_root_relative_geometry (Display *dpy, Window w,
|
||||
int *x_ret, int *y_ret,
|
||||
int *width_ret,
|
||||
int *height_ret);
|
||||
static GdkDevicePrivate *gdk_input_device_new(XDeviceInfo *device,
|
||||
gint include_core);
|
||||
static void gdk_input_common_find_events(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev,
|
||||
gint mask,
|
||||
XEventClass *classes,
|
||||
int *num_classes);
|
||||
static void gdk_input_common_select_events(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static void gdk_input_translate_coordinates(GdkDevicePrivate *gdkdev,
|
||||
GdkInputWindow *input_window,
|
||||
gint *axis_data,
|
||||
gdouble *x, gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt, gdouble *ytilt);
|
||||
static guint gdk_input_translate_state(guint state, guint device_state);
|
||||
static gint gdk_input_common_init(gint include_core);
|
||||
static gint gdk_input_common_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkInputWindow *input_window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static void gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes);
|
||||
static GdkTimeCoord * gdk_input_common_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return);
|
||||
static void gdk_input_common_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask);
|
||||
|
||||
/* Global variables */
|
||||
|
||||
static gint gdk_input_root_width;
|
||||
static gint gdk_input_root_height;
|
||||
|
||||
static void
|
||||
gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_ret,
|
||||
int *width_ret, int *height_ret)
|
||||
{
|
||||
Window root,parent;
|
||||
Window *children;
|
||||
int nchildren;
|
||||
int x,y,width,height;
|
||||
int xc,yc,widthc,heightc,border_widthc,depthc;
|
||||
|
||||
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
|
||||
if (children) XFree(children);
|
||||
XGetGeometry(dpy,w,&root,&x,&y,&width,&height,&border_widthc,
|
||||
&depthc);
|
||||
x += border_widthc;
|
||||
y += border_widthc;
|
||||
|
||||
while (root != parent)
|
||||
{
|
||||
w = parent;
|
||||
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
|
||||
if (children) XFree(children);
|
||||
XGetGeometry(dpy,w,&root,&xc,&yc,&widthc,&heightc,
|
||||
&border_widthc,&depthc);
|
||||
x += xc + border_widthc;
|
||||
y += yc + border_widthc;
|
||||
}
|
||||
|
||||
if (x_ret)
|
||||
*x_ret = x;
|
||||
if (y_ret)
|
||||
*y_ret = y;
|
||||
if (width_ret)
|
||||
*width_ret = width;
|
||||
if (height_ret)
|
||||
*height_ret = height;
|
||||
}
|
||||
|
||||
static GdkDevicePrivate *
|
||||
gdk_input_device_new(XDeviceInfo *device, gint include_core)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev;
|
||||
gchar *tmp_name, *p;
|
||||
XAnyClassPtr class;
|
||||
gint i,j;
|
||||
|
||||
gdkdev = g_new(GdkDevicePrivate,1);
|
||||
|
||||
gdkdev->info.deviceid = device->id;
|
||||
if (device->name[0]) {
|
||||
gdkdev->info.name = g_new(char, strlen(device->name)+1);
|
||||
strcpy(gdkdev->info.name,device->name);
|
||||
} else {
|
||||
/* XFree86 3.2 gives an empty name to the default core devices,
|
||||
(fixed in 3.2A) */
|
||||
gdkdev->info.name = g_strdup("pointer");
|
||||
strcpy(gdkdev->info.name,"pointer");
|
||||
gdkdev->info.source = GDK_SOURCE_MOUSE;
|
||||
}
|
||||
|
||||
gdkdev->info.mode = GDK_MODE_DISABLED;
|
||||
|
||||
/* Try to figure out what kind of device this is by its name -
|
||||
could invite a very, very, long list... Lowercase name
|
||||
for comparison purposes */
|
||||
|
||||
tmp_name = g_strdup(gdkdev->info.name);
|
||||
for (p = tmp_name; *p; p++)
|
||||
{
|
||||
if (*p >= 'A' && *p <= 'Z')
|
||||
*p += 'a' - 'A';
|
||||
}
|
||||
|
||||
if (!strcmp (tmp_name, "pointer"))
|
||||
gdkdev->info.source = GDK_SOURCE_MOUSE;
|
||||
else if (!strcmp (tmp_name, "wacom") ||
|
||||
!strcmp (tmp_name, "pen"))
|
||||
gdkdev->info.source = GDK_SOURCE_PEN;
|
||||
else if (!strcmp (tmp_name, "eraser"))
|
||||
gdkdev->info.source = GDK_SOURCE_ERASER;
|
||||
else if (!strcmp (tmp_name, "cursor"))
|
||||
gdkdev->info.source = GDK_SOURCE_CURSOR;
|
||||
else
|
||||
gdkdev->info.source = GDK_SOURCE_PEN;
|
||||
|
||||
g_free(tmp_name);
|
||||
|
||||
gdkdev->xdevice = NULL;
|
||||
|
||||
/* step through the classes */
|
||||
|
||||
gdkdev->info.num_axes = 0;
|
||||
gdkdev->axes = 0;
|
||||
gdkdev->info.has_cursor = 0;
|
||||
gdkdev->needs_update = FALSE;
|
||||
gdkdev->claimed = FALSE;
|
||||
gdkdev->button_state = 0;
|
||||
|
||||
class = device->inputclassinfo;
|
||||
for (i=0;i<device->num_classes;i++)
|
||||
{
|
||||
switch (class->class) {
|
||||
case ButtonClass:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ValuatorClass:
|
||||
{
|
||||
XValuatorInfo *xvi = (XValuatorInfo *)class;
|
||||
gdkdev->info.num_axes = xvi->num_axes;
|
||||
gdkdev->axes = g_new(GdkAxisInfo, xvi->num_axes);
|
||||
gdkdev->info.axes = g_new(GdkAxisUse, xvi->num_axes);
|
||||
for (j=0;j<xvi->num_axes;j++)
|
||||
{
|
||||
gdkdev->axes[j].resolution =
|
||||
gdkdev->axes[j].xresolution = xvi->axes[j].resolution;
|
||||
gdkdev->axes[j].min_value =
|
||||
gdkdev->axes[j].xmin_value = xvi->axes[j].min_value;
|
||||
gdkdev->axes[j].max_value =
|
||||
gdkdev->axes[j].xmax_value = xvi->axes[j].max_value;
|
||||
gdkdev->info.axes[j] = GDK_AXIS_IGNORE;
|
||||
}
|
||||
j=0;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_X;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_Y;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_PRESSURE;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_XTILT;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_YTILT;
|
||||
|
||||
/* set up reverse lookup on axis use */
|
||||
for (j=GDK_AXIS_IGNORE;j<GDK_AXIS_LAST;j++)
|
||||
gdkdev->axis_for_use[j] = -1;
|
||||
|
||||
for (j=0;j<xvi->num_axes;j++)
|
||||
if (gdkdev->info.axes[j] != GDK_AXIS_IGNORE)
|
||||
gdkdev->axis_for_use[gdkdev->info.axes[j]] = j;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
class = (XAnyClassPtr)(((char *)class) + class->length);
|
||||
}
|
||||
/* return NULL if no axes */
|
||||
if (!gdkdev->info.num_axes || !gdkdev->axes ||
|
||||
(!include_core && device->use == IsXPointer))
|
||||
{
|
||||
g_free(gdkdev->info.name);
|
||||
if (gdkdev->axes)
|
||||
g_free(gdkdev->axes);
|
||||
g_free(gdkdev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (device->use != IsXPointer)
|
||||
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
|
||||
|
||||
return gdkdev;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_common_find_events(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev,
|
||||
gint mask,
|
||||
XEventClass *classes,
|
||||
int *num_classes)
|
||||
{
|
||||
gint i;
|
||||
XEventClass class;
|
||||
|
||||
i = 0;
|
||||
/* We have to track press and release events in pairs to keep
|
||||
track of button state correctly and implement grabbing */
|
||||
if (mask & GDK_BUTTON_PRESS_MASK || mask & GDK_BUTTON_RELEASE_MASK)
|
||||
{
|
||||
DeviceButtonPress (gdkdev->xdevice, gdkdev->buttonpress_type,
|
||||
class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
DeviceButtonRelease (gdkdev->xdevice, gdkdev->buttonrelease_type,
|
||||
class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_POINTER_MOTION_MASK)
|
||||
{
|
||||
DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_POINTER_MOTION_HINT_MASK)
|
||||
{
|
||||
/* We'll get into trouble if the macros change, but at least we'll
|
||||
know about it, and we avoid warnings now */
|
||||
DevicePointerMotionHint (gdkdev->xdevice, 0, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_PROXIMITY_IN_MASK)
|
||||
{
|
||||
ProximityIn (gdkdev->xdevice, gdkdev->proximityin_type, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_PROXIMITY_OUT_MASK)
|
||||
{
|
||||
ProximityOut (gdkdev->xdevice, gdkdev->proximityout_type, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
|
||||
*num_classes = i;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_common_select_events(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
XEventClass classes[6];
|
||||
gint num_classes;
|
||||
|
||||
if (gdkdev->info.mode == GDK_MODE_DISABLED)
|
||||
gdk_input_common_find_events(window, gdkdev, 0, classes, &num_classes);
|
||||
else
|
||||
gdk_input_common_find_events(window, gdkdev,
|
||||
((GdkWindowPrivate *)window)->extension_events,
|
||||
classes, &num_classes);
|
||||
|
||||
XSelectExtensionEvent (gdk_display,
|
||||
GDK_WINDOW_XWINDOW(window),
|
||||
classes, num_classes);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_input_common_init(gint include_core)
|
||||
{
|
||||
char **extensions;
|
||||
XDeviceInfo *devices;
|
||||
int num_devices;
|
||||
int num_extensions, loop;
|
||||
Display *display = gdk_display;
|
||||
|
||||
/* Init global vars */
|
||||
gdk_window_get_geometry(NULL, /* use root window */
|
||||
NULL,NULL,
|
||||
&gdk_input_root_width,&gdk_input_root_height,
|
||||
NULL);
|
||||
|
||||
/* Init XInput extension */
|
||||
|
||||
extensions = XListExtensions(display, &num_extensions);
|
||||
for (loop = 0; loop < num_extensions &&
|
||||
(strcmp(extensions[loop], "XInputExtension") != 0); loop++);
|
||||
XFreeExtensionList(extensions);
|
||||
if (loop == num_extensions) /* XInput extension not found */
|
||||
return FALSE;
|
||||
|
||||
gdk_input_devices = 0;
|
||||
devices = XListInputDevices(display, &num_devices);
|
||||
|
||||
for(loop=0; loop<num_devices; loop++)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = gdk_input_device_new(&devices[loop],
|
||||
include_core);
|
||||
if (gdkdev)
|
||||
gdk_input_devices = g_list_append(gdk_input_devices, gdkdev);
|
||||
}
|
||||
XFreeDeviceList(devices);
|
||||
|
||||
gdk_input_devices = g_list_append (gdk_input_devices, &gdk_input_core_info);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
|
||||
GdkInputWindow *input_window,
|
||||
gint *axis_data,
|
||||
gdouble *x, gdouble *y, gdouble *pressure,
|
||||
gdouble *xtilt, gdouble *ytilt)
|
||||
{
|
||||
GdkWindowPrivate *win_priv;
|
||||
|
||||
int x_axis, y_axis, pressure_axis, xtilt_axis, ytilt_axis;
|
||||
|
||||
double device_width, device_height;
|
||||
double x_offset, y_offset, x_scale, y_scale;
|
||||
|
||||
win_priv = (GdkWindowPrivate *) input_window->window;
|
||||
|
||||
x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
|
||||
y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
|
||||
pressure_axis = gdkdev->axis_for_use[GDK_AXIS_PRESSURE];
|
||||
xtilt_axis = gdkdev->axis_for_use[GDK_AXIS_XTILT];
|
||||
ytilt_axis = gdkdev->axis_for_use[GDK_AXIS_YTILT];
|
||||
|
||||
device_width = gdkdev->axes[x_axis].max_value -
|
||||
gdkdev->axes[x_axis].min_value;
|
||||
device_height = gdkdev->axes[y_axis].max_value -
|
||||
gdkdev->axes[y_axis].min_value;
|
||||
|
||||
if (gdkdev->info.mode == GDK_MODE_SCREEN)
|
||||
{
|
||||
x_scale = gdk_input_root_width / device_width;
|
||||
y_scale = gdk_input_root_height / device_height;
|
||||
|
||||
x_offset = - input_window->root_x;
|
||||
y_offset = - input_window->root_y;
|
||||
}
|
||||
else /* GDK_MODE_WINDOW */
|
||||
{
|
||||
double device_aspect = (device_height*gdkdev->axes[y_axis].resolution) /
|
||||
(device_width*gdkdev->axes[x_axis].resolution);
|
||||
|
||||
if (device_aspect * win_priv->width >= win_priv->height)
|
||||
{
|
||||
/* device taller than window */
|
||||
x_scale = win_priv->width / device_width;
|
||||
y_scale = (x_scale * gdkdev->axes[x_axis].resolution)
|
||||
/ gdkdev->axes[y_axis].resolution;
|
||||
|
||||
x_offset = 0;
|
||||
y_offset = -(device_height * y_scale -
|
||||
win_priv->height)/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* window taller than device */
|
||||
y_scale = win_priv->height / device_height;
|
||||
x_scale = (y_scale * gdkdev->axes[y_axis].resolution)
|
||||
/ gdkdev->axes[x_axis].resolution;
|
||||
|
||||
y_offset = 0;
|
||||
x_offset = - (device_width * x_scale - win_priv->width)/2;
|
||||
}
|
||||
}
|
||||
|
||||
if (x) *x = x_offset + x_scale*axis_data[x_axis];
|
||||
if (y) *y = y_offset + y_scale*axis_data[y_axis];
|
||||
|
||||
if (pressure)
|
||||
{
|
||||
if (pressure_axis != -1)
|
||||
*pressure = ((double)axis_data[pressure_axis]
|
||||
- gdkdev->axes[pressure_axis].min_value)
|
||||
/ (gdkdev->axes[pressure_axis].max_value
|
||||
- gdkdev->axes[pressure_axis].min_value);
|
||||
else
|
||||
*pressure = 0.5;
|
||||
}
|
||||
|
||||
if (xtilt)
|
||||
{
|
||||
if (xtilt_axis != -1)
|
||||
{
|
||||
*xtilt = 2. * (double)(axis_data[xtilt_axis] -
|
||||
(gdkdev->axes[xtilt_axis].min_value +
|
||||
gdkdev->axes[xtilt_axis].max_value)/2) /
|
||||
(gdkdev->axes[xtilt_axis].max_value -
|
||||
gdkdev->axes[xtilt_axis].min_value);
|
||||
}
|
||||
else *xtilt = 0;
|
||||
}
|
||||
|
||||
if (ytilt)
|
||||
{
|
||||
if (ytilt_axis != -1)
|
||||
{
|
||||
*ytilt = 2. * (double)(axis_data[ytilt_axis] -
|
||||
(gdkdev->axes[ytilt_axis].min_value +
|
||||
gdkdev->axes[ytilt_axis].max_value)/2) /
|
||||
(gdkdev->axes[ytilt_axis].max_value -
|
||||
gdkdev->axes[ytilt_axis].min_value);
|
||||
}
|
||||
else
|
||||
*ytilt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* combine the state of the core device and the device state
|
||||
into one - for now we do this in a simple-minded manner -
|
||||
we just take the keyboard portion of the core device and
|
||||
the button portion (all of?) the device state.
|
||||
Any button remapping should go on here. */
|
||||
static guint
|
||||
gdk_input_translate_state(guint state, guint device_state)
|
||||
{
|
||||
return device_state | (state & 0xFF);
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_common_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkInputWindow *input_window,
|
||||
GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
if ((xevent->type == gdkdev->buttonpress_type) ||
|
||||
(xevent->type == gdkdev->buttonrelease_type))
|
||||
{
|
||||
XDeviceButtonEvent *xdbe = (XDeviceButtonEvent *)(xevent);
|
||||
|
||||
if (xdbe->type == gdkdev->buttonpress_type)
|
||||
{
|
||||
event->button.type = GDK_BUTTON_PRESS;
|
||||
gdkdev->button_state |= 1 << xdbe->button;
|
||||
}
|
||||
else
|
||||
{
|
||||
event->button.type = GDK_BUTTON_RELEASE;
|
||||
gdkdev->button_state &= ~(1 << xdbe->button);
|
||||
}
|
||||
event->button.window = input_window->window;
|
||||
event->button.time = xdbe->time;
|
||||
event->button.source = gdkdev->info.source;
|
||||
event->button.deviceid = xdbe->deviceid;
|
||||
|
||||
gdk_input_translate_coordinates (gdkdev,input_window, xdbe->axis_data,
|
||||
&event->button.x,&event->button.y,
|
||||
&event->button.pressure,
|
||||
&event->button.xtilt,
|
||||
&event->button.ytilt);
|
||||
event->button.state = gdk_input_translate_state(xdbe->state,xdbe->device_state);
|
||||
event->button.button = xdbe->button;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (xevent->type == gdkdev->motionnotify_type)
|
||||
{
|
||||
XDeviceMotionEvent *xdme = (XDeviceMotionEvent *)(xevent);
|
||||
|
||||
gdk_input_translate_coordinates(gdkdev,input_window,xdme->axis_data,
|
||||
&event->motion.x,&event->motion.y,
|
||||
&event->motion.pressure,
|
||||
&event->motion.xtilt,
|
||||
&event->motion.ytilt);
|
||||
|
||||
event->motion.type = GDK_MOTION_NOTIFY;
|
||||
event->motion.window = input_window->window;
|
||||
event->motion.time = xdme->time;
|
||||
event->motion.deviceid = xdme->deviceid;
|
||||
event->motion.state = gdk_input_translate_state(xdme->state,
|
||||
xdme->device_state);
|
||||
event->motion.source = gdkdev->info.source;
|
||||
event->motion.deviceid = xdme->deviceid;
|
||||
|
||||
if (gdk_show_events)
|
||||
g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f hint: %s\n",
|
||||
xdme->window,
|
||||
xdme->deviceid,
|
||||
event->motion.x, event->motion.y,
|
||||
(xevent->xmotion.is_hint) ? "true" : "false");
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (xevent->type == gdkdev->proximityin_type ||
|
||||
xevent->type == gdkdev->proximityout_type)
|
||||
{
|
||||
XProximityNotifyEvent *xpne = (XProximityNotifyEvent *)(xevent);
|
||||
|
||||
event->proximity.type = (xevent->type == gdkdev->proximityin_type)?
|
||||
GDK_PROXIMITY_IN:GDK_PROXIMITY_OUT;
|
||||
event->proximity.window = input_window->window;
|
||||
event->proximity.time = xpne->time;
|
||||
event->proximity.source = gdkdev->info.source;
|
||||
event->proximity.deviceid = xpne->deviceid;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return -1; /* wasn't one of our event types */
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
|
||||
{
|
||||
int i;
|
||||
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
|
||||
for (i=GDK_AXIS_IGNORE;i<GDK_AXIS_LAST;i++)
|
||||
{
|
||||
gdkdev->axis_for_use[i] = -1;
|
||||
}
|
||||
|
||||
for (i=0;i<gdkdev->info.num_axes;i++)
|
||||
{
|
||||
gdkdev->info.axes[i] = axes[i];
|
||||
gdkdev->axis_for_use[axes[i]] = i;
|
||||
}
|
||||
}
|
||||
|
||||
static GdkTimeCoord *
|
||||
gdk_input_common_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return)
|
||||
{
|
||||
GdkTimeCoord *coords;
|
||||
XDeviceTimeCoord *device_coords;
|
||||
GdkInputWindow *input_window;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
int mode_return;
|
||||
int axis_count_return;
|
||||
int i;
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
input_window = gdk_input_window_find (window);
|
||||
|
||||
g_return_val_if_fail (gdkdev != NULL, NULL);
|
||||
g_return_val_if_fail (gdkdev->xdevice != NULL, NULL);
|
||||
g_return_val_if_fail (input_window != NULL, NULL);
|
||||
|
||||
device_coords = XGetDeviceMotionEvents (gdk_display,
|
||||
gdkdev->xdevice,
|
||||
start, stop,
|
||||
nevents_return, &mode_return,
|
||||
&axis_count_return);
|
||||
|
||||
if (device_coords)
|
||||
{
|
||||
coords = g_new (GdkTimeCoord, *nevents_return);
|
||||
|
||||
for (i=0; i<*nevents_return; i++)
|
||||
{
|
||||
gdk_input_translate_coordinates (gdkdev, input_window,
|
||||
device_coords[i].data,
|
||||
&coords[i].x, &coords[i].y,
|
||||
&coords[i].pressure,
|
||||
&coords[i].xtilt, &coords[i].ytilt);
|
||||
}
|
||||
XFreeDeviceMotionEvents (device_coords);
|
||||
|
||||
return coords;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_common_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GdkInputWindow *input_window;
|
||||
XDeviceState *state;
|
||||
XInputClass *input_class;
|
||||
gint x_int, y_int;
|
||||
gint i;
|
||||
|
||||
/* we probably need to get the mask in any case */
|
||||
|
||||
if (deviceid == GDK_CORE_POINTER)
|
||||
{
|
||||
gdk_window_get_pointer (window, &x_int, &y_int, mask);
|
||||
if (x) *x = x_int;
|
||||
if (y) *y = y_int;
|
||||
if (pressure) *pressure = 0.5;
|
||||
if (xtilt) *xtilt = 0;
|
||||
if (ytilt) *ytilt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mask)
|
||||
gdk_window_get_pointer (window, NULL, NULL, mask);
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
input_window = gdk_input_window_find (window);
|
||||
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
g_return_if_fail (gdkdev->xdevice != NULL);
|
||||
g_return_if_fail (input_window != NULL);
|
||||
|
||||
state = XQueryDeviceState (gdk_display, gdkdev->xdevice);
|
||||
input_class = state->data;
|
||||
for (i=0; i<state->num_classes; i++)
|
||||
{
|
||||
switch (input_class->class)
|
||||
{
|
||||
case ValuatorClass:
|
||||
gdk_input_translate_coordinates(gdkdev, input_window,
|
||||
((XValuatorState *)input_class)->valuators,
|
||||
x, y, pressure,
|
||||
xtilt, ytilt);
|
||||
|
||||
|
||||
break;
|
||||
case ButtonClass:
|
||||
if (mask)
|
||||
{
|
||||
*mask &= ~(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK |
|
||||
GDK_BUTTON3_MASK | GDK_BUTTON4_MASK |
|
||||
GDK_BUTTON5_MASK);
|
||||
for (i=0; i < ((XButtonState *)input_class)->num_buttons; i++)
|
||||
{
|
||||
if (((XButtonState *)input_class)->buttons[i])
|
||||
*mask |= GDK_BUTTON1_MASK << i;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
input_class = (XInputClass *)(((char *)input_class)+input_class->length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
628
gdk/gdkinputgxi.h
Normal file
628
gdk/gdkinputgxi.h
Normal file
@ -0,0 +1,628 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef XINPUT_GXI
|
||||
|
||||
/* #define DEBUG_SWITCHING */
|
||||
|
||||
#include <gxid_lib.h>
|
||||
|
||||
/* Forward declarations */
|
||||
static void gdk_input_gxi_select_notify (GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode);
|
||||
static gint gdk_input_is_extension_device (guint32 deviceid);
|
||||
static void gdk_input_gxi_configure_event (XConfigureEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static void gdk_input_gxi_enter_event (XCrossingEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static gint gdk_input_gxi_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static void gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev);
|
||||
|
||||
static gint gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent);
|
||||
static gint gdk_input_gxi_enable_window (GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_gxi_disable_window (GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static Window gdk_input_find_root_child(Display *dpy, Window w);
|
||||
static void gdk_input_compute_obscuring(GdkInputWindow *input_window);
|
||||
static gint gdk_input_is_obscured(GdkInputWindow *input_window, gdouble x,
|
||||
gdouble y);
|
||||
static GdkTimeCoord *gdk_input_gxi_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return);
|
||||
static void gdk_input_gxi_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask);
|
||||
static gint gdk_input_gxi_grab_pointer (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time);
|
||||
static void gdk_input_gxi_ungrab_pointer (guint32 time);
|
||||
|
||||
/* Local variables */
|
||||
|
||||
static GdkDevicePrivate *gdk_input_current_device;
|
||||
static GdkDevicePrivate *gdk_input_core_pointer;
|
||||
|
||||
void
|
||||
gdk_input_init(void)
|
||||
{
|
||||
GList *tmp_list;
|
||||
|
||||
gdk_input_vtable.set_mode = gdk_input_gxi_set_mode;
|
||||
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
|
||||
gdk_input_vtable.motion_events = gdk_input_gxi_motion_events;
|
||||
gdk_input_vtable.get_pointer = gdk_input_gxi_get_pointer;
|
||||
gdk_input_vtable.grab_pointer = gdk_input_gxi_grab_pointer;
|
||||
gdk_input_vtable.ungrab_pointer = gdk_input_gxi_ungrab_pointer;
|
||||
gdk_input_vtable.configure_event = gdk_input_gxi_configure_event;
|
||||
gdk_input_vtable.enter_event = gdk_input_gxi_enter_event;
|
||||
gdk_input_vtable.other_event = gdk_input_gxi_other_event;
|
||||
gdk_input_vtable.window_none_event = gdk_input_gxi_window_none_event;
|
||||
gdk_input_vtable.enable_window = gdk_input_gxi_enable_window;
|
||||
gdk_input_vtable.disable_window = gdk_input_gxi_disable_window;
|
||||
|
||||
gdk_input_ignore_core = FALSE;
|
||||
gdk_input_core_pointer = NULL;
|
||||
|
||||
if (!gdk_input_gxid_host)
|
||||
{
|
||||
gdk_input_gxid_host = getenv("GXID_HOST");
|
||||
}
|
||||
if (!gdk_input_gxid_port)
|
||||
{
|
||||
char *t = getenv("GXID_PORT");
|
||||
if (t)
|
||||
gdk_input_gxid_port = atoi(t);
|
||||
}
|
||||
|
||||
gdk_input_common_init(TRUE);
|
||||
|
||||
/* find initial core pointer */
|
||||
|
||||
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdk_input_is_extension_device(gdkdev->info.deviceid))
|
||||
{
|
||||
gdk_input_gxi_select_notify (gdkdev);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
|
||||
gdk_input_core_pointer = gdkdev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_select_notify (GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
XEventClass class;
|
||||
|
||||
ChangeDeviceNotify (gdkdev->xdevice, gdkdev->changenotify_type, class);
|
||||
|
||||
XSelectExtensionEvent (gdk_display, gdk_root_window, &class, 1);
|
||||
}
|
||||
|
||||
/* Set the core pointer. Device should already be enabled. */
|
||||
static gint
|
||||
gdk_input_gxi_set_core_pointer(GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
int x_axis,y_axis;
|
||||
|
||||
g_return_val_if_fail(gdkdev->xdevice,FALSE);
|
||||
|
||||
x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
|
||||
y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
|
||||
|
||||
g_return_val_if_fail(x_axis != -1 && y_axis != -1,FALSE);
|
||||
|
||||
/* core_pointer might not be up to date so we check with the server
|
||||
before change the pointer */
|
||||
|
||||
if ( !gdk_input_is_extension_device(gdkdev->info.deviceid) )
|
||||
{
|
||||
#if 0
|
||||
if (gdkdev != gdk_input_core_pointer)
|
||||
g_warning("core pointer inconsistency");
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( XChangePointerDevice(gdk_display,gdkdev->xdevice, x_axis, y_axis)
|
||||
!= Success )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_input_gxi_update_device (gdk_input_core_pointer);
|
||||
gdk_input_core_pointer = gdkdev;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* FIXME, merge with gdk_input_xfree_set_mode */
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GdkInputMode old_mode;
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
gdkdev = gdk_input_find_device(deviceid);
|
||||
g_return_val_if_fail (gdkdev != NULL,FALSE);
|
||||
old_mode = gdkdev->info.mode;
|
||||
|
||||
if (gdkdev->info.mode == mode)
|
||||
return TRUE;
|
||||
|
||||
gdkdev->info.mode = mode;
|
||||
|
||||
if (old_mode != GDK_MODE_DISABLED)
|
||||
{
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
|
||||
gdk_input_disable_window (input_window->window, gdkdev);
|
||||
}
|
||||
}
|
||||
|
||||
if (mode != GDK_MODE_DISABLED)
|
||||
{
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
|
||||
if (!gdk_input_enable_window(input_window->window, gdkdev))
|
||||
{
|
||||
gdk_input_set_mode(deviceid, old_mode);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_input_is_extension_device (guint32 deviceid)
|
||||
{
|
||||
XDeviceInfo *devices;
|
||||
int num_devices, loop;
|
||||
|
||||
if (deviceid == GDK_CORE_POINTER)
|
||||
return FALSE;
|
||||
|
||||
devices = XListInputDevices(gdk_display, &num_devices);
|
||||
for(loop=0; loop<num_devices; loop++)
|
||||
{
|
||||
if ((devices[loop].id == deviceid) && (devices[loop].use == IsXExtensionDevice))
|
||||
{
|
||||
XFreeDeviceList(devices);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
XFreeDeviceList(devices);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_configure_event (XConfigureEvent *xevent, GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
gint root_x, root_y;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_if_fail (input_window != NULL);
|
||||
|
||||
gdk_input_get_root_relative_geometry(gdk_display,GDK_WINDOW_XWINDOW(window),
|
||||
&root_x, &root_y, NULL, NULL);
|
||||
input_window->root_x = root_x;
|
||||
input_window->root_y = root_y;
|
||||
gdk_input_compute_obscuring(input_window);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_enter_event (XCrossingEvent *xevent, GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_if_fail (input_window != NULL);
|
||||
|
||||
gdk_input_compute_obscuring(input_window);
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
GdkDevicePrivate *gdkdev;
|
||||
gint return_val;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_val_if_fail (window != NULL, -1);
|
||||
|
||||
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
|
||||
but it's potentially faster than scanning through the types of
|
||||
every device. If we were deceived, then it won't match any of
|
||||
the types for the device anyways */
|
||||
gdkdev = gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
|
||||
|
||||
if (!gdkdev) {
|
||||
return -1; /* we don't handle it - not an XInput event */
|
||||
}
|
||||
|
||||
if (gdkdev->info.mode == GDK_MODE_DISABLED ||
|
||||
input_window->mode == GDK_EXTENSION_EVENTS_CURSOR)
|
||||
return FALSE;
|
||||
|
||||
if (gdkdev != gdk_input_current_device &&
|
||||
xevent->type != gdkdev->changenotify_type)
|
||||
{
|
||||
gdk_input_current_device = gdkdev;
|
||||
}
|
||||
|
||||
return_val = gdk_input_common_other_event (event, xevent,
|
||||
input_window, gdkdev);
|
||||
|
||||
if (return_val > 0 && event->type == GDK_MOTION_NOTIFY &&
|
||||
(!gdkdev->button_state) && (!input_window->grabbed) &&
|
||||
((event->motion.x < 0) || (event->motion.y < 0) ||
|
||||
(event->motion.x > ((GdkWindowPrivate *)window)->width) ||
|
||||
(event->motion.y > ((GdkWindowPrivate *)window)->height) ||
|
||||
gdk_input_is_obscured(input_window,event->motion.x,event->motion.y)))
|
||||
{
|
||||
#ifdef DEBUG_SWITCHING
|
||||
g_print("gdkinput: Setting core pointer to %d on motion at (%f,%f)\n",
|
||||
gdkdev->info.deviceid,event->motion.x,event->motion.y);
|
||||
g_print(" window geometry is: %dx%d\n",
|
||||
((GdkWindowPrivate *)window)->width,
|
||||
((GdkWindowPrivate *)window)->height);
|
||||
#endif
|
||||
gdk_input_gxi_set_core_pointer(gdkdev);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
return return_val;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
GList *t;
|
||||
|
||||
if (gdk_input_is_extension_device (gdkdev->info.deviceid))
|
||||
{
|
||||
if (!gdkdev->xdevice)
|
||||
{
|
||||
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
|
||||
gdk_input_gxi_select_notify (gdkdev);
|
||||
gdkdev->needs_update = 1;
|
||||
}
|
||||
if (gdkdev->needs_update && gdkdev->xdevice)
|
||||
{
|
||||
for (t = gdk_input_windows; t; t = t->next)
|
||||
gdk_input_common_select_events (((GdkInputWindow *)t->data)->window,
|
||||
gdkdev);
|
||||
gdkdev->needs_update = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev =
|
||||
gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
|
||||
|
||||
if (!gdkdev) {
|
||||
return -1; /* we don't handle it - not an XInput event */
|
||||
}
|
||||
|
||||
if (xevent->type == gdkdev->changenotify_type)
|
||||
{
|
||||
if (gdk_input_core_pointer != gdkdev)
|
||||
{
|
||||
#ifdef DEBUG_SWITCHING
|
||||
g_print("ChangeNotify from %d to %d:\n",
|
||||
gdk_input_core_pointer->info.deviceid,
|
||||
gdkdev->info.deviceid);
|
||||
#endif
|
||||
gdk_input_gxi_update_device (gdk_input_core_pointer);
|
||||
gdk_input_core_pointer = gdkdev;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
input_window = gdk_input_window_find (window);
|
||||
g_return_val_if_fail (input_window != NULL, FALSE);
|
||||
|
||||
if (!gdkdev->claimed)
|
||||
{
|
||||
if (gxid_claim_device(gdk_input_gxid_host, gdk_input_gxid_port,
|
||||
gdkdev->info.deviceid,
|
||||
GDK_WINDOW_XWINDOW(window), FALSE) !=
|
||||
GXID_RETURN_OK)
|
||||
{
|
||||
g_warning("Could not get device (is gxid running?)\n");
|
||||
return FALSE;
|
||||
}
|
||||
gdkdev->claimed = TRUE;
|
||||
}
|
||||
|
||||
if (gdkdev->xdevice && gdkdev != gdk_input_core_pointer)
|
||||
gdk_input_common_select_events(window, gdkdev);
|
||||
else
|
||||
gdkdev->needs_update = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
input_window = gdk_input_window_find (window);
|
||||
g_return_val_if_fail (input_window != NULL, FALSE);
|
||||
|
||||
if (gdkdev->claimed)
|
||||
{
|
||||
gxid_release_device(gdk_input_gxid_host, gdk_input_gxid_port,
|
||||
gdkdev->info.deviceid,
|
||||
GDK_WINDOW_XWINDOW(window));
|
||||
|
||||
gdkdev->claimed = FALSE;
|
||||
}
|
||||
|
||||
if (gdkdev->xdevice && gdkdev != gdk_input_core_pointer)
|
||||
gdk_input_common_select_events(window, gdkdev);
|
||||
else
|
||||
gdkdev->needs_update = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_is_obscured(GdkInputWindow *input_window, gdouble x, gdouble y)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<input_window->num_obscuring;i++)
|
||||
{
|
||||
GdkRectangle *rect = &input_window->obscuring[i];
|
||||
if ((x >= rect->x) &&
|
||||
(y >= rect->y) &&
|
||||
(x < rect->x + rect->width) &&
|
||||
(y < rect->y + rect->height))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If this routine needs fixing, the corresponding routine
|
||||
in gxid.c will need it too. */
|
||||
|
||||
static Window
|
||||
gdk_input_find_root_child(Display *dpy, Window w)
|
||||
{
|
||||
Window root,parent;
|
||||
Window *children;
|
||||
int nchildren;
|
||||
|
||||
parent = w;
|
||||
do
|
||||
{
|
||||
w = parent;
|
||||
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
|
||||
if (children) XFree(children);
|
||||
}
|
||||
while (parent != root);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_compute_obscuring(GdkInputWindow *input_window)
|
||||
{
|
||||
int i;
|
||||
int x,y,width,height;
|
||||
int xc,yc,widthc,heightc,border_widthc,depthc;
|
||||
|
||||
Window root,parent;
|
||||
Window *children;
|
||||
int nchildren;
|
||||
|
||||
Window w = GDK_WINDOW_XWINDOW(input_window->window);
|
||||
Window root_child = gdk_input_find_root_child(gdk_display,w);
|
||||
gdk_input_get_root_relative_geometry(gdk_display,w,&x,&y,&width,&height);
|
||||
|
||||
input_window->root_x = x;
|
||||
input_window->root_y = y;
|
||||
|
||||
XQueryTree(gdk_display,GDK_ROOT_WINDOW(),
|
||||
&root,&parent,&children,&nchildren);
|
||||
|
||||
|
||||
if (input_window->obscuring)
|
||||
g_free(input_window->obscuring);
|
||||
input_window->obscuring = 0;
|
||||
input_window->num_obscuring = 0;
|
||||
|
||||
for (i=0;i<nchildren;i++)
|
||||
if (children[i] == root_child)
|
||||
break;
|
||||
|
||||
if (i>=nchildren-1)
|
||||
{
|
||||
if (nchildren)
|
||||
XFree(children);
|
||||
return;
|
||||
}
|
||||
|
||||
input_window->obscuring = g_new(GdkRectangle,(nchildren-i-1));
|
||||
|
||||
for (i=i+1;i<nchildren;i++)
|
||||
{
|
||||
int xmin, xmax, ymin, ymax;
|
||||
XGetGeometry(gdk_display,children[i],&root,&xc,&yc,&widthc,&heightc,
|
||||
&border_widthc, &depthc);
|
||||
xmin = xc>x ? xc : x;
|
||||
xmax = (xc+widthc)<(x+width) ? xc+widthc : x+width;
|
||||
ymin = yc>y ? yc : y;
|
||||
ymax = (yc+heightc)<(y+height) ? yc+heightc : y+height;
|
||||
if ((xmin < xmax) && (ymin < ymax))
|
||||
{
|
||||
XWindowAttributes attributes;
|
||||
XGetWindowAttributes(gdk_display,children[i],&attributes);
|
||||
if (attributes.map_state == IsViewable)
|
||||
{
|
||||
GdkRectangle *rect = &input_window->obscuring[input_window->num_obscuring];
|
||||
|
||||
/* we store the whole window, not just the obscuring part */
|
||||
rect->x = xc - x;
|
||||
rect->y = yc - y;
|
||||
rect->width = widthc;
|
||||
rect->height = heightc;
|
||||
input_window->num_obscuring++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nchildren)
|
||||
XFree(children);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
|
||||
if (gdkdev == gdk_input_core_pointer)
|
||||
gdk_input_common_get_pointer (window, GDK_CORE_POINTER, x, y,
|
||||
pressure, xtilt, ytilt, mask);
|
||||
else
|
||||
gdk_input_common_get_pointer (window, deviceid, x, y,
|
||||
pressure, xtilt, ytilt, mask);
|
||||
}
|
||||
|
||||
static GdkTimeCoord *
|
||||
gdk_input_gxi_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
g_return_val_if_fail (gdkdev != NULL, NULL);
|
||||
|
||||
|
||||
if (gdkdev == gdk_input_core_pointer)
|
||||
return gdk_input_motion_events (window, GDK_CORE_POINTER, start, stop,
|
||||
nevents_return);
|
||||
else
|
||||
return gdk_input_common_motion_events (window, deviceid, start, stop,
|
||||
nevents_return);
|
||||
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_grab_pointer (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window, *new_window;
|
||||
GList *tmp_list;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
return AlreadyGrabbed;
|
||||
|
||||
if (input_window->window == window)
|
||||
new_window = input_window;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
new_window->grabbed = TRUE;
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_ungrab_pointer (guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
GList *tmp_list;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
input_window->grabbed = FALSE;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* XINPUT_GXI */
|
72
gdk/gdkinputnone.h
Normal file
72
gdk/gdkinputnone.h
Normal file
@ -0,0 +1,72 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef XINPUT_NONE
|
||||
|
||||
static void gdk_input_none_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask);
|
||||
|
||||
void
|
||||
gdk_input_init ()
|
||||
{
|
||||
gdk_input_vtable.set_mode = NULL;
|
||||
gdk_input_vtable.set_axes = NULL;
|
||||
gdk_input_vtable.motion_events = NULL;
|
||||
gdk_input_vtable.get_pointer = gdk_input_none_get_pointer;
|
||||
gdk_input_vtable.grab_pointer = NULL;
|
||||
gdk_input_vtable.ungrab_pointer = NULL;
|
||||
gdk_input_vtable.configure_event = NULL;
|
||||
gdk_input_vtable.enter_event = NULL;
|
||||
gdk_input_vtable.other_event = NULL;
|
||||
gdk_input_vtable.window_none_event = NULL;
|
||||
gdk_input_vtable.enable_window = NULL;
|
||||
gdk_input_vtable.disable_window = NULL;
|
||||
|
||||
gdk_input_devices = g_list_append (NULL, &gdk_input_core_info);
|
||||
|
||||
gdk_input_ignore_core = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_none_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
gint x_int, y_int;
|
||||
|
||||
gdk_window_get_pointer (window, &x_int, &y_int, mask);
|
||||
|
||||
if (x) *x = x_int;
|
||||
if (y) *y = y_int;
|
||||
if (pressure) *pressure = 0.5;
|
||||
if (xtilt) *xtilt = 0;
|
||||
if (ytilt) *ytilt = 0;
|
||||
}
|
||||
|
||||
#endif /* XINPUT_NONE */
|
368
gdk/gdkinputxfree.h
Normal file
368
gdk/gdkinputxfree.h
Normal file
@ -0,0 +1,368 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef XINPUT_XFREE
|
||||
|
||||
/* forward declarations */
|
||||
|
||||
static gint gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode);
|
||||
static void gdk_input_check_proximity();
|
||||
static void gdk_input_xfree_configure_event (XConfigureEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static void gdk_input_xfree_enter_event (XCrossingEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static gint gdk_input_xfree_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static gint gdk_input_xfree_enable_window(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_xfree_disable_window(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_xfree_grab_pointer (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time);
|
||||
static void gdk_input_xfree_ungrab_pointer (guint32 time);
|
||||
|
||||
void
|
||||
gdk_input_init(void)
|
||||
{
|
||||
gdk_input_vtable.set_mode = gdk_input_xfree_set_mode;
|
||||
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
|
||||
gdk_input_vtable.motion_events = gdk_input_common_motion_events;
|
||||
gdk_input_vtable.get_pointer = gdk_input_common_get_pointer;
|
||||
gdk_input_vtable.grab_pointer = gdk_input_xfree_grab_pointer;
|
||||
gdk_input_vtable.ungrab_pointer = gdk_input_xfree_ungrab_pointer;
|
||||
gdk_input_vtable.configure_event = gdk_input_xfree_configure_event;
|
||||
gdk_input_vtable.enter_event = gdk_input_xfree_enter_event;
|
||||
gdk_input_vtable.other_event = gdk_input_xfree_other_event;
|
||||
gdk_input_vtable.window_none_event = NULL;
|
||||
gdk_input_vtable.enable_window = gdk_input_xfree_enable_window;
|
||||
gdk_input_vtable.disable_window = gdk_input_xfree_disable_window;
|
||||
|
||||
gdk_input_ignore_core = FALSE;
|
||||
gdk_input_common_init(FALSE);
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GdkInputMode old_mode;
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
gdkdev = gdk_input_find_device(deviceid);
|
||||
g_return_val_if_fail (gdkdev != NULL,FALSE);
|
||||
old_mode = gdkdev->info.mode;
|
||||
|
||||
if (gdkdev->info.mode == mode)
|
||||
return TRUE;
|
||||
|
||||
gdkdev->info.mode = mode;
|
||||
|
||||
if (mode == GDK_MODE_WINDOW)
|
||||
{
|
||||
gdkdev->info.has_cursor = FALSE;
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
|
||||
gdk_input_enable_window (input_window->window, gdkdev);
|
||||
else
|
||||
if (old_mode != GDK_MODE_DISABLED)
|
||||
gdk_input_disable_window (input_window->window, gdkdev);
|
||||
}
|
||||
}
|
||||
else if (mode == GDK_MODE_SCREEN)
|
||||
{
|
||||
gdkdev->info.has_cursor = TRUE;
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
gdk_input_enable_window (((GdkInputWindow *)tmp_list->data)->window,
|
||||
gdkdev);
|
||||
}
|
||||
else /* mode == GDK_MODE_DISABLED */
|
||||
{
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (old_mode != GDK_MODE_WINDOW ||
|
||||
input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
|
||||
gdk_input_disable_window (input_window->window, gdkdev);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_check_proximity()
|
||||
{
|
||||
gint new_proximity = 0;
|
||||
GList *tmp_list = gdk_input_devices;
|
||||
|
||||
while (tmp_list && !new_proximity)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
||||
|
||||
if (gdkdev->info.mode != GDK_MODE_DISABLED
|
||||
&& gdkdev->info.deviceid != GDK_CORE_POINTER
|
||||
&& gdkdev->xdevice)
|
||||
{
|
||||
XDeviceState *state = XQueryDeviceState(GDK_DISPLAY(),
|
||||
gdkdev->xdevice);
|
||||
XInputClass *xic;
|
||||
int i;
|
||||
|
||||
xic = state->data;
|
||||
for (i=0; i<state->num_classes; i++)
|
||||
{
|
||||
if (xic->class == ValuatorClass)
|
||||
{
|
||||
XValuatorState *xvs = (XValuatorState *)xic;
|
||||
if ((xvs->mode & ProximityState) == InProximity)
|
||||
{
|
||||
new_proximity = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
xic = (XInputClass *)((char *)xic + xic->length);
|
||||
}
|
||||
}
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
gdk_input_ignore_core = new_proximity;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_xfree_configure_event (XConfigureEvent *xevent, GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
gint root_x, root_y;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_if_fail (window != NULL);
|
||||
|
||||
gdk_input_get_root_relative_geometry(GDK_DISPLAY(),GDK_WINDOW_XWINDOW(window),
|
||||
&root_x,
|
||||
&root_y, NULL, NULL);
|
||||
|
||||
input_window->root_x = root_x;
|
||||
input_window->root_y = root_y;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_xfree_enter_event (XCrossingEvent *xevent,
|
||||
GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
gint root_x, root_y;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_if_fail (window != NULL);
|
||||
|
||||
gdk_input_check_proximity();
|
||||
|
||||
gdk_input_get_root_relative_geometry(GDK_DISPLAY(),GDK_WINDOW_XWINDOW(window),
|
||||
&root_x,
|
||||
&root_y, NULL, NULL);
|
||||
|
||||
input_window->root_x = root_x;
|
||||
input_window->root_y = root_y;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
GdkDevicePrivate *gdkdev;
|
||||
gint return_val;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_val_if_fail (window != NULL, -1);
|
||||
|
||||
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
|
||||
but it's potentially faster than scanning through the types of
|
||||
every device. If we were deceived, then it won't match any of
|
||||
the types for the device anyways */
|
||||
gdkdev = gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
|
||||
|
||||
if (!gdkdev) {
|
||||
return -1; /* we don't handle it - not an XInput event */
|
||||
}
|
||||
|
||||
/* FIXME: It would be nice if we could just get rid of the events
|
||||
entirely, instead of having to ignore them */
|
||||
if (gdkdev->info.mode == GDK_MODE_DISABLED ||
|
||||
(gdkdev->info.mode == GDK_MODE_WINDOW
|
||||
&& input_window->mode == GDK_EXTENSION_EVENTS_CURSOR))
|
||||
return FALSE;
|
||||
|
||||
if (!gdk_input_ignore_core)
|
||||
gdk_input_check_proximity();
|
||||
|
||||
return_val = gdk_input_common_other_event (event, xevent,
|
||||
input_window, gdkdev);
|
||||
|
||||
if (return_val > 0 && event->type == GDK_PROXIMITY_OUT &&
|
||||
gdk_input_ignore_core)
|
||||
gdk_input_check_proximity();
|
||||
|
||||
/* Do a passive button grab. We have to be careful not to release
|
||||
an explicit grab, if any. Doubling the grab should be harmless,
|
||||
but we check anyways. */
|
||||
|
||||
/* FIXME, finding the proper events here is going to be SLOW - but
|
||||
we might have different sets for each window/device combination */
|
||||
|
||||
if (return_val> 0 && !input_window->grabbed)
|
||||
{
|
||||
if (event->type == GDK_BUTTON_PRESS)
|
||||
{
|
||||
XEventClass event_classes[6];
|
||||
gint num_classes;
|
||||
|
||||
gdk_input_common_find_events (window, gdkdev,
|
||||
((GdkWindowPrivate *)window)->extension_events,
|
||||
event_classes, &num_classes);
|
||||
|
||||
XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
|
||||
GDK_WINDOW_XWINDOW (window),
|
||||
TRUE, num_classes, event_classes,
|
||||
GrabModeAsync, GrabModeAsync, event->button.time);
|
||||
}
|
||||
else if (event->type == GDK_BUTTON_RELEASE)
|
||||
XUngrabDevice( GDK_DISPLAY(), gdkdev->xdevice, event->button.time);
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_enable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
/* FIXME: watchout, gdkdev might be core pointer, never opened */
|
||||
gdk_input_common_select_events (window, gdkdev);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
gdk_input_common_select_events (window, gdkdev);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_grab_pointer (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window, *new_window;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GList *tmp_list;
|
||||
XEventClass event_classes[6];
|
||||
gint num_classes;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
new_window = NULL;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
return AlreadyGrabbed;
|
||||
|
||||
if (input_window->window == window)
|
||||
{
|
||||
new_window = input_window;
|
||||
break;
|
||||
}
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
g_return_if_fail (new_window == NULL);
|
||||
|
||||
new_window->grabbed = TRUE;
|
||||
|
||||
tmp_list = gdk_input_devices;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
|
||||
gdkdev->xdevice && !gdkdev->button_state)
|
||||
{
|
||||
gdk_input_common_find_events (window, gdkdev,
|
||||
((GdkWindowPrivate *)window)->extension_events,
|
||||
event_classes, &num_classes);
|
||||
|
||||
/* FIXME: we should do something on failure */
|
||||
XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
|
||||
GDK_WINDOW_XWINDOW (window),
|
||||
TRUE, num_classes, event_classes,
|
||||
GrabModeAsync, GrabModeAsync, time);
|
||||
}
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_xfree_ungrab_pointer (guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GList *tmp_list;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
break;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
if (tmp_list) /* we found a grabbed window */
|
||||
{
|
||||
input_window->grabbed = FALSE;
|
||||
|
||||
tmp_list = gdk_input_devices;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
|
||||
gdkdev->xdevice && !gdkdev->button_state)
|
||||
{
|
||||
XUngrabDevice( gdk_display, gdkdev->xdevice, time);
|
||||
}
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* XINPUT_XFREE */
|
657
gdk/gdkpixmap.c
Normal file
657
gdk/gdkpixmap.c
Normal file
@ -0,0 +1,657 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include "../config.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *color_string;
|
||||
GdkColor color;
|
||||
gint transparent;
|
||||
} _GdkPixmapColor;
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_new (GdkWindow *window,
|
||||
gint width,
|
||||
gint height,
|
||||
gint depth)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkWindowPrivate *private;
|
||||
GdkWindowPrivate *window_private;
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
if (depth == -1)
|
||||
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
|
||||
|
||||
private = g_new (GdkWindowPrivate, 1);
|
||||
pixmap = (GdkPixmap*) private;
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
|
||||
private->xdisplay = window_private->xdisplay;
|
||||
private->window_type = GDK_WINDOW_PIXMAP;
|
||||
private->xwindow = XCreatePixmap (private->xdisplay, window_private->xwindow,
|
||||
width, height, depth);
|
||||
private->parent = NULL;
|
||||
private->x = 0;
|
||||
private->y = 0;
|
||||
private->width = width;
|
||||
private->height = height;
|
||||
private->resize_count = 0;
|
||||
private->ref_count = 1;
|
||||
private->destroyed = 0;
|
||||
|
||||
gdk_xid_table_insert (&private->xwindow, pixmap);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap *
|
||||
gdk_bitmap_create_from_data (GdkWindow *window,
|
||||
gchar *data,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkWindowPrivate *private;
|
||||
GdkWindowPrivate *window_private;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
private = g_new (GdkWindowPrivate, 1);
|
||||
pixmap = (GdkPixmap*) private;
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
|
||||
private->parent = NULL;
|
||||
private->xdisplay = window_private->xdisplay;
|
||||
private->window_type = GDK_WINDOW_PIXMAP;
|
||||
private->x = 0;
|
||||
private->y = 0;
|
||||
private->width = width;
|
||||
private->height = height;
|
||||
private->resize_count = 0;
|
||||
private->ref_count = 1;
|
||||
private->destroyed = FALSE;
|
||||
|
||||
private->xwindow = XCreateBitmapFromData (private->xdisplay,
|
||||
window_private->xwindow,
|
||||
data, width, height);
|
||||
|
||||
gdk_xid_table_insert (&private->xwindow, pixmap);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_data (GdkWindow *window,
|
||||
gchar *data,
|
||||
gint width,
|
||||
gint height,
|
||||
gint depth,
|
||||
GdkColor *fg,
|
||||
GdkColor *bg)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkWindowPrivate *private;
|
||||
GdkWindowPrivate *window_private;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
g_return_val_if_fail (fg != NULL, NULL);
|
||||
g_return_val_if_fail (bg != NULL, NULL);
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
if (depth == -1)
|
||||
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
|
||||
|
||||
private = g_new (GdkWindowPrivate, 1);
|
||||
pixmap = (GdkPixmap*) private;
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
|
||||
private->parent = NULL;
|
||||
private->xdisplay = window_private->xdisplay;
|
||||
private->window_type = GDK_WINDOW_PIXMAP;
|
||||
private->x = 0;
|
||||
private->y = 0;
|
||||
private->width = width;
|
||||
private->height = height;
|
||||
private->resize_count = 0;
|
||||
private->ref_count = 1;
|
||||
private->destroyed = FALSE;
|
||||
|
||||
private->xwindow = XCreatePixmapFromBitmapData (private->xdisplay,
|
||||
window_private->xwindow,
|
||||
data, width, height,
|
||||
fg->pixel, bg->pixel, depth);
|
||||
|
||||
gdk_xid_table_insert (&private->xwindow, pixmap);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_pixmap_seek_string (FILE *infile,
|
||||
const gchar *str,
|
||||
gint skip_comments)
|
||||
{
|
||||
char instr[1024];
|
||||
|
||||
while (!feof (infile))
|
||||
{
|
||||
fscanf (infile, "%s", instr);
|
||||
if (skip_comments == TRUE && strcmp (instr, "/*") == 0)
|
||||
{
|
||||
fscanf (infile, "%s", instr);
|
||||
while (!feof (infile) && strcmp (instr, "*/") != 0)
|
||||
fscanf (infile, "%s", instr);
|
||||
fscanf(infile, "%s", instr);
|
||||
}
|
||||
if (strcmp (instr, str)==0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_pixmap_seek_char (FILE *infile,
|
||||
gchar c)
|
||||
{
|
||||
gchar b, oldb;
|
||||
|
||||
while (!feof (infile))
|
||||
{
|
||||
fscanf(infile, "%c", &b);
|
||||
if (c != b && b == '/')
|
||||
{
|
||||
fscanf (infile, "%c", &b);
|
||||
if (b == '*')
|
||||
{
|
||||
oldb = b;
|
||||
while (!feof (infile) && !(oldb == '*' && b == '/'))
|
||||
{
|
||||
oldb = b;
|
||||
fscanf (infile, "%c", &b);
|
||||
}
|
||||
fscanf (infile, "%c", &b);
|
||||
}
|
||||
}
|
||||
if (c == b)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_pixmap_read_string (FILE *infile,
|
||||
gchar **buffer,
|
||||
int *buffer_size)
|
||||
{
|
||||
gchar c;
|
||||
gint cnt = 0;
|
||||
|
||||
if ((*buffer) == NULL)
|
||||
{
|
||||
(*buffer_size) = 10 * sizeof (gchar);
|
||||
(*buffer) = (gchar *) malloc (*buffer_size);
|
||||
}
|
||||
|
||||
do
|
||||
fscanf (infile, "%c", &c);
|
||||
while (!feof (infile) && c != '"');
|
||||
|
||||
if (c != '"')
|
||||
return FALSE;
|
||||
|
||||
while (!feof (infile))
|
||||
{
|
||||
fscanf (infile, "%c", &c);
|
||||
|
||||
if (cnt == (*buffer_size))
|
||||
{
|
||||
(*buffer_size) *= 2;
|
||||
(*buffer) = (gchar *) realloc ((*buffer), *buffer_size);
|
||||
}
|
||||
|
||||
if (c != '"')
|
||||
(*buffer)[cnt++] = c;
|
||||
else
|
||||
{
|
||||
(*buffer)[cnt++] = 0;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gchar*
|
||||
gdk_pixmap_skip_whitespaces (gchar *buffer)
|
||||
{
|
||||
gint32 index = 0;
|
||||
|
||||
while (buffer[index] != 0 && (buffer[index] == 0x20 || buffer[index] == 0x09))
|
||||
index++;
|
||||
|
||||
return &buffer[index];
|
||||
}
|
||||
|
||||
gchar*
|
||||
gdk_pixmap_skip_string (gchar *buffer)
|
||||
{
|
||||
gint32 index = 0;
|
||||
|
||||
while (buffer[index] != 0 && buffer[index] != 0x20 && buffer[index] != 0x09)
|
||||
index++;
|
||||
|
||||
return &buffer[index];
|
||||
}
|
||||
|
||||
gchar*
|
||||
gdk_pixmap_extract_color (gchar *buffer)
|
||||
{
|
||||
gint counter, finished = FALSE, numnames;
|
||||
gchar *ptr = NULL, ch, temp[128];
|
||||
gchar color[128], *retcol;
|
||||
|
||||
counter = 0;
|
||||
while (ptr == NULL)
|
||||
{
|
||||
if (buffer[counter] == 'c')
|
||||
{
|
||||
ch = buffer[counter + 1];
|
||||
if (ch == 0x20 || ch == 0x09)
|
||||
ptr = &buffer[counter + 1];
|
||||
}
|
||||
else if (buffer[counter] == 0)
|
||||
return NULL;
|
||||
|
||||
counter++;
|
||||
}
|
||||
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
ptr = gdk_pixmap_skip_whitespaces (ptr);
|
||||
|
||||
if (ptr[0] == 0)
|
||||
return NULL;
|
||||
else if (ptr[0] == '#')
|
||||
{
|
||||
retcol = g_new(gchar, strlen (ptr) + 1);
|
||||
strcpy (retcol, ptr);
|
||||
return retcol;
|
||||
}
|
||||
|
||||
color[0] = 0;
|
||||
numnames = 0;
|
||||
|
||||
while (finished == FALSE)
|
||||
{
|
||||
sscanf (ptr, "%s", temp);
|
||||
|
||||
if ((gint)ptr[0] == 0 || strcmp ("s", temp) == 0 || strcmp ("m", temp) == 0 ||
|
||||
strcmp ("g", temp) == 0 || strcmp ("g4", temp) == 0)
|
||||
finished = TRUE;
|
||||
else
|
||||
{
|
||||
if (numnames > 0)
|
||||
strcat (color, " ");
|
||||
strcat (color, temp);
|
||||
ptr = gdk_pixmap_skip_string (ptr);
|
||||
ptr = gdk_pixmap_skip_whitespaces (ptr);
|
||||
numnames++;
|
||||
}
|
||||
}
|
||||
|
||||
retcol = g_new(gchar, strlen (color) + 1);
|
||||
strcpy (retcol, color);
|
||||
return retcol;
|
||||
}
|
||||
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_xpm (GdkWindow *window,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
const gchar *filename)
|
||||
{
|
||||
FILE *infile = NULL;
|
||||
GdkPixmap *pixmap = NULL;
|
||||
GdkImage *image = NULL;
|
||||
GdkColormap *colormap;
|
||||
GdkVisual *visual;
|
||||
GdkGC *gc;
|
||||
GdkColor tmp_color;
|
||||
gint width, height, num_cols, cpp, cnt, n, ns, xcnt, ycnt;
|
||||
gchar *buffer = NULL, *color_name = NULL, pixel_str[32];
|
||||
guint buffer_size = 0;
|
||||
_GdkPixmapColor *colors = NULL, *color = NULL;
|
||||
gulong index;
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
infile = fopen (filename, "rb");
|
||||
if (infile != NULL)
|
||||
{
|
||||
if (gdk_pixmap_seek_string (infile, "XPM", FALSE) == TRUE)
|
||||
{
|
||||
if (gdk_pixmap_seek_char (infile,'{') == TRUE)
|
||||
{
|
||||
gdk_pixmap_seek_char (infile, '"');
|
||||
fseek (infile, -1, SEEK_CUR);
|
||||
gdk_pixmap_read_string (infile, &buffer, &buffer_size);
|
||||
|
||||
sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp);
|
||||
|
||||
colors = g_new(_GdkPixmapColor, num_cols);
|
||||
|
||||
colormap = gdk_window_get_colormap (window);
|
||||
visual = gdk_window_get_visual (window);
|
||||
|
||||
if (transparent_color == NULL)
|
||||
{
|
||||
gdk_color_white (colormap, &tmp_color);
|
||||
transparent_color = &tmp_color;
|
||||
}
|
||||
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
{
|
||||
gdk_pixmap_seek_char (infile, '"');
|
||||
fseek (infile, -1, SEEK_CUR);
|
||||
gdk_pixmap_read_string (infile, &buffer, &buffer_size);
|
||||
|
||||
colors[cnt].color_string = g_new(gchar, cpp + 1);
|
||||
for (n = 0; n < cpp; n++)
|
||||
colors[cnt].color_string[n] = buffer[n];
|
||||
colors[cnt].color_string[n] = 0;
|
||||
colors[cnt].transparent = FALSE;
|
||||
|
||||
if (color_name != NULL)
|
||||
g_free (color_name);
|
||||
|
||||
color_name = gdk_pixmap_extract_color (&buffer[cpp]);
|
||||
|
||||
if (color_name != NULL)
|
||||
{
|
||||
if (gdk_color_parse (color_name, &colors[cnt].color) == FALSE)
|
||||
{
|
||||
colors[cnt].color = *transparent_color;
|
||||
colors[cnt].transparent = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
colors[cnt].color = *transparent_color;
|
||||
colors[cnt].transparent = TRUE;
|
||||
}
|
||||
|
||||
gdk_color_alloc (colormap, &colors[cnt].color);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
image = gdk_image_new (GDK_IMAGE_FASTEST, visual, width, height);
|
||||
|
||||
gc = NULL;
|
||||
if (mask)
|
||||
{
|
||||
*mask = gdk_pixmap_new (window, width, height, 1);
|
||||
gc = gdk_gc_new (*mask);
|
||||
|
||||
gdk_color_black (colormap, &tmp_color);
|
||||
gdk_gc_set_foreground (gc, &tmp_color);
|
||||
gdk_draw_rectangle (*mask, gc, TRUE, 0, 0, -1, -1);
|
||||
|
||||
gdk_color_white (colormap, &tmp_color);
|
||||
gdk_gc_set_foreground (gc, &tmp_color);
|
||||
}
|
||||
|
||||
for (ycnt = 0; ycnt < height; ycnt++)
|
||||
{
|
||||
gdk_pixmap_read_string (infile, &buffer, &buffer_size);
|
||||
|
||||
for (n = 0, cnt = 0, xcnt = 0; n < (width * cpp); n += cpp, xcnt++)
|
||||
{
|
||||
strncpy (pixel_str, &buffer[n], cpp);
|
||||
pixel_str[cpp] = 0;
|
||||
color = NULL;
|
||||
ns = 0;
|
||||
|
||||
while (color == NULL)
|
||||
{
|
||||
if (strcmp (pixel_str, colors[ns].color_string) == 0)
|
||||
color = &colors[ns];
|
||||
else
|
||||
ns++;
|
||||
}
|
||||
|
||||
gdk_image_put_pixel (image, xcnt, ycnt, color->color.pixel);
|
||||
|
||||
if (mask && color->transparent)
|
||||
{
|
||||
if (cnt < xcnt)
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
cnt = xcnt + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask && (cnt < xcnt))
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
gdk_gc_destroy (gc);
|
||||
|
||||
pixmap = gdk_pixmap_new (window, width, height, visual->depth);
|
||||
|
||||
gc = gdk_gc_new (pixmap);
|
||||
gdk_gc_set_foreground (gc, transparent_color);
|
||||
gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
|
||||
gdk_gc_destroy (gc);
|
||||
gdk_image_destroy (image);
|
||||
}
|
||||
}
|
||||
|
||||
fclose (infile);
|
||||
free (buffer);
|
||||
|
||||
if (colors != NULL)
|
||||
{
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
g_free (colors[cnt].color_string);
|
||||
g_free (colors);
|
||||
}
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_xpm_d (GdkWindow *window,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
gchar **data)
|
||||
{
|
||||
GdkPixmap *pixmap = NULL;
|
||||
GdkImage *image = NULL;
|
||||
GdkColormap *colormap;
|
||||
GdkVisual *visual;
|
||||
GdkGC *gc;
|
||||
GdkColor tmp_color;
|
||||
gint width, height, num_cols, cpp, cnt, n, ns, xcnt, ycnt, i;
|
||||
gchar *buffer, *color_name = NULL, pixel_str[32];
|
||||
_GdkPixmapColor *colors = NULL, *color = NULL;
|
||||
gulong index;
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
i = 0;
|
||||
buffer = data[i++];
|
||||
sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp);
|
||||
|
||||
colors = g_new(_GdkPixmapColor, num_cols);
|
||||
|
||||
colormap = gdk_window_get_colormap (window);
|
||||
visual = gdk_window_get_visual (window);
|
||||
|
||||
if (transparent_color == NULL)
|
||||
{
|
||||
gdk_color_white (colormap, &tmp_color);
|
||||
transparent_color = &tmp_color;
|
||||
}
|
||||
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
{
|
||||
buffer = data[i++];
|
||||
|
||||
colors[cnt].color_string = g_new(gchar, cpp + 1);
|
||||
for (n = 0; n < cpp; n++)
|
||||
colors[cnt].color_string[n] = buffer[n];
|
||||
colors[cnt].color_string[n] = 0;
|
||||
colors[cnt].transparent = FALSE;
|
||||
|
||||
if (color_name != NULL)
|
||||
g_free (color_name);
|
||||
|
||||
color_name = gdk_pixmap_extract_color (&buffer[cpp]);
|
||||
|
||||
if (color_name != NULL)
|
||||
{
|
||||
if (gdk_color_parse (color_name, &colors[cnt].color) == FALSE)
|
||||
{
|
||||
colors[cnt].color = *transparent_color;
|
||||
colors[cnt].transparent = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
colors[cnt].color = *transparent_color;
|
||||
colors[cnt].transparent = TRUE;
|
||||
}
|
||||
|
||||
gdk_color_alloc (colormap, &colors[cnt].color);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
image = gdk_image_new (GDK_IMAGE_FASTEST, visual, width, height);
|
||||
|
||||
gc = NULL;
|
||||
if (mask)
|
||||
{
|
||||
*mask = gdk_pixmap_new (window, width, height, 1);
|
||||
gc = gdk_gc_new (*mask);
|
||||
|
||||
gdk_color_black (colormap, &tmp_color);
|
||||
gdk_gc_set_foreground (gc, &tmp_color);
|
||||
gdk_draw_rectangle (*mask, gc, TRUE, 0, 0, -1, -1);
|
||||
|
||||
gdk_color_white (colormap, &tmp_color);
|
||||
gdk_gc_set_foreground (gc, &tmp_color);
|
||||
}
|
||||
|
||||
for (ycnt = 0; ycnt < height; ycnt++)
|
||||
{
|
||||
buffer = data[i++];
|
||||
|
||||
for (n = 0, cnt = 0, xcnt = 0; n < (width * cpp); n += cpp, xcnt++)
|
||||
{
|
||||
strncpy (pixel_str, &buffer[n], cpp);
|
||||
pixel_str[cpp] = 0;
|
||||
color = NULL;
|
||||
ns = 0;
|
||||
|
||||
while (color == NULL)
|
||||
{
|
||||
if (strcmp (pixel_str, colors[ns].color_string) == 0)
|
||||
color = &colors[ns];
|
||||
else
|
||||
ns++;
|
||||
}
|
||||
|
||||
gdk_image_put_pixel (image, xcnt, ycnt, color->color.pixel);
|
||||
|
||||
if (mask && color->transparent)
|
||||
{
|
||||
if (cnt < xcnt)
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
cnt = xcnt + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask && (cnt < xcnt))
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
gdk_gc_destroy (gc);
|
||||
|
||||
pixmap = gdk_pixmap_new (window, width, height, visual->depth);
|
||||
|
||||
gc = gdk_gc_new (pixmap);
|
||||
gdk_gc_set_foreground (gc, transparent_color);
|
||||
gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
|
||||
gdk_gc_destroy (gc);
|
||||
gdk_image_destroy (image);
|
||||
|
||||
if (colors != NULL)
|
||||
{
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
g_free (colors[cnt].color_string);
|
||||
g_free (colors);
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_pixmap_destroy (GdkPixmap *pixmap)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
|
||||
g_return_if_fail (pixmap != NULL);
|
||||
|
||||
private = (GdkPixmapPrivate*) pixmap;
|
||||
if (private->ref_count <= 0)
|
||||
{
|
||||
XFreePixmap (private->xdisplay, private->xwindow);
|
||||
gdk_xid_table_remove (private->xwindow);
|
||||
g_free (pixmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
private->ref_count -= 1;
|
||||
}
|
||||
}
|
197
gdk/gdkprivate.h
Normal file
197
gdk/gdkprivate.h
Normal file
@ -0,0 +1,197 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef __GDK_PRIVATE_H__
|
||||
#define __GDK_PRIVATE_H__
|
||||
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
#define DND_PROTOCOL_VERSION 0
|
||||
|
||||
#define gdk_window_lookup(xid) ((GdkWindow*) gdk_xid_table_lookup (xid))
|
||||
#define gdk_pixmap_lookup(xid) ((GdkPixmap*) gdk_xid_table_lookup (xid))
|
||||
#define gdk_font_lookup(xid) ((GdkFont*) gdk_xid_table_lookup (xid))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
typedef struct _GdkWindowPrivate GdkWindowPrivate;
|
||||
typedef struct _GdkWindowPrivate GdkPixmapPrivate;
|
||||
typedef struct _GdkImagePrivate GdkImagePrivate;
|
||||
typedef struct _GdkGCPrivate GdkGCPrivate;
|
||||
typedef struct _GdkColormapPrivate GdkColormapPrivate;
|
||||
typedef struct _GdkVisualPrivate GdkVisualPrivate;
|
||||
typedef struct _GdkFontPrivate GdkFontPrivate;
|
||||
typedef struct _GdkCursorPrivate GdkCursorPrivate;
|
||||
|
||||
|
||||
struct _GdkWindowPrivate
|
||||
{
|
||||
GdkWindow window;
|
||||
GdkWindow *parent;
|
||||
Window xwindow;
|
||||
Display *xdisplay;
|
||||
gint16 x;
|
||||
gint16 y;
|
||||
guint16 width;
|
||||
guint16 height;
|
||||
guint8 resize_count;
|
||||
guint8 ref_count;
|
||||
guint8 window_type;
|
||||
guint8 destroyed : 2;
|
||||
guint8 dnd_drag_enabled : 1,
|
||||
dnd_drag_datashow : 1,
|
||||
dnd_drag_destructive_op : 1,
|
||||
dnd_drag_accepted : 1,
|
||||
dnd_drop_enabled : 1,
|
||||
dnd_drop_destructive_op : 1;
|
||||
GdkAtom dnd_drag_data_type, *dnd_drag_data_typesavail;
|
||||
guint dnd_drag_data_numtypesavail;
|
||||
/* We have to turn on MotionMask/EnterWindowMask/LeaveWindowMask
|
||||
during drags, then set it back to what it was after */
|
||||
glong dnd_drag_savedeventmask, dnd_drag_eventmask;
|
||||
GdkAtom *dnd_drop_data_typesavail;
|
||||
guint dnd_drop_data_numtypesavail;
|
||||
/* need to allow custom drag/drop cursors */
|
||||
|
||||
gint extension_events;
|
||||
};
|
||||
|
||||
struct _GdkImagePrivate
|
||||
{
|
||||
GdkImage image;
|
||||
XImage *ximage;
|
||||
Display *xdisplay;
|
||||
gpointer x_shm_info;
|
||||
|
||||
void (*image_put) (GdkDrawable *window,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height);
|
||||
};
|
||||
|
||||
struct _GdkGCPrivate
|
||||
{
|
||||
GdkGC gc;
|
||||
GC xgc;
|
||||
Display *xdisplay;
|
||||
};
|
||||
|
||||
struct _GdkColormapPrivate
|
||||
{
|
||||
GdkColormap colormap;
|
||||
Colormap xcolormap;
|
||||
Display *xdisplay;
|
||||
GdkVisual *visual;
|
||||
gint private_val;
|
||||
gint next_color;
|
||||
gint ref_count;
|
||||
};
|
||||
|
||||
struct _GdkVisualPrivate
|
||||
{
|
||||
GdkVisual visual;
|
||||
Visual *xvisual;
|
||||
};
|
||||
|
||||
struct _GdkFontPrivate
|
||||
{
|
||||
GdkFont font;
|
||||
/* XFontStruct *xfont; */
|
||||
/* generic pointer point to XFontStruct or XFontSet */
|
||||
gpointer xfont;
|
||||
Display *xdisplay;
|
||||
gint ref_count;
|
||||
};
|
||||
|
||||
struct _GdkCursorPrivate
|
||||
{
|
||||
GdkCursor cursor;
|
||||
Cursor xcursor;
|
||||
Display *xdisplay;
|
||||
};
|
||||
|
||||
struct _GdkDndGlobals {
|
||||
GdkAtom gdk_XdeEnter, gdk_XdeLeave, gdk_XdeRequest;
|
||||
GdkAtom gdk_XdeDataAvailable, gdk_XdeDataShow, gdk_XdeCancel;
|
||||
GdkAtom gdk_XdeTypelist;
|
||||
Cursor gdk_cursor_dragdefault, gdk_cursor_dragok;
|
||||
GdkWindow **drag_startwindows;
|
||||
guint drag_numwindows;
|
||||
guint8 drag_really;
|
||||
GdkPoint drag_dropcoords;
|
||||
};
|
||||
typedef struct _GdkDndGlobals GdkDndGlobals;
|
||||
|
||||
void gdk_window_init (void);
|
||||
void gdk_visual_init (void);
|
||||
|
||||
void gdk_image_init (void);
|
||||
void gdk_image_exit (void);
|
||||
|
||||
GdkColormap* gdk_colormap_lookup (Colormap xcolormap);
|
||||
GdkVisual* gdk_visual_lookup (Visual *xvisual);
|
||||
|
||||
void gdk_window_real_destroy (GdkWindow *window);
|
||||
void gdk_window_add_colormap_windows (GdkWindow *window);
|
||||
|
||||
void gdk_xid_table_insert (XID *xid,
|
||||
gpointer data);
|
||||
void gdk_xid_table_remove (XID xid);
|
||||
gpointer gdk_xid_table_lookup (XID xid);
|
||||
|
||||
|
||||
extern gint gdk_debug_level;
|
||||
extern gint gdk_show_events;
|
||||
extern gint gdk_use_xshm;
|
||||
extern gint gdk_stack_trace;
|
||||
extern gchar *gdk_display_name;
|
||||
extern Display *gdk_display;
|
||||
extern gint gdk_screen;
|
||||
extern Window gdk_root_window;
|
||||
extern Window gdk_leader_window;
|
||||
extern GdkWindowPrivate gdk_root_parent;
|
||||
extern Atom gdk_wm_delete_window;
|
||||
extern Atom gdk_wm_take_focus;
|
||||
extern Atom gdk_wm_protocols;
|
||||
extern Atom gdk_wm_window_protocols[];
|
||||
extern Atom gdk_selection_property;
|
||||
extern GdkDndGlobals gdk_dnd;
|
||||
extern GdkWindow *selection_owner[];
|
||||
extern gchar *gdk_progname;
|
||||
extern gchar *gdk_progclass;
|
||||
extern gint gdk_error_code;
|
||||
extern gint gdk_error_warnings;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif /* __GDK_PRIVATE_H__ */
|
194
gdk/gdkproperty.c
Normal file
194
gdk/gdkproperty.c
Normal file
@ -0,0 +1,194 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <string.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
GdkAtom
|
||||
gdk_atom_intern (const gchar *atom_name,
|
||||
gint only_if_exists)
|
||||
{
|
||||
return XInternAtom (gdk_display, atom_name, only_if_exists);
|
||||
}
|
||||
|
||||
gchar *
|
||||
gdk_atom_name (GdkAtom atom)
|
||||
{
|
||||
gchar *t;
|
||||
gchar *name;
|
||||
|
||||
/* If this atom doesn't exist, we'll die with an X error unless
|
||||
we take precautions */
|
||||
|
||||
gdk_error_warnings = 0;
|
||||
t = XGetAtomName (gdk_display, atom);
|
||||
gdk_error_warnings = 1;
|
||||
|
||||
if (gdk_error_code == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = g_strdup (t);
|
||||
XFree (t);
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_property_get (GdkWindow *window,
|
||||
GdkAtom property,
|
||||
GdkAtom type,
|
||||
gulong offset,
|
||||
gulong length,
|
||||
gint pdelete,
|
||||
GdkAtom *actual_property_type,
|
||||
gint *actual_format_type,
|
||||
gint *actual_length,
|
||||
guchar **data)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
Display *xdisplay;
|
||||
Window xwindow;
|
||||
Atom ret_prop_type;
|
||||
gint ret_format;
|
||||
gulong ret_nitems;
|
||||
gulong ret_bytes_after;
|
||||
gulong ret_length;
|
||||
guchar *ret_data;
|
||||
|
||||
if (window)
|
||||
{
|
||||
private = (GdkWindowPrivate*) window;
|
||||
xdisplay = private->xdisplay;
|
||||
xwindow = private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdisplay = gdk_display;
|
||||
xwindow = gdk_root_window;
|
||||
}
|
||||
|
||||
XGetWindowProperty (xdisplay, xwindow, property,
|
||||
offset, (length + 3) / 4, pdelete,
|
||||
type, &ret_prop_type, &ret_format,
|
||||
&ret_nitems, &ret_bytes_after,
|
||||
&ret_data);
|
||||
|
||||
if ((ret_prop_type == None) && (ret_format == 0))
|
||||
return FALSE;
|
||||
|
||||
if (actual_property_type)
|
||||
*actual_property_type = ret_prop_type;
|
||||
if (actual_format_type)
|
||||
*actual_format_type = ret_format;
|
||||
|
||||
if (ret_prop_type != property)
|
||||
{
|
||||
XFree (ret_data);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* FIXME: ignoring bytes_after could have very bad effects */
|
||||
|
||||
if (data)
|
||||
{
|
||||
switch (ret_format)
|
||||
{
|
||||
case 8:
|
||||
ret_length = ret_nitems;
|
||||
break;
|
||||
case 16:
|
||||
ret_length = 2 * ret_nitems;
|
||||
break;
|
||||
case 32:
|
||||
ret_length = 4 * ret_nitems;
|
||||
break;
|
||||
default:
|
||||
g_warning ("unknown property return format: %d", ret_format);
|
||||
XFree (ret_data);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*data = g_new (guchar, ret_length);
|
||||
memcpy (*data, ret_data, ret_length);
|
||||
if (actual_length)
|
||||
*actual_length = ret_length;
|
||||
}
|
||||
|
||||
XFree (ret_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_property_change (GdkWindow *window,
|
||||
GdkAtom property,
|
||||
GdkAtom type,
|
||||
gint format,
|
||||
GdkPropMode mode,
|
||||
guchar *data,
|
||||
gint nelements)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
Display *xdisplay;
|
||||
Window xwindow;
|
||||
|
||||
if (window)
|
||||
{
|
||||
private = (GdkWindowPrivate*) window;
|
||||
xdisplay = private->xdisplay;
|
||||
xwindow = private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdisplay = gdk_display;
|
||||
xwindow = gdk_root_window;
|
||||
}
|
||||
|
||||
XChangeProperty (xdisplay, xwindow, property, type,
|
||||
format, mode, data, nelements);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_property_delete (GdkWindow *window,
|
||||
GdkAtom property)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
Display *xdisplay;
|
||||
Window xwindow;
|
||||
|
||||
if (window)
|
||||
{
|
||||
private = (GdkWindowPrivate*) window;
|
||||
xdisplay = private->xdisplay;
|
||||
xwindow = private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdisplay = gdk_display;
|
||||
xwindow = gdk_root_window;
|
||||
}
|
||||
|
||||
XDeleteProperty (xdisplay, xwindow, property);
|
||||
}
|
83
gdk/gdkrectangle.c
Normal file
83
gdk/gdkrectangle.c
Normal file
@ -0,0 +1,83 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include "gdk.h"
|
||||
|
||||
|
||||
gint
|
||||
gdk_rectangle_intersect (GdkRectangle *src1,
|
||||
GdkRectangle *src2,
|
||||
GdkRectangle *dest)
|
||||
{
|
||||
GdkRectangle *temp;
|
||||
gint src1_x2, src1_y2;
|
||||
gint src2_x2, src2_y2;
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (src1 != NULL, FALSE);
|
||||
g_return_val_if_fail (src2 != NULL, FALSE);
|
||||
g_return_val_if_fail (dest != NULL, FALSE);
|
||||
|
||||
return_val = FALSE;
|
||||
|
||||
if (src2->x < src1->x)
|
||||
{
|
||||
temp = src1;
|
||||
src1 = src2;
|
||||
src2 = temp;
|
||||
}
|
||||
dest->x = src2->x;
|
||||
|
||||
src1_x2 = src1->x + src1->width;
|
||||
src2_x2 = src2->x + src2->width;
|
||||
|
||||
if (src2->x < src1_x2)
|
||||
{
|
||||
if (src1_x2 < src2_x2)
|
||||
dest->width = src1_x2 - dest->x;
|
||||
else
|
||||
dest->width = src2_x2 - dest->x;
|
||||
|
||||
if (src2->y < src1->y)
|
||||
{
|
||||
temp = src1;
|
||||
src1 = src2;
|
||||
src2 = temp;
|
||||
}
|
||||
dest->y = src2->y;
|
||||
|
||||
src1_y2 = src1->y + src1->height;
|
||||
src2_y2 = src2->y + src2->height;
|
||||
|
||||
if (src2->y < src1_y2)
|
||||
{
|
||||
return_val = TRUE;
|
||||
|
||||
if (src1_y2 < src2_y2)
|
||||
dest->height = src1_y2 - dest->y;
|
||||
else
|
||||
dest->height = src2_y2 - dest->y;
|
||||
|
||||
if (dest->height == 0)
|
||||
return_val = FALSE;
|
||||
if (dest->width == 0)
|
||||
return_val = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
168
gdk/gdkselection.c
Normal file
168
gdk/gdkselection.c
Normal file
@ -0,0 +1,168 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <string.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
gint
|
||||
gdk_selection_owner_set (GdkWindow *owner,
|
||||
GdkAtom selection,
|
||||
guint32 time,
|
||||
gint send_event)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
Display *xdisplay;
|
||||
Window xwindow;
|
||||
|
||||
if (owner)
|
||||
{
|
||||
private = (GdkWindowPrivate*) owner;
|
||||
xdisplay = private->xdisplay;
|
||||
xwindow = private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdisplay = gdk_display;
|
||||
xwindow = None;
|
||||
}
|
||||
|
||||
XSetSelectionOwner (xdisplay, selection, xwindow, time);
|
||||
|
||||
return (XGetSelectionOwner (xdisplay, selection) == xwindow);
|
||||
}
|
||||
|
||||
GdkWindow*
|
||||
gdk_selection_owner_get (GdkAtom selection)
|
||||
{
|
||||
Window xwindow;
|
||||
|
||||
xwindow = XGetSelectionOwner (gdk_display, selection);
|
||||
if (xwindow == None)
|
||||
return NULL;
|
||||
|
||||
return gdk_window_lookup (xwindow);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_selection_convert (GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
|
||||
g_return_if_fail (requestor != NULL);
|
||||
|
||||
private = (GdkWindowPrivate*) requestor;
|
||||
|
||||
XConvertSelection (private->xdisplay, selection, target,
|
||||
gdk_selection_property, private->xwindow, time);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_selection_property_get (GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *ret_type,
|
||||
gint *ret_format)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
gulong nitems;
|
||||
gulong nbytes;
|
||||
gulong length;
|
||||
GdkAtom prop_type;
|
||||
gint prop_format;
|
||||
guchar *t;
|
||||
|
||||
g_return_val_if_fail (requestor != NULL, 0);
|
||||
|
||||
/* If retrieved chunks are typically small, (and the ICCM says the
|
||||
should be) it would be a win to try first with a buffer of
|
||||
moderate length, to avoid two round trips to the server */
|
||||
|
||||
private = (GdkWindowPrivate*) requestor;
|
||||
|
||||
XGetWindowProperty (private->xdisplay, private->xwindow,
|
||||
gdk_selection_property, 0, 0, False,
|
||||
AnyPropertyType, &prop_type, &prop_format,
|
||||
&nitems, &nbytes, &t);
|
||||
|
||||
if (ret_type)
|
||||
*ret_type = prop_type;
|
||||
if (ret_format)
|
||||
*ret_format = prop_format;
|
||||
|
||||
if (prop_type == None)
|
||||
{
|
||||
*data = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
XFree (t);
|
||||
|
||||
/* Add on an extra byte to handle null termination. X guarantees
|
||||
that t will be 1 longer than nbytes and null terminated */
|
||||
length = nbytes + 1;
|
||||
|
||||
/* We can't delete the selection here, because it might be the INCR
|
||||
protocol, in which case the client has to make sure they'll be
|
||||
notified of PropertyChange events _before_ the property is deleted.
|
||||
Otherwise there's no guarantee we'll win the race ... */
|
||||
XGetWindowProperty (private->xdisplay, private->xwindow,
|
||||
gdk_selection_property, 0, (nbytes + 3) / 4, False,
|
||||
AnyPropertyType, &prop_type, &prop_format,
|
||||
&nitems, &nbytes, &t);
|
||||
|
||||
if (prop_type != None)
|
||||
{
|
||||
*data = g_new (guchar, length);
|
||||
memcpy (*data, t, length);
|
||||
XFree (t);
|
||||
return length-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*data = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gdk_selection_send_notify (guint32 requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time)
|
||||
{
|
||||
XSelectionEvent xevent;
|
||||
|
||||
xevent.type = SelectionNotify;
|
||||
xevent.serial = 0;
|
||||
xevent.send_event = True;
|
||||
xevent.display = gdk_display;
|
||||
xevent.requestor = requestor;
|
||||
xevent.selection = selection;
|
||||
xevent.target = target;
|
||||
xevent.property = property;
|
||||
xevent.time = time;
|
||||
|
||||
XSendEvent (gdk_display, requestor, False, NoEventMask, (XEvent*) &xevent);
|
||||
}
|
967
gdk/gdktypes.h
Normal file
967
gdk/gdktypes.h
Normal file
@ -0,0 +1,967 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef __GDK_TYPES_H__
|
||||
#define __GDK_TYPES_H__
|
||||
|
||||
|
||||
/* GDK uses "glib". (And so does GTK).
|
||||
*/
|
||||
#include <glib.h>
|
||||
|
||||
|
||||
#define GDK_NONE 0L
|
||||
#define GDK_CURRENT_TIME 0L
|
||||
#define GDK_PARENT_RELATIVE 1L
|
||||
|
||||
/* special deviceid for core pointer events */
|
||||
#define GDK_CORE_POINTER 0xfedc
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/* Type definitions for the basic structures.
|
||||
*/
|
||||
|
||||
typedef gulong GdkAtom;
|
||||
typedef struct _GdkColor GdkColor;
|
||||
typedef struct _GdkColormap GdkColormap;
|
||||
typedef struct _GdkVisual GdkVisual;
|
||||
typedef struct _GdkWindowAttr GdkWindowAttr;
|
||||
typedef struct _GdkWindow GdkWindow;
|
||||
typedef struct _GdkWindow GdkPixmap;
|
||||
typedef struct _GdkWindow GdkBitmap;
|
||||
typedef struct _GdkWindow GdkDrawable;
|
||||
typedef struct _GdkImage GdkImage;
|
||||
typedef struct _GdkGCValues GdkGCValues;
|
||||
typedef struct _GdkGC GdkGC;
|
||||
typedef struct _GdkPoint GdkPoint;
|
||||
typedef struct _GdkRectangle GdkRectangle;
|
||||
typedef struct _GdkSegment GdkSegment;
|
||||
typedef struct _GdkFont GdkFont;
|
||||
typedef struct _GdkCursor GdkCursor;
|
||||
|
||||
typedef struct _GdkEventAny GdkEventAny;
|
||||
typedef struct _GdkEventExpose GdkEventExpose;
|
||||
typedef struct _GdkEventMotion GdkEventMotion;
|
||||
typedef struct _GdkEventButton GdkEventButton;
|
||||
typedef struct _GdkEventKey GdkEventKey;
|
||||
typedef struct _GdkEventFocus GdkEventFocus;
|
||||
typedef struct _GdkEventCrossing GdkEventCrossing;
|
||||
typedef struct _GdkEventConfigure GdkEventConfigure;
|
||||
typedef struct _GdkEventProperty GdkEventProperty;
|
||||
typedef struct _GdkEventSelection GdkEventSelection;
|
||||
typedef struct _GdkEventProximity GdkEventProximity;
|
||||
typedef struct _GdkEventOther GdkEventOther;
|
||||
typedef struct _GdkEventDragBegin GdkEventDragBegin;
|
||||
typedef struct _GdkEventDragRequest GdkEventDragRequest;
|
||||
typedef struct _GdkEventDropEnter GdkEventDropEnter;
|
||||
typedef struct _GdkEventDropDataAvailable GdkEventDropDataAvailable;
|
||||
typedef struct _GdkEventDropLeave GdkEventDropLeave;
|
||||
typedef struct _GdkEventClient GdkEventClient;
|
||||
typedef union _GdkEvent GdkEvent;
|
||||
typedef struct _GdkDeviceInfo GdkDeviceInfo;
|
||||
typedef struct _GdkTimeCoord GdkTimeCoord;
|
||||
typedef gint (*GdkEventFunc) (GdkEvent *event,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* Types of windows.
|
||||
* Root: There is only 1 root window and it is initialized
|
||||
* at startup. Creating a window of type GDK_WINDOW_ROOT
|
||||
* is an error.
|
||||
* Toplevel: Windows which interact with the window manager.
|
||||
* Child: Windows which are children of some other type of window.
|
||||
* (Any other type of window). Most windows are child windows.
|
||||
* Dialog: A special kind of toplevel window which interacts with
|
||||
* the window manager slightly differently than a regular
|
||||
* toplevel window. Dialog windows should be used for any
|
||||
* transient window.
|
||||
* Pixmap: Pixmaps are really just another kind of window which
|
||||
* doesn't actually appear on the screen. It can't have
|
||||
* children, either and is really just a convenience so
|
||||
* that the drawing functions can work on both windows
|
||||
* and pixmaps transparently. (ie. You shouldn't pass a
|
||||
* pixmap to any procedure which accepts a window with the
|
||||
* exception of the drawing functions).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_WINDOW_ROOT,
|
||||
GDK_WINDOW_TOPLEVEL,
|
||||
GDK_WINDOW_CHILD,
|
||||
GDK_WINDOW_DIALOG,
|
||||
GDK_WINDOW_TEMP,
|
||||
GDK_WINDOW_PIXMAP
|
||||
} GdkWindowType;
|
||||
|
||||
/* Classes of windows.
|
||||
* InputOutput: Almost every window should be of this type. Such windows
|
||||
* receive events and are also displayed on screen.
|
||||
* InputOnly: Used only in special circumstances when events need to be
|
||||
* stolen from another window or windows. Input only windows
|
||||
* have no visible output, so they are handy for placing over
|
||||
* top of a group of windows in order to grab the events (or
|
||||
* filter the events) from those windows.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_INPUT_OUTPUT,
|
||||
GDK_INPUT_ONLY
|
||||
} GdkWindowClass;
|
||||
|
||||
/* Types of images.
|
||||
* Normal: Normal X image type. These are slow as they involve passing
|
||||
* the entire image through the X connection each time a draw
|
||||
* request is required.
|
||||
* Shared: Shared memory X image type. These are fast as the X server
|
||||
* and the program actually use the same piece of memory. They
|
||||
* should be used with care though as there is the possibility
|
||||
* for both the X server and the program to be reading/writing
|
||||
* the image simultaneously and producing undesired results.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_IMAGE_NORMAL,
|
||||
GDK_IMAGE_SHARED,
|
||||
GDK_IMAGE_FASTEST
|
||||
} GdkImageType;
|
||||
|
||||
/* Types of visuals.
|
||||
* StaticGray:
|
||||
* Grayscale:
|
||||
* StaticColor:
|
||||
* PseudoColor:
|
||||
* TrueColor:
|
||||
* DirectColor:
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_VISUAL_STATIC_GRAY,
|
||||
GDK_VISUAL_GRAYSCALE,
|
||||
GDK_VISUAL_STATIC_COLOR,
|
||||
GDK_VISUAL_PSEUDO_COLOR,
|
||||
GDK_VISUAL_TRUE_COLOR,
|
||||
GDK_VISUAL_DIRECT_COLOR
|
||||
} GdkVisualType;
|
||||
|
||||
/* Types of font.
|
||||
* GDK_FONT_FONT: the font is an XFontStruct.
|
||||
* GDK_FONT_FONTSET: the font is an XFontSet used for I18N.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_FONT_FONT,
|
||||
GDK_FONT_FONTSET
|
||||
} GdkFontType;
|
||||
|
||||
/* Window attribute mask values.
|
||||
* GDK_WA_TITLE: The "title" field is valid.
|
||||
* GDK_WA_X: The "x" field is valid.
|
||||
* GDK_WA_Y: The "y" field is valid.
|
||||
* GDK_WA_CURSOR: The "cursor" field is valid.
|
||||
* GDK_WA_COLORMAP: The "colormap" field is valid.
|
||||
* GDK_WA_VISUAL: The "visual" field is valid.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_WA_TITLE = 1 << 1,
|
||||
GDK_WA_X = 1 << 2,
|
||||
GDK_WA_Y = 1 << 3,
|
||||
GDK_WA_CURSOR = 1 << 4,
|
||||
GDK_WA_COLORMAP = 1 << 5,
|
||||
GDK_WA_VISUAL = 1 << 6,
|
||||
GDK_WA_WMCLASS = 1 << 7
|
||||
} GdkWindowAttributesType;
|
||||
|
||||
/* Size restriction enumeration.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_HINT_POS = 1 << 0,
|
||||
GDK_HINT_MIN_SIZE = 1 << 1,
|
||||
GDK_HINT_MAX_SIZE = 1 << 2
|
||||
} GdkWindowHints;
|
||||
|
||||
/* GC function types.
|
||||
* Copy: Overwrites destination pixels with the source pixels.
|
||||
* Invert: Inverts the destination pixels.
|
||||
* Xor: Xor's the destination pixels with the source pixels.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_COPY,
|
||||
GDK_INVERT,
|
||||
GDK_XOR
|
||||
} GdkFunction;
|
||||
|
||||
/* GC fill types.
|
||||
* Solid:
|
||||
* Tiled:
|
||||
* Stippled:
|
||||
* OpaqueStippled:
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_SOLID,
|
||||
GDK_TILED,
|
||||
GDK_STIPPLED,
|
||||
GDK_OPAQUE_STIPPLED
|
||||
} GdkFill;
|
||||
|
||||
/* GC line styles
|
||||
* Solid:
|
||||
* OnOffDash:
|
||||
* DoubleDash:
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_LINE_SOLID,
|
||||
GDK_LINE_ON_OFF_DASH,
|
||||
GDK_LINE_DOUBLE_DASH
|
||||
} GdkLineStyle;
|
||||
|
||||
/* GC cap styles
|
||||
* CapNotLast:
|
||||
* CapButt:
|
||||
* CapRound:
|
||||
* CapProjecting:
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_CAP_NOT_LAST,
|
||||
GDK_CAP_BUTT,
|
||||
GDK_CAP_ROUND,
|
||||
GDK_CAP_PROJECTING
|
||||
} GdkCapStyle;
|
||||
|
||||
/* GC join styles
|
||||
* JoinMiter:
|
||||
* JoinRound:
|
||||
* JoinBevel:
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_JOIN_MITER,
|
||||
GDK_JOIN_ROUND,
|
||||
GDK_JOIN_BEVEL
|
||||
} GdkJoinStyle;
|
||||
|
||||
/* Cursor types.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
#include <gdk/gdkcursors.h>
|
||||
GDK_LAST_CURSOR
|
||||
} GdkCursorType;
|
||||
|
||||
/* Event types.
|
||||
* Nothing: No event occurred.
|
||||
* Delete: A window delete event was sent by the window manager.
|
||||
* The specified window should be deleted.
|
||||
* Destroy: A window has been destroyed.
|
||||
* Expose: Part of a window has been uncovered.
|
||||
* MotionNotify: The mouse has moved.
|
||||
* ButtonPress: A mouse button was pressed.
|
||||
* ButtonRelease: A mouse button was release.
|
||||
* KeyPress: A key was pressed.
|
||||
* KeyRelease: A key was released.
|
||||
* EnterNotify: A window was entered.
|
||||
* LeaveNotify: A window was exited.
|
||||
* FocusChange: The focus window has changed. (The focus window gets
|
||||
* keyboard events).
|
||||
* Resize: A window has been resized.
|
||||
* Map: A window has been mapped. (It is now visible on the screen).
|
||||
* Unmap: A window has been unmapped. (It is no longer visible on
|
||||
* the screen).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_NOTHING = -1,
|
||||
GDK_DELETE = 0,
|
||||
GDK_DESTROY = 1,
|
||||
GDK_EXPOSE = 2,
|
||||
GDK_MOTION_NOTIFY = 3,
|
||||
GDK_BUTTON_PRESS = 4,
|
||||
GDK_2BUTTON_PRESS = 5,
|
||||
GDK_3BUTTON_PRESS = 6,
|
||||
GDK_BUTTON_RELEASE = 7,
|
||||
GDK_KEY_PRESS = 8,
|
||||
GDK_KEY_RELEASE = 9,
|
||||
GDK_ENTER_NOTIFY = 10,
|
||||
GDK_LEAVE_NOTIFY = 11,
|
||||
GDK_FOCUS_CHANGE = 12,
|
||||
GDK_CONFIGURE = 13,
|
||||
GDK_MAP = 14,
|
||||
GDK_UNMAP = 15,
|
||||
GDK_PROPERTY_NOTIFY = 16,
|
||||
GDK_SELECTION_CLEAR = 17,
|
||||
GDK_SELECTION_REQUEST = 18,
|
||||
GDK_SELECTION_NOTIFY = 19,
|
||||
GDK_PROXIMITY_IN = 20,
|
||||
GDK_PROXIMITY_OUT = 21,
|
||||
GDK_DRAG_BEGIN = 22,
|
||||
GDK_DRAG_REQUEST = 23,
|
||||
GDK_DROP_ENTER = 24,
|
||||
GDK_DROP_LEAVE = 25,
|
||||
GDK_DROP_DATA_AVAIL = 26,
|
||||
GDK_CLIENT_EVENT = 27,
|
||||
GDK_OTHER_EVENT = 9999
|
||||
} GdkEventType;
|
||||
|
||||
/* Event masks. (Used to select what types of events a window
|
||||
* will receive).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_EXPOSURE_MASK = 1 << 1,
|
||||
GDK_POINTER_MOTION_MASK = 1 << 2,
|
||||
GDK_POINTER_MOTION_HINT_MASK = 1 << 3,
|
||||
GDK_BUTTON_MOTION_MASK = 1 << 4,
|
||||
GDK_BUTTON1_MOTION_MASK = 1 << 5,
|
||||
GDK_BUTTON2_MOTION_MASK = 1 << 6,
|
||||
GDK_BUTTON3_MOTION_MASK = 1 << 7,
|
||||
GDK_BUTTON_PRESS_MASK = 1 << 8,
|
||||
GDK_BUTTON_RELEASE_MASK = 1 << 9,
|
||||
GDK_KEY_PRESS_MASK = 1 << 10,
|
||||
GDK_KEY_RELEASE_MASK = 1 << 11,
|
||||
GDK_ENTER_NOTIFY_MASK = 1 << 12,
|
||||
GDK_LEAVE_NOTIFY_MASK = 1 << 13,
|
||||
GDK_FOCUS_CHANGE_MASK = 1 << 14,
|
||||
GDK_STRUCTURE_MASK = 1 << 15,
|
||||
GDK_PROPERTY_CHANGE_MASK = 1 << 16,
|
||||
GDK_PROXIMITY_IN_MASK = 1 << 17,
|
||||
GDK_PROXIMITY_OUT_MASK = 1 << 18,
|
||||
GDK_ALL_EVENTS_MASK = 0x07FFFF
|
||||
} GdkEventMask;
|
||||
|
||||
/* Types of enter/leave notifications.
|
||||
* Ancestor:
|
||||
* Virtual:
|
||||
* Inferior:
|
||||
* Nonlinear:
|
||||
* NonlinearVirtual:
|
||||
* Unknown: An unknown type of enter/leave event occurred.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_NOTIFY_ANCESTOR = 0,
|
||||
GDK_NOTIFY_VIRTUAL = 1,
|
||||
GDK_NOTIFY_INFERIOR = 2,
|
||||
GDK_NOTIFY_NONLINEAR = 3,
|
||||
GDK_NOTIFY_NONLINEAR_VIRTUAL = 4,
|
||||
GDK_NOTIFY_UNKNOWN = 5
|
||||
} GdkNotifyType;
|
||||
|
||||
/* Types of modifiers.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_SHIFT_MASK = 1 << 0,
|
||||
GDK_LOCK_MASK = 1 << 1,
|
||||
GDK_CONTROL_MASK = 1 << 2,
|
||||
GDK_MOD1_MASK = 1 << 3,
|
||||
GDK_MOD2_MASK = 1 << 4,
|
||||
GDK_MOD3_MASK = 1 << 5,
|
||||
GDK_MOD4_MASK = 1 << 6,
|
||||
GDK_MOD5_MASK = 1 << 7,
|
||||
GDK_BUTTON1_MASK = 1 << 8,
|
||||
GDK_BUTTON2_MASK = 1 << 9,
|
||||
GDK_BUTTON3_MASK = 1 << 10,
|
||||
GDK_BUTTON4_MASK = 1 << 11,
|
||||
GDK_BUTTON5_MASK = 1 << 12
|
||||
} GdkModifierType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_CLIP_BY_CHILDREN = 0,
|
||||
GDK_INCLUDE_INFERIORS = 1
|
||||
} GdkSubwindowMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_INPUT_READ = 1 << 0,
|
||||
GDK_INPUT_WRITE = 1 << 1,
|
||||
GDK_INPUT_EXCEPTION = 1 << 2
|
||||
} GdkInputCondition;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_OK = 0,
|
||||
GDK_ERROR = -1,
|
||||
GDK_ERROR_PARAM = -2,
|
||||
GDK_ERROR_FILE = -3,
|
||||
GDK_ERROR_MEM = -4
|
||||
} GdkStatus;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_LSB_FIRST,
|
||||
GDK_MSB_FIRST
|
||||
} GdkByteOrder;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_GC_FOREGROUND = 1 << 0,
|
||||
GDK_GC_BACKGROUND = 1 << 1,
|
||||
GDK_GC_FONT = 1 << 2,
|
||||
GDK_GC_FUNCTION = 1 << 3,
|
||||
GDK_GC_FILL = 1 << 4,
|
||||
GDK_GC_TILE = 1 << 5,
|
||||
GDK_GC_STIPPLE = 1 << 6,
|
||||
GDK_GC_CLIP_MASK = 1 << 7,
|
||||
GDK_GC_SUBWINDOW = 1 << 8,
|
||||
GDK_GC_TS_X_ORIGIN = 1 << 9,
|
||||
GDK_GC_TS_Y_ORIGIN = 1 << 10,
|
||||
GDK_GC_CLIP_X_ORIGIN = 1 << 11,
|
||||
GDK_GC_CLIP_Y_ORIGIN = 1 << 12,
|
||||
GDK_GC_EXPOSURES = 1 << 13,
|
||||
GDK_GC_LINE_WIDTH = 1 << 14,
|
||||
GDK_GC_LINE_STYLE = 1 << 15,
|
||||
GDK_GC_CAP_STYLE = 1 << 16,
|
||||
GDK_GC_JOIN_STYLE = 1 << 17
|
||||
} GdkGCValuesMask;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_SELECTION_PRIMARY = 1,
|
||||
GDK_SELECTION_SECONDARY = 2
|
||||
} GdkSelection;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_PROPERTY_NEW_VALUE,
|
||||
GDK_PROPERTY_DELETE
|
||||
} GdkPropertyState;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_PROP_MODE_REPLACE,
|
||||
GDK_PROP_MODE_PREPEND,
|
||||
GDK_PROP_MODE_APPEND
|
||||
} GdkPropMode;
|
||||
|
||||
/* These definitions are for version 1 of the OffiX D&D protocol,
|
||||
taken from <OffiX/DragAndDropTypes.h> */
|
||||
typedef enum
|
||||
{
|
||||
GDK_DNDTYPE_NOTDND = -1,
|
||||
GDK_DNDTYPE_UNKNOWN = 0,
|
||||
GDK_DNDTYPE_RAWDATA = 1,
|
||||
GDK_DNDTYPE_FILE = 2,
|
||||
GDK_DNDTYPE_FILES = 3,
|
||||
GDK_DNDTYPE_TEXT = 4,
|
||||
GDK_DNDTYPE_DIR = 5,
|
||||
GDK_DNDTYPE_LINK = 6,
|
||||
GDK_DNDTYPE_EXE = 7,
|
||||
GDK_DNDTYPE_URL = 8,
|
||||
GDK_DNDTYPE_MIME = 9,
|
||||
GDK_DNDTYPE_END = 10
|
||||
} GdkDndType;
|
||||
|
||||
/* Enums for XInput support */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_SOURCE_MOUSE,
|
||||
GDK_SOURCE_PEN,
|
||||
GDK_SOURCE_ERASER,
|
||||
GDK_SOURCE_CURSOR
|
||||
} GdkInputSource;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_MODE_DISABLED,
|
||||
GDK_MODE_SCREEN,
|
||||
GDK_MODE_WINDOW
|
||||
} GdkInputMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_AXIS_IGNORE,
|
||||
GDK_AXIS_X,
|
||||
GDK_AXIS_Y,
|
||||
GDK_AXIS_PRESSURE,
|
||||
GDK_AXIS_XTILT,
|
||||
GDK_AXIS_YTILT,
|
||||
GDK_AXIS_LAST
|
||||
} GdkAxisUse;
|
||||
|
||||
/* The next two types define enums for predefined atoms relating
|
||||
to selections. In general, one will need to use gdk_intern_atom */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_TARGET_BITMAP = 5,
|
||||
GDK_TARGET_COLORMAP = 7,
|
||||
GDK_TARGET_DRAWABLE = 17,
|
||||
GDK_TARGET_PIXMAP = 20,
|
||||
GDK_TARGET_STRING = 31
|
||||
} GdkTarget;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_SELECTION_TYPE_ATOM = 4,
|
||||
GDK_SELECTION_TYPE_BITMAP = 5,
|
||||
GDK_SELECTION_TYPE_COLORMAP = 7,
|
||||
GDK_SELECTION_TYPE_DRAWABLE = 17,
|
||||
GDK_SELECTION_TYPE_INTEGER = 19,
|
||||
GDK_SELECTION_TYPE_PIXMAP = 20,
|
||||
GDK_SELECTION_TYPE_WINDOW = 33,
|
||||
GDK_SELECTION_TYPE_STRING = 31
|
||||
} GdkSelectionType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_EXTENSION_EVENTS_NONE,
|
||||
GDK_EXTENSION_EVENTS_ALL,
|
||||
GDK_EXTENSION_EVENTS_CURSOR
|
||||
} GdkExtensionMode;
|
||||
|
||||
typedef void (*GdkInputFunction) (gpointer data,
|
||||
gint source,
|
||||
GdkInputCondition condition);
|
||||
|
||||
/* The color type.
|
||||
* A color consists of red, green and blue values in the
|
||||
* range 0-65535 and a pixel value. The pixel value is highly
|
||||
* dependent on the depth and colormap which this color will
|
||||
* be used to draw into. Therefore, sharing colors between
|
||||
* colormaps is a bad idea.
|
||||
*/
|
||||
struct _GdkColor
|
||||
{
|
||||
gulong pixel;
|
||||
gushort red;
|
||||
gushort green;
|
||||
gushort blue;
|
||||
};
|
||||
|
||||
/* The colormap type.
|
||||
* Colormaps consist of 256 colors.
|
||||
*/
|
||||
struct _GdkColormap
|
||||
{
|
||||
GdkColor colors[256];
|
||||
};
|
||||
|
||||
/* The visual type.
|
||||
* "type" is the type of visual this is (PseudoColor, TrueColor, etc).
|
||||
* "depth" is the bit depth of this visual.
|
||||
* "colormap_size" is the size of a colormap for this visual.
|
||||
* "bits_per_rgb" is the number of significant bits per red, green and blue.
|
||||
* The red, green and blue masks, shifts and precisions refer
|
||||
* to value needed to calculate pixel values in TrueColor and DirectColor
|
||||
* visuals. The "mask" is the significant bits within the pixel. The
|
||||
* "shift" is the number of bits left we must shift a primary for it
|
||||
* to be in position (according to the "mask"). "prec" refers to how
|
||||
* much precision the pixel value contains for a particular primary.
|
||||
*/
|
||||
struct _GdkVisual
|
||||
{
|
||||
GdkVisualType type;
|
||||
gint depth;
|
||||
GdkByteOrder byte_order;
|
||||
gint colormap_size;
|
||||
gint bits_per_rgb;
|
||||
|
||||
guint32 red_mask;
|
||||
gint red_shift;
|
||||
gint red_prec;
|
||||
|
||||
guint32 green_mask;
|
||||
gint green_shift;
|
||||
gint green_prec;
|
||||
|
||||
guint32 blue_mask;
|
||||
gint blue_shift;
|
||||
gint blue_prec;
|
||||
};
|
||||
|
||||
struct _GdkWindowAttr
|
||||
{
|
||||
gchar *title;
|
||||
gint event_mask;
|
||||
gint16 x, y;
|
||||
gint16 width;
|
||||
gint16 height;
|
||||
GdkWindowClass wclass;
|
||||
GdkVisual *visual;
|
||||
GdkColormap *colormap;
|
||||
GdkWindowType window_type;
|
||||
GdkCursor *cursor;
|
||||
gchar *wmclass_name;
|
||||
gchar *wmclass_class;
|
||||
};
|
||||
|
||||
struct _GdkWindow
|
||||
{
|
||||
gpointer user_data;
|
||||
};
|
||||
|
||||
struct _GdkImage
|
||||
{
|
||||
GdkImageType type;
|
||||
GdkVisual *visual; /* visual used to create the image */
|
||||
GdkByteOrder byte_order;
|
||||
guint16 width;
|
||||
guint16 height;
|
||||
guint16 depth;
|
||||
guint16 bpp; /* bytes per pixel */
|
||||
guint16 bpl; /* bytes per line */
|
||||
gpointer mem;
|
||||
};
|
||||
|
||||
struct _GdkGCValues
|
||||
{
|
||||
GdkColor foreground;
|
||||
GdkColor background;
|
||||
GdkFont *font;
|
||||
GdkFunction function;
|
||||
GdkFill fill;
|
||||
GdkPixmap *tile;
|
||||
GdkPixmap *stipple;
|
||||
GdkPixmap *clip_mask;
|
||||
GdkSubwindowMode subwindow_mode;
|
||||
gint ts_x_origin;
|
||||
gint ts_y_origin;
|
||||
gint clip_x_origin;
|
||||
gint clip_y_origin;
|
||||
gint graphics_exposures;
|
||||
gint line_width;
|
||||
GdkLineStyle line_style;
|
||||
GdkCapStyle cap_style;
|
||||
GdkJoinStyle join_style;
|
||||
};
|
||||
|
||||
struct _GdkGC
|
||||
{
|
||||
gint dummy_var;
|
||||
};
|
||||
|
||||
struct _GdkPoint
|
||||
{
|
||||
gint16 x;
|
||||
gint16 y;
|
||||
};
|
||||
|
||||
struct _GdkRectangle
|
||||
{
|
||||
gint16 x;
|
||||
gint16 y;
|
||||
guint16 width;
|
||||
guint16 height;
|
||||
};
|
||||
|
||||
struct _GdkSegment
|
||||
{
|
||||
gint16 x1;
|
||||
gint16 y1;
|
||||
gint16 x2;
|
||||
gint16 y2;
|
||||
};
|
||||
|
||||
struct _GdkFont
|
||||
{
|
||||
GdkFontType type;
|
||||
gint ascent;
|
||||
gint descent;
|
||||
};
|
||||
|
||||
struct _GdkCursor
|
||||
{
|
||||
GdkCursorType type;
|
||||
};
|
||||
|
||||
/* Types for XInput support */
|
||||
|
||||
struct _GdkDeviceInfo
|
||||
{
|
||||
guint32 deviceid;
|
||||
gchar *name;
|
||||
GdkInputSource source;
|
||||
GdkInputMode mode;
|
||||
gint has_cursor; /* TRUE if the X pointer follows device motion */
|
||||
gint num_axes;
|
||||
GdkAxisUse *axes; /* Specifies use for each axis */
|
||||
};
|
||||
|
||||
struct _GdkTimeCoord
|
||||
{
|
||||
guint32 time;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
gdouble pressure;
|
||||
gdouble xtilt;
|
||||
gdouble ytilt;
|
||||
};
|
||||
|
||||
struct _GdkEventAny
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
gint8 send_event;
|
||||
};
|
||||
|
||||
struct _GdkEventExpose
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
GdkRectangle area;
|
||||
gint count; /* If non-zero, how many more events follow. */
|
||||
};
|
||||
|
||||
struct _GdkEventMotion
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
guint32 time;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
gdouble pressure;
|
||||
gdouble xtilt;
|
||||
gdouble ytilt;
|
||||
guint state;
|
||||
gint16 is_hint;
|
||||
GdkInputSource source;
|
||||
guint32 deviceid;
|
||||
};
|
||||
|
||||
struct _GdkEventButton
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
guint32 time;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
gdouble pressure;
|
||||
gdouble xtilt;
|
||||
gdouble ytilt;
|
||||
guint state;
|
||||
guint button;
|
||||
GdkInputSource source;
|
||||
guint32 deviceid;
|
||||
};
|
||||
|
||||
struct _GdkEventKey
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
guint32 time;
|
||||
guint state;
|
||||
guint keyval;
|
||||
};
|
||||
|
||||
struct _GdkEventCrossing
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
GdkWindow *subwindow;
|
||||
GdkNotifyType detail;
|
||||
};
|
||||
|
||||
struct _GdkEventFocus
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
gint16 in;
|
||||
};
|
||||
|
||||
struct _GdkEventConfigure
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
gint16 x, y;
|
||||
gint16 width;
|
||||
gint16 height;
|
||||
};
|
||||
|
||||
struct _GdkEventProperty
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
GdkAtom atom;
|
||||
guint32 time;
|
||||
guint state;
|
||||
};
|
||||
|
||||
struct _GdkEventSelection
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
GdkAtom selection;
|
||||
GdkAtom target;
|
||||
GdkAtom property;
|
||||
guint32 requestor;
|
||||
guint32 time;
|
||||
};
|
||||
|
||||
/* This event type will be used pretty rarely. It only is important
|
||||
for XInput aware programs that are drawing their own cursor */
|
||||
|
||||
struct _GdkEventProximity
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
guint32 time;
|
||||
GdkInputSource source;
|
||||
guint32 deviceid;
|
||||
};
|
||||
|
||||
struct _GdkEventDragRequest
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
guint32 requestor;
|
||||
union {
|
||||
struct {
|
||||
guint protocol_version:4;
|
||||
guint sendreply:1;
|
||||
guint willaccept:1;
|
||||
guint delete_data:1; /* Do *not* delete if link is sent, only
|
||||
if data is sent */
|
||||
guint senddata:1;
|
||||
guint reserved:22;
|
||||
} flags;
|
||||
glong allflags;
|
||||
} u;
|
||||
guint8 isdrop; /* This gdk event can be generated by a couple of
|
||||
X events - this lets the app know whether the
|
||||
drop really occurred or we just set the data */
|
||||
|
||||
GdkPoint drop_coords;
|
||||
gchar *data_type;
|
||||
};
|
||||
|
||||
struct _GdkEventDragBegin
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
union {
|
||||
struct {
|
||||
guint protocol_version:4;
|
||||
guint reserved:28;
|
||||
} flags;
|
||||
glong allflags;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct _GdkEventDropEnter
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
guint32 requestor;
|
||||
union {
|
||||
struct {
|
||||
guint protocol_version:4;
|
||||
guint sendreply:1;
|
||||
guint extended_typelist:1;
|
||||
guint reserved:26;
|
||||
} flags;
|
||||
glong allflags;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct _GdkEventDropLeave
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
guint32 requestor;
|
||||
union {
|
||||
struct {
|
||||
guint protocol_version:4;
|
||||
guint reserved:28;
|
||||
} flags;
|
||||
glong allflags;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct _GdkEventDropDataAvailable
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
guint32 requestor;
|
||||
union {
|
||||
struct {
|
||||
guint protocol_version:4;
|
||||
guint isdrop:1;
|
||||
guint reserved:25;
|
||||
} flags;
|
||||
glong allflags;
|
||||
} u;
|
||||
gchar *data_type; /* MIME type */
|
||||
gulong data_numbytes;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
struct _GdkEventClient
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
GdkAtom message_type;
|
||||
gushort data_format;
|
||||
union {
|
||||
char b[20];
|
||||
short s[10];
|
||||
long l[5];
|
||||
} data;
|
||||
};
|
||||
|
||||
#ifndef _XLIB_H_
|
||||
#define XEvent void
|
||||
#endif
|
||||
|
||||
struct _GdkEventOther
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
XEvent *xevent;
|
||||
};
|
||||
|
||||
union _GdkEvent
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkEventAny any;
|
||||
GdkEventExpose expose;
|
||||
GdkEventMotion motion;
|
||||
GdkEventButton button;
|
||||
GdkEventKey key;
|
||||
GdkEventCrossing crossing;
|
||||
GdkEventFocus focus_change;
|
||||
GdkEventConfigure configure;
|
||||
GdkEventProperty property;
|
||||
GdkEventSelection selection;
|
||||
GdkEventProximity proximity;
|
||||
GdkEventDragBegin dragbegin;
|
||||
GdkEventDragRequest dragrequest;
|
||||
GdkEventDropEnter dropenter;
|
||||
GdkEventDropLeave dropleave;
|
||||
GdkEventDropDataAvailable dropdataavailable;
|
||||
GdkEventClient client;
|
||||
GdkEventOther other;
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif /* __GDK_TYPES_H__ */
|
431
gdk/gdkvisual.c
Normal file
431
gdk/gdkvisual.c
Normal file
@ -0,0 +1,431 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
static void gdk_visual_add (GdkVisual *visual);
|
||||
static void gdk_visual_decompose_mask (gulong mask,
|
||||
gint *shift,
|
||||
gint *prec);
|
||||
static guint gdk_visual_hash (Visual *key);
|
||||
static gint gdk_visual_compare (Visual *a,
|
||||
Visual *b);
|
||||
|
||||
|
||||
static GdkVisualPrivate *system_visual;
|
||||
static GdkVisualPrivate *visuals;
|
||||
static gint nvisuals;
|
||||
|
||||
static gint available_depths[4];
|
||||
static gint navailable_depths;
|
||||
|
||||
static GdkVisualType available_types[6];
|
||||
static gint navailable_types;
|
||||
|
||||
static char* visual_names[] =
|
||||
{
|
||||
"static gray",
|
||||
"grayscale",
|
||||
"static color",
|
||||
"pseudo color",
|
||||
"true color",
|
||||
"direct color",
|
||||
};
|
||||
|
||||
static GHashTable *visual_hash = NULL;
|
||||
|
||||
void
|
||||
gdk_visual_init ()
|
||||
{
|
||||
static gint possible_depths[5] = { 32, 24, 16, 15, 8 };
|
||||
static GdkVisualType possible_types[6] =
|
||||
{
|
||||
GDK_VISUAL_DIRECT_COLOR,
|
||||
GDK_VISUAL_TRUE_COLOR,
|
||||
GDK_VISUAL_PSEUDO_COLOR,
|
||||
GDK_VISUAL_STATIC_COLOR,
|
||||
GDK_VISUAL_GRAYSCALE,
|
||||
GDK_VISUAL_STATIC_GRAY
|
||||
};
|
||||
|
||||
static gint npossible_depths = 5;
|
||||
static gint npossible_types = 6;
|
||||
|
||||
XVisualInfo *visual_list;
|
||||
XVisualInfo visual_template;
|
||||
GdkVisualPrivate temp_visual;
|
||||
Visual *default_xvisual;
|
||||
int nxvisuals;
|
||||
int i, j;
|
||||
|
||||
visual_template.screen = gdk_screen;
|
||||
visual_list = XGetVisualInfo (gdk_display, VisualScreenMask, &visual_template, &nxvisuals);
|
||||
visuals = g_new (GdkVisualPrivate, nxvisuals);
|
||||
|
||||
default_xvisual = DefaultVisual (gdk_display, gdk_screen);
|
||||
|
||||
nvisuals = 0;
|
||||
for (i = 0; i < nxvisuals; i++)
|
||||
{
|
||||
if (visual_list[i].depth >= 8)
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
switch (visual_list[i].c_class)
|
||||
#else /* __cplusplus */
|
||||
switch (visual_list[i].class)
|
||||
#endif /* __cplusplus */
|
||||
{
|
||||
case StaticGray:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_STATIC_GRAY;
|
||||
break;
|
||||
case GrayScale:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_GRAYSCALE;
|
||||
break;
|
||||
case StaticColor:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_STATIC_COLOR;
|
||||
break;
|
||||
case PseudoColor:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_PSEUDO_COLOR;
|
||||
break;
|
||||
case TrueColor:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_TRUE_COLOR;
|
||||
break;
|
||||
case DirectColor:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_DIRECT_COLOR;
|
||||
break;
|
||||
}
|
||||
|
||||
visuals[nvisuals].visual.depth = visual_list[i].depth;
|
||||
visuals[nvisuals].visual.byte_order =
|
||||
(ImageByteOrder(gdk_display) == LSBFirst) ?
|
||||
GDK_LSB_FIRST : GDK_MSB_FIRST;
|
||||
visuals[nvisuals].visual.red_mask = visual_list[i].red_mask;
|
||||
visuals[nvisuals].visual.green_mask = visual_list[i].green_mask;
|
||||
visuals[nvisuals].visual.blue_mask = visual_list[i].blue_mask;
|
||||
visuals[nvisuals].visual.colormap_size = visual_list[i].colormap_size;
|
||||
visuals[nvisuals].visual.bits_per_rgb = visual_list[i].bits_per_rgb;
|
||||
visuals[nvisuals].xvisual = visual_list[i].visual;
|
||||
|
||||
if ((visuals[nvisuals].visual.type == GDK_VISUAL_TRUE_COLOR) ||
|
||||
(visuals[nvisuals].visual.type == GDK_VISUAL_DIRECT_COLOR))
|
||||
{
|
||||
gdk_visual_decompose_mask (visuals[nvisuals].visual.red_mask,
|
||||
&visuals[nvisuals].visual.red_shift,
|
||||
&visuals[nvisuals].visual.red_prec);
|
||||
|
||||
gdk_visual_decompose_mask (visuals[nvisuals].visual.green_mask,
|
||||
&visuals[nvisuals].visual.green_shift,
|
||||
&visuals[nvisuals].visual.green_prec);
|
||||
|
||||
gdk_visual_decompose_mask (visuals[nvisuals].visual.blue_mask,
|
||||
&visuals[nvisuals].visual.blue_shift,
|
||||
&visuals[nvisuals].visual.blue_prec);
|
||||
}
|
||||
else
|
||||
{
|
||||
visuals[nvisuals].visual.red_mask = 0;
|
||||
visuals[nvisuals].visual.red_shift = 0;
|
||||
visuals[nvisuals].visual.red_prec = 0;
|
||||
|
||||
visuals[nvisuals].visual.green_mask = 0;
|
||||
visuals[nvisuals].visual.green_shift = 0;
|
||||
visuals[nvisuals].visual.green_prec = 0;
|
||||
|
||||
visuals[nvisuals].visual.blue_mask = 0;
|
||||
visuals[nvisuals].visual.blue_shift = 0;
|
||||
visuals[nvisuals].visual.blue_prec = 0;
|
||||
}
|
||||
|
||||
nvisuals += 1;
|
||||
}
|
||||
}
|
||||
|
||||
XFree (visual_list);
|
||||
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
{
|
||||
for (j = i+1; j < nvisuals; j++)
|
||||
{
|
||||
if (visuals[j].visual.depth >= visuals[i].visual.depth)
|
||||
{
|
||||
if ((visuals[j].visual.depth == 8) && (visuals[i].visual.depth == 8))
|
||||
{
|
||||
if (visuals[j].visual.type == GDK_VISUAL_PSEUDO_COLOR)
|
||||
{
|
||||
temp_visual = visuals[j];
|
||||
visuals[j] = visuals[i];
|
||||
visuals[i] = temp_visual;
|
||||
}
|
||||
else if ((visuals[i].visual.type != GDK_VISUAL_PSEUDO_COLOR) &&
|
||||
visuals[j].visual.type > visuals[i].visual.type)
|
||||
{
|
||||
temp_visual = visuals[j];
|
||||
visuals[j] = visuals[i];
|
||||
visuals[i] = temp_visual;
|
||||
}
|
||||
}
|
||||
else if ((visuals[j].visual.depth > visuals[i].visual.depth) ||
|
||||
((visuals[j].visual.depth == visuals[i].visual.depth) &&
|
||||
(visuals[j].visual.type > visuals[i].visual.type)))
|
||||
{
|
||||
temp_visual = visuals[j];
|
||||
visuals[j] = visuals[i];
|
||||
visuals[i] = temp_visual;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if (default_xvisual->visualid == visuals[i].xvisual->visualid)
|
||||
{
|
||||
system_visual = &visuals[i];
|
||||
break;
|
||||
}
|
||||
|
||||
if (gdk_debug_level >= 1)
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
g_print ("visual: %s: %d\n",
|
||||
visual_names[visuals[i].visual.type],
|
||||
visuals[i].visual.depth);
|
||||
|
||||
navailable_depths = 0;
|
||||
for (i = 0; i < npossible_depths; i++)
|
||||
{
|
||||
for (j = 0; j < nvisuals; j++)
|
||||
{
|
||||
if (visuals[j].visual.depth == possible_depths[i])
|
||||
{
|
||||
available_depths[navailable_depths++] = visuals[j].visual.depth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (navailable_depths == 0)
|
||||
g_error ("unable to find a usable depth");
|
||||
|
||||
navailable_types = 0;
|
||||
for (i = 0; i < npossible_types; i++)
|
||||
{
|
||||
for (j = 0; j < nvisuals; j++)
|
||||
{
|
||||
if (visuals[j].visual.type == possible_types[i])
|
||||
{
|
||||
available_types[navailable_types++] = visuals[j].visual.type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
gdk_visual_add ((GdkVisual*) &visuals[i]);
|
||||
|
||||
if (npossible_types == 0)
|
||||
g_error ("unable to find a usable visual type");
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_ref (GdkVisual *visual)
|
||||
{
|
||||
return visual;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_visual_unref (GdkVisual *visual)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_visual_get_best_depth ()
|
||||
{
|
||||
return available_depths[0];
|
||||
}
|
||||
|
||||
GdkVisualType
|
||||
gdk_visual_get_best_type ()
|
||||
{
|
||||
return available_types[0];
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_system ()
|
||||
{
|
||||
return ((GdkVisual*) system_visual);
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best ()
|
||||
{
|
||||
return ((GdkVisual*) &(visuals[0]));
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_depth (gint depth)
|
||||
{
|
||||
GdkVisual *return_val;
|
||||
int i;
|
||||
|
||||
return_val = NULL;
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if (depth == visuals[i].visual.depth)
|
||||
{
|
||||
return_val = (GdkVisual*) &(visuals[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_type (GdkVisualType visual_type)
|
||||
{
|
||||
GdkVisual *return_val;
|
||||
int i;
|
||||
|
||||
return_val = NULL;
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if (visual_type == visuals[i].visual.type)
|
||||
{
|
||||
return_val = (GdkVisual*) &(visuals[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_both (gint depth,
|
||||
GdkVisualType visual_type)
|
||||
{
|
||||
GdkVisual *return_val;
|
||||
int i;
|
||||
|
||||
return_val = NULL;
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if ((depth == visuals[i].visual.depth) &&
|
||||
(visual_type == visuals[i].visual.type))
|
||||
{
|
||||
return_val = (GdkVisual*) &(visuals[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_query_depths (gint **depths,
|
||||
gint *count)
|
||||
{
|
||||
*count = navailable_depths;
|
||||
*depths = available_depths;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_query_visual_types (GdkVisualType **visual_types,
|
||||
gint *count)
|
||||
{
|
||||
*count = navailable_types;
|
||||
*visual_types = available_types;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_query_visuals (GdkVisual **visual_return,
|
||||
gint *count)
|
||||
{
|
||||
*count = nvisuals;
|
||||
*visual_return = (GdkVisual*) visuals;
|
||||
}
|
||||
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_lookup (Visual *xvisual)
|
||||
{
|
||||
GdkVisual *visual;
|
||||
|
||||
if (!visual_hash)
|
||||
return NULL;
|
||||
|
||||
visual = g_hash_table_lookup (visual_hash, xvisual);
|
||||
return visual;
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdkx_visual_get (VisualID xvisualid)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if (xvisualid == visuals[i].xvisual->visualid)
|
||||
return (GdkVisual*) &visuals[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gdk_visual_add (GdkVisual *visual)
|
||||
{
|
||||
GdkVisualPrivate *private;
|
||||
|
||||
if (!visual_hash)
|
||||
visual_hash = g_hash_table_new ((GHashFunc) gdk_visual_hash,
|
||||
(GCompareFunc) gdk_visual_compare);
|
||||
|
||||
private = (GdkVisualPrivate*) visual;
|
||||
|
||||
g_hash_table_insert (visual_hash, private->xvisual, visual);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_visual_decompose_mask (gulong mask,
|
||||
gint *shift,
|
||||
gint *prec)
|
||||
{
|
||||
*shift = 0;
|
||||
*prec = 0;
|
||||
|
||||
while (!(mask & 0x1))
|
||||
{
|
||||
(*shift)++;
|
||||
mask >>= 1;
|
||||
}
|
||||
|
||||
while (mask & 0x1)
|
||||
{
|
||||
(*prec)++;
|
||||
mask >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
static guint
|
||||
gdk_visual_hash (Visual *key)
|
||||
{
|
||||
return key->visualid;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_visual_compare (Visual *a,
|
||||
Visual *b)
|
||||
{
|
||||
return (a->visualid == b->visualid);
|
||||
}
|
1358
gdk/gdkwindow.c
Normal file
1358
gdk/gdkwindow.c
Normal file
File diff suppressed because it is too large
Load Diff
48
gdk/gdkx.h
Normal file
48
gdk/gdkx.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef __GDK_X_H__
|
||||
#define __GDK_X_H__
|
||||
|
||||
#include <gdk/gdkprivate.h>
|
||||
|
||||
|
||||
#define GDK_ROOT_WINDOW() gdk_root_window
|
||||
#define GDK_ROOT_PARENT() &gdk_root_parent
|
||||
#define GDK_DISPLAY() gdk_display
|
||||
#define GDK_WINDOW_XDISPLAY(win) (((GdkWindowPrivate*) win)->xdisplay)
|
||||
#define GDK_WINDOW_XWINDOW(win) (((GdkWindowPrivate*) win)->xwindow)
|
||||
#define GDK_IMAGE_XDISPLAY(image) (((GdkImagePrivate*) image)->xdisplay)
|
||||
#define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage)
|
||||
#define GDK_GC_XDISPLAY(gc) (((GdkGCPrivate*) gc)->xdisplay)
|
||||
#define GDK_GC_XGC(gc) (((GdkGCPrivate*) gc)->xgc)
|
||||
#define GDK_COLORMAP_XDISPLAY(cmap) (((GdkColormapPrivate*) cmap)->xdisplay)
|
||||
#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivate*) cmap)->xcolormap)
|
||||
#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate*) vis)->xvisual)
|
||||
#define GDK_FONT_XDISPLAY(font) (((GdkFontPrivate*) font)->xdisplay)
|
||||
#define GDK_FONT_XFONT(font) (((GdkFontPrivate*) font)->xfont)
|
||||
|
||||
|
||||
GdkVisual* gdkx_visual_get (VisualID xvisualid);
|
||||
GdkColormap* gdkx_colormap_get (Colormap xcolormap);
|
||||
/* Utility function in gdk.c - not sure where it belongs, but it's
|
||||
needed in more than one place, so make it public */
|
||||
Window gdk_get_client_window (Display *dpy,
|
||||
Window win);
|
||||
|
||||
|
||||
#endif /* __GDK_X_H__ */
|
74
gdk/gdkxid.c
Normal file
74
gdk/gdkxid.c
Normal file
@ -0,0 +1,74 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
static guint gdk_xid_hash (XID *xid);
|
||||
static gint gdk_xid_compare (XID *a,
|
||||
XID *b);
|
||||
|
||||
|
||||
GHashTable *xid_ht = NULL;
|
||||
|
||||
|
||||
void
|
||||
gdk_xid_table_insert (XID *xid,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_if_fail (xid != NULL);
|
||||
|
||||
if (!xid_ht)
|
||||
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
|
||||
(GCompareFunc) gdk_xid_compare);
|
||||
|
||||
g_hash_table_insert (xid_ht, xid, data);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_xid_table_remove (XID xid)
|
||||
{
|
||||
if (!xid_ht)
|
||||
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
|
||||
(GCompareFunc) gdk_xid_compare);
|
||||
|
||||
g_hash_table_remove (xid_ht, &xid);
|
||||
}
|
||||
|
||||
gpointer
|
||||
gdk_xid_table_lookup (XID xid)
|
||||
{
|
||||
gpointer data;
|
||||
|
||||
data = g_hash_table_lookup (xid_ht, &xid);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static guint
|
||||
gdk_xid_hash (XID *xid)
|
||||
{
|
||||
return *xid;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_xid_compare (XID *a,
|
||||
XID *b)
|
||||
{
|
||||
return (*a == *b);
|
||||
}
|
844
gdk/gxid.c
Normal file
844
gdk/gxid.c
Normal file
@ -0,0 +1,844 @@
|
||||
/*
|
||||
* gxid version 0.3
|
||||
*
|
||||
* Copyright 1997 Owen Taylor <owt1@cornell.edu>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/XInput.h>
|
||||
|
||||
#include "gxid_proto.h"
|
||||
|
||||
/* #define DEBUG_CLIENTS */
|
||||
/* #define DEBUG_EVENTS */
|
||||
|
||||
char *program_name;
|
||||
Display *dpy;
|
||||
Window root_window; /* default root window of dpy */
|
||||
int port = 0; /* port to listen on */
|
||||
int socket_fd = 0; /* file descriptor of socket */
|
||||
typedef struct GxidWindow_ GxidWindow;
|
||||
|
||||
typedef struct GxidDevice_ GxidDevice;
|
||||
struct GxidDevice_ {
|
||||
XID id;
|
||||
int exclusive;
|
||||
int ispointer;
|
||||
|
||||
XDevice *xdevice;
|
||||
int motionnotify_type;
|
||||
int changenotify_type;
|
||||
};
|
||||
|
||||
struct GxidWindow_ {
|
||||
Window xwindow;
|
||||
/* Immediate child of root that is ancestor of window */
|
||||
Window root_child;
|
||||
int num_devices;
|
||||
GxidDevice **devices;
|
||||
};
|
||||
|
||||
GxidDevice **devices = NULL;
|
||||
int num_devices = 0;
|
||||
GxidWindow **windows = NULL;
|
||||
int num_windows = 0;
|
||||
|
||||
void
|
||||
handler(int signal)
|
||||
{
|
||||
fprintf(stderr,"%s: dying on signal %d\n",program_name,signal);
|
||||
if (socket_fd)
|
||||
close(socket_fd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
init_socket()
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
|
||||
socket_fd = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
|
||||
if (socket_fd < 0)
|
||||
{
|
||||
fprintf (stderr, "%s: error getting socket\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(port);
|
||||
sin.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
if (bind(socket_fd,(struct sockaddr *)(&sin),
|
||||
sizeof(struct sockaddr_in)) < 0)
|
||||
{
|
||||
fprintf (stderr,"%s: cannot bind to port %d\n",
|
||||
program_name,port);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (listen(socket_fd,5) < 0)
|
||||
{
|
||||
fprintf (stderr,"%s: error listening on socket\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
};
|
||||
}
|
||||
|
||||
#define NUM_EVENTC 2
|
||||
static void
|
||||
enable_device(GxidDevice *dev)
|
||||
{
|
||||
XEventClass xevc[NUM_EVENTC];
|
||||
int num_eventc = NUM_EVENTC;
|
||||
int i,j;
|
||||
|
||||
if (!dev->xdevice)
|
||||
{
|
||||
if (dev->ispointer) return;
|
||||
|
||||
dev->xdevice = XOpenDevice(dpy, dev->id);
|
||||
if (!dev->xdevice) return;
|
||||
|
||||
DeviceMotionNotify (dev->xdevice, dev->motionnotify_type,
|
||||
xevc[0]);
|
||||
ChangeDeviceNotify (dev->xdevice, dev->changenotify_type,
|
||||
xevc[1]);
|
||||
|
||||
/* compress out zero event classes */
|
||||
for (i=0,j=0;i<NUM_EVENTC;i++)
|
||||
{
|
||||
if (xevc[i]) {
|
||||
xevc[j] = xevc[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
num_eventc = j;
|
||||
|
||||
XSelectExtensionEvent (dpy, root_window, xevc, num_eventc);
|
||||
}
|
||||
}
|
||||
|
||||
/* switch the core pointer from whatever it is now to something else,
|
||||
return true on success, false otherwise */
|
||||
static int
|
||||
switch_core_pointer()
|
||||
{
|
||||
GxidDevice *old_pointer = 0;
|
||||
GxidDevice *new_pointer = 0;
|
||||
int result;
|
||||
int i;
|
||||
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (devices[i]->ispointer)
|
||||
old_pointer = devices[i];
|
||||
else
|
||||
if (!new_pointer && !devices[i]->exclusive)
|
||||
new_pointer = devices[i];
|
||||
}
|
||||
|
||||
if (!old_pointer || !new_pointer)
|
||||
return 0;
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"gxid: Switching core from %ld to %ld\n",
|
||||
old_pointer->id,new_pointer->id);
|
||||
#endif
|
||||
result = XChangePointerDevice(dpy,new_pointer->xdevice, 0, 1);
|
||||
if (result != Success)
|
||||
{
|
||||
fprintf(stderr,"gxid: Error %d switching core from %ld to %ld\n",
|
||||
result, old_pointer->id, new_pointer->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_pointer->ispointer = 1;
|
||||
old_pointer->ispointer = 0;
|
||||
if (!old_pointer->xdevice)
|
||||
enable_device(old_pointer);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
disable_device(GxidDevice *dev)
|
||||
{
|
||||
if (dev->xdevice)
|
||||
{
|
||||
if (dev->ispointer)
|
||||
return;
|
||||
XCloseDevice(dpy,dev->xdevice);
|
||||
dev->xdevice = 0;
|
||||
}
|
||||
}
|
||||
|
||||
GxidDevice *
|
||||
init_device(XDeviceInfo *xdevice)
|
||||
{
|
||||
GxidDevice *dev = (GxidDevice *)malloc(sizeof(GxidDevice));
|
||||
XAnyClassPtr class;
|
||||
int num_axes, i;
|
||||
|
||||
dev->id = xdevice->id;
|
||||
dev->exclusive = 0;
|
||||
dev->xdevice = NULL;
|
||||
|
||||
dev->ispointer = (xdevice->use == IsXPointer);
|
||||
|
||||
/* step through the classes */
|
||||
|
||||
num_axes = 0;
|
||||
class = xdevice->inputclassinfo;
|
||||
for (i=0;i<xdevice->num_classes;i++)
|
||||
{
|
||||
if (class->class == ValuatorClass)
|
||||
{
|
||||
XValuatorInfo *xvi = (XValuatorInfo *)class;
|
||||
num_axes = xvi->num_axes;
|
||||
}
|
||||
class = (XAnyClassPtr)(((char *)class) + class->length);
|
||||
}
|
||||
|
||||
/* return NULL if insufficient axes */
|
||||
if (num_axes < 2)
|
||||
{
|
||||
free((void *)dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!dev->ispointer)
|
||||
enable_device(dev);
|
||||
return dev;
|
||||
}
|
||||
|
||||
void
|
||||
init_xinput()
|
||||
{
|
||||
char **extensions;
|
||||
XDeviceInfo *xdevices;
|
||||
int num_xdevices;
|
||||
int num_extensions;
|
||||
int i;
|
||||
|
||||
extensions = XListExtensions(dpy, &num_extensions);
|
||||
for (i = 0; i < num_extensions &&
|
||||
(strcmp(extensions[i], "XInputExtension") != 0); i++);
|
||||
XFreeExtensionList(extensions);
|
||||
if (i == num_extensions) /* XInput extension not found */
|
||||
{
|
||||
fprintf(stderr,"XInput extension not found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
xdevices = XListInputDevices(dpy, &num_xdevices);
|
||||
devices = (GxidDevice **)malloc(num_xdevices * sizeof(GxidDevice *));
|
||||
|
||||
num_devices = 0;
|
||||
for(i=0; i<num_xdevices; i++)
|
||||
{
|
||||
GxidDevice *dev = init_device(&xdevices[i]);
|
||||
if (dev)
|
||||
devices[num_devices++] = dev;
|
||||
}
|
||||
XFreeDeviceList(xdevices);
|
||||
}
|
||||
|
||||
/* If this routine needs fixing, the corresponding routine
|
||||
in gdkinputgxi.h will need it too. */
|
||||
|
||||
Window
|
||||
gxi_find_root_child(Display *dpy, Window w)
|
||||
{
|
||||
Window root,parent;
|
||||
Window *children;
|
||||
int nchildren;
|
||||
|
||||
parent = w;
|
||||
do
|
||||
{
|
||||
w = parent;
|
||||
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
|
||||
if (children) XFree(children);
|
||||
}
|
||||
while (parent != root);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
int
|
||||
handle_claim_device(GxidClaimDevice *msg)
|
||||
{
|
||||
int i,j;
|
||||
XID devid = ntohl(msg->device);
|
||||
XID winid = ntohl(msg->window);
|
||||
int exclusive = ntohl(msg->exclusive);
|
||||
GxidDevice *device = NULL;
|
||||
GxidWindow *window = NULL;
|
||||
|
||||
#ifdef DEBUG_CLIENTS
|
||||
fprintf(stderr,"device %ld claimed (window 0x%lx)\n",devid,winid);
|
||||
#endif
|
||||
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (devices[i]->id == devid)
|
||||
{
|
||||
device = devices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!device)
|
||||
{
|
||||
fprintf(stderr,"%s: Unknown device id %ld\n",program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (device->exclusive)
|
||||
{
|
||||
/* already in use */
|
||||
fprintf(stderr,
|
||||
"%s: Device %ld already claimed in exclusive mode\n",
|
||||
program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (exclusive)
|
||||
{
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
for (j=0;j<windows[i]->num_devices;j++)
|
||||
if (windows[i]->devices[j]->id == devid)
|
||||
{
|
||||
/* already in use */
|
||||
fprintf(stderr,
|
||||
"%s: Can't establish exclusive use of device %ld\n",
|
||||
program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
if (device->ispointer)
|
||||
if (!switch_core_pointer())
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: Can't free up core pointer %ld\n",
|
||||
program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
device->exclusive = 1;
|
||||
disable_device(device);
|
||||
XSelectInput(dpy,winid,StructureNotifyMask);
|
||||
}
|
||||
else /* !exclusive */
|
||||
{
|
||||
/* FIXME: this is a bit improper. We probably should do this only
|
||||
when a window is first claimed. But we might be fooled if
|
||||
an old client died without releasing it's windows. So until
|
||||
we look for client-window closings, do it here
|
||||
|
||||
(We do look for closings now...)
|
||||
*/
|
||||
|
||||
XSelectInput(dpy,winid,EnterWindowMask|StructureNotifyMask);
|
||||
}
|
||||
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
if (windows[i]->xwindow == winid)
|
||||
{
|
||||
window = windows[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create window structure if no devices have been previously
|
||||
claimed on it */
|
||||
if (!window)
|
||||
{
|
||||
num_windows++;
|
||||
windows = (GxidWindow **)realloc(windows,
|
||||
sizeof(GxidWindow*)*num_windows);
|
||||
window = (GxidWindow *)malloc(sizeof(GxidWindow));
|
||||
windows[num_windows-1] = window;
|
||||
|
||||
window->xwindow = winid;
|
||||
window->root_child = gxi_find_root_child(dpy,winid);
|
||||
window->num_devices = 0;
|
||||
window->devices = 0;
|
||||
}
|
||||
|
||||
|
||||
for (i=0;i<window->num_devices;i++)
|
||||
{
|
||||
if (window->devices[i] == device)
|
||||
return GXID_RETURN_OK;
|
||||
}
|
||||
|
||||
window->num_devices++;
|
||||
window->devices = (GxidDevice **)realloc(window->devices,
|
||||
sizeof(GxidDevice*)*num_devices);
|
||||
/* we need add the device to the window */
|
||||
window->devices[i] = device;
|
||||
|
||||
return GXID_RETURN_OK;
|
||||
}
|
||||
|
||||
int
|
||||
handle_release_device(GxidReleaseDevice *msg)
|
||||
{
|
||||
int i,j;
|
||||
XID devid = ntohl(msg->device);
|
||||
XID winid = ntohl(msg->window);
|
||||
|
||||
GxidDevice *device = NULL;
|
||||
|
||||
#ifdef DEBUG_CLIENTS
|
||||
fprintf(stderr,"device %ld released (window 0x%lx)\n",devid,winid);
|
||||
#endif
|
||||
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (devices[i]->id == devid)
|
||||
{
|
||||
device = devices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!device)
|
||||
{
|
||||
fprintf(stderr,"%s: Unknown device id %ld\n",program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
GxidWindow *w = windows[i];
|
||||
|
||||
if (w->xwindow == winid)
|
||||
for (j=0;j<w->num_devices;j++)
|
||||
if (w->devices[j]->id == devid)
|
||||
{
|
||||
if (j<w->num_devices-1)
|
||||
w->devices[j] = w->devices[w->num_devices-1];
|
||||
w->num_devices--;
|
||||
|
||||
if (w->num_devices == 0)
|
||||
{
|
||||
if (i<num_windows-1)
|
||||
windows[i] = windows[num_windows-1];
|
||||
num_windows--;
|
||||
|
||||
free((void *)w);
|
||||
/* FIXME: should we deselect input? But what
|
||||
what if window is already destroyed */
|
||||
}
|
||||
|
||||
if (device->exclusive)
|
||||
{
|
||||
device->exclusive = 0;
|
||||
enable_device(device);
|
||||
}
|
||||
return GXID_RETURN_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/* device/window combination not found */
|
||||
fprintf(stderr,
|
||||
"%s: Device %ld not claimed for window 0x%lx\n",
|
||||
program_name,devid,winid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
void
|
||||
handle_connection()
|
||||
{
|
||||
GxidMessage msg;
|
||||
GxidU32 type;
|
||||
int length;
|
||||
GxidI32 retval;
|
||||
|
||||
int conn_fd;
|
||||
struct sockaddr_in sin;
|
||||
int sin_length;
|
||||
int count;
|
||||
|
||||
sin_length = sizeof(struct sockaddr_in);
|
||||
conn_fd = accept(socket_fd,(struct sockaddr *)&sin,&sin_length);
|
||||
if (conn_fd < 0)
|
||||
{
|
||||
fprintf(stderr,"%s: Error accepting connection\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* read type and length of message */
|
||||
|
||||
count = read(conn_fd,(char *)&msg,2*sizeof(GxidU32));
|
||||
if (count != 2*sizeof(GxidU32))
|
||||
{
|
||||
fprintf(stderr,"%s: Error reading message header\n",
|
||||
program_name);
|
||||
close(conn_fd);
|
||||
return;
|
||||
}
|
||||
type = ntohl(msg.any.type);
|
||||
length = ntohl(msg.any.length);
|
||||
|
||||
/* read rest of message */
|
||||
|
||||
if (length > sizeof(GxidMessage))
|
||||
{
|
||||
fprintf(stderr,"%s: Bad message length\n",
|
||||
program_name);
|
||||
close(conn_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
count = read(conn_fd,2*sizeof(GxidU32) + (char *)&msg,
|
||||
length - 2*sizeof(GxidU32));
|
||||
if (count != length - 2*sizeof(GxidU32))
|
||||
{
|
||||
fprintf(stderr,"%s: Error reading message body\n",
|
||||
program_name);
|
||||
close(conn_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GXID_CLAIM_DEVICE:
|
||||
retval = handle_claim_device((GxidClaimDevice *)&msg);
|
||||
break;
|
||||
case GXID_RELEASE_DEVICE:
|
||||
retval = handle_release_device((GxidReleaseDevice *)&msg);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"%s: Unknown message type: %ld (ignoring)\n",
|
||||
program_name,type);
|
||||
close(conn_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
count = write(conn_fd,&retval,sizeof(GxidI32));
|
||||
if (count != sizeof(GxidI32))
|
||||
{
|
||||
fprintf(stderr,"%s: Error writing return code\n",
|
||||
program_name);
|
||||
}
|
||||
|
||||
close(conn_fd);
|
||||
}
|
||||
|
||||
void
|
||||
handle_motion_notify(XDeviceMotionEvent *event)
|
||||
{
|
||||
int i,j;
|
||||
GxidDevice *old_device = NULL;
|
||||
GxidDevice *new_device = NULL;
|
||||
Window w, root, child;
|
||||
int root_x, root_y, x, y, mask;
|
||||
|
||||
for (j=0;j<num_devices;j++)
|
||||
{
|
||||
if (devices[j]->ispointer)
|
||||
old_device = devices[j];
|
||||
if (devices[j]->id == event->deviceid)
|
||||
new_device = devices[j];
|
||||
}
|
||||
|
||||
if (new_device && !new_device->exclusive && !new_device->ispointer)
|
||||
{
|
||||
/* make sure we aren't stealing the pointer back from a slow
|
||||
client */
|
||||
child = root_window;
|
||||
do
|
||||
{
|
||||
w = child;
|
||||
/* FIXME: this fails disasterously if child vanishes between
|
||||
calls. (Which is prone to happening since we get events
|
||||
on root just as the client exits) */
|
||||
|
||||
XQueryPointer(dpy,w,&root,&child,&root_x,&root_y,
|
||||
&x,&y,&mask);
|
||||
}
|
||||
while (child != None);
|
||||
|
||||
for (i=0;i<num_windows;i++)
|
||||
if (windows[i]->xwindow == w)
|
||||
for (j=0;j<windows[i]->num_devices;j++)
|
||||
if (windows[i]->devices[j] == new_device)
|
||||
return;
|
||||
|
||||
/* FIXME: do something smarter with axes */
|
||||
XChangePointerDevice(dpy,new_device->xdevice, 0, 1);
|
||||
new_device->ispointer = 1;
|
||||
|
||||
old_device->ispointer = 0;
|
||||
if (!old_device->xdevice)
|
||||
enable_device(old_device);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_change_notify(XChangeDeviceNotifyEvent *event)
|
||||
{
|
||||
int j;
|
||||
GxidDevice *old_device = NULL;
|
||||
GxidDevice *new_device = NULL;
|
||||
|
||||
|
||||
for (j=0;j<num_devices;j++)
|
||||
{
|
||||
if (devices[j]->ispointer)
|
||||
old_device = devices[j];
|
||||
if (devices[j]->id == event->deviceid)
|
||||
new_device = devices[j];
|
||||
}
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"gxid: ChangeNotify event; old = %ld; new = %ld\n",
|
||||
old_device->id, new_device->id);
|
||||
#endif
|
||||
|
||||
if (old_device != new_device)
|
||||
{
|
||||
new_device->ispointer = 1;
|
||||
|
||||
old_device->ispointer = 0;
|
||||
if (!old_device->xdevice)
|
||||
enable_device(old_device);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_enter_notify(XEnterWindowEvent *event, GxidWindow *window)
|
||||
{
|
||||
int i;
|
||||
GxidDevice *old_pointer = NULL;
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (devices[i]->ispointer)
|
||||
{
|
||||
old_pointer = devices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"gxid: Enter event; oldpointer = %ld\n",
|
||||
old_pointer->id);
|
||||
#endif
|
||||
|
||||
if (old_pointer)
|
||||
for (i=0;i<window->num_devices;i++)
|
||||
{
|
||||
if (window->devices[i] == old_pointer)
|
||||
{
|
||||
switch_core_pointer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_destroy_notify(XDestroyWindowEvent *event)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
for (i=0;i<num_windows;i++)
|
||||
if (windows[i]->xwindow == event->window)
|
||||
{
|
||||
GxidWindow *w = windows[i];
|
||||
|
||||
for (j=0;j<w->num_devices;j++)
|
||||
{
|
||||
#ifdef DEBUG_CLIENTS
|
||||
fprintf(stderr,"device %ld released on destruction of window 0x%lx.\n",
|
||||
w->devices[j]->id,w->xwindow);
|
||||
#endif
|
||||
|
||||
if (w->devices[j]->exclusive)
|
||||
{
|
||||
w->devices[j]->exclusive = 0;
|
||||
enable_device(devices[j]);
|
||||
}
|
||||
}
|
||||
|
||||
if (i<num_windows-1)
|
||||
windows[i] = windows[num_windows-1];
|
||||
num_windows--;
|
||||
|
||||
if (w->devices)
|
||||
free((void *)w->devices);
|
||||
free((void *)w);
|
||||
/* FIXME: should we deselect input? But what
|
||||
what if window is already destroyed */
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_xevent()
|
||||
{
|
||||
int i;
|
||||
XEvent event;
|
||||
|
||||
XNextEvent (dpy, &event);
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"Event - type = %d; window = 0x%lx\n",
|
||||
event.type,event.xany.window);
|
||||
#endif
|
||||
|
||||
if (event.type == ConfigureNotify)
|
||||
{
|
||||
#ifdef DEBUG_EVENTS
|
||||
XConfigureEvent *xce = (XConfigureEvent *)&event;
|
||||
fprintf(stderr," configureNotify: window = 0x%lx\n",xce->window);
|
||||
#endif
|
||||
}
|
||||
else if (event.type == EnterNotify)
|
||||
{
|
||||
/* pointer entered a claimed window */
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
if (event.xany.window == windows[i]->xwindow)
|
||||
handle_enter_notify((XEnterWindowEvent *)&event,windows[i]);
|
||||
}
|
||||
}
|
||||
else if (event.type == DestroyNotify)
|
||||
{
|
||||
/* A claimed window was destroyed */
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
if (event.xany.window == windows[i]->xwindow)
|
||||
handle_destroy_notify((XDestroyWindowEvent *)&event);
|
||||
}
|
||||
}
|
||||
else
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (event.type == devices[i]->motionnotify_type)
|
||||
{
|
||||
handle_motion_notify((XDeviceMotionEvent *)&event);
|
||||
break;
|
||||
}
|
||||
else if (event.type == devices[i]->changenotify_type)
|
||||
{
|
||||
handle_change_notify((XChangeDeviceNotifyEvent *)&event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr,"Usage: %s [-d display] [-p --gxid-port port]\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char *display_name = NULL;
|
||||
fd_set readfds;
|
||||
|
||||
program_name = argv[0];
|
||||
|
||||
for (i=1;i<argc;i++)
|
||||
{
|
||||
if (!strcmp(argv[i],"-d"))
|
||||
{
|
||||
if (++i >= argc) usage();
|
||||
display_name = argv[i];
|
||||
}
|
||||
else if (!strcmp(argv[i],"--gxid-port") ||
|
||||
!strcmp(argv[i],"-p"))
|
||||
{
|
||||
if (++i >= argc) usage();
|
||||
port = atoi(argv[i]);
|
||||
break;
|
||||
}
|
||||
else
|
||||
usage();
|
||||
}
|
||||
|
||||
if (!port)
|
||||
{
|
||||
char *t = getenv("GXID_PORT");
|
||||
if (t)
|
||||
port = atoi(t);
|
||||
else
|
||||
port = 6951;
|
||||
}
|
||||
/* set up a signal handler so we can clean up if killed */
|
||||
|
||||
signal(SIGTERM,handler);
|
||||
signal(SIGINT,handler);
|
||||
|
||||
/* initialize the X connection */
|
||||
|
||||
dpy = XOpenDisplay (display_name);
|
||||
if (!dpy)
|
||||
{
|
||||
fprintf (stderr, "%s: unable to open display '%s'\n",
|
||||
program_name, XDisplayName (display_name));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
root_window = DefaultRootWindow(dpy);
|
||||
|
||||
/* We'll want to do this in the future if we are to support
|
||||
gxid monitoring visibility information for clients */
|
||||
#if 0
|
||||
XSelectInput(dpy,root_window,SubstructureNotifyMask);
|
||||
#endif
|
||||
init_xinput();
|
||||
|
||||
/* set up our server connection */
|
||||
|
||||
init_socket();
|
||||
|
||||
/* main loop */
|
||||
|
||||
if (XPending(dpy)) /* this seems necessary to get things
|
||||
in sync */
|
||||
handle_xevent();
|
||||
while (1)
|
||||
{
|
||||
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(ConnectionNumber(dpy),&readfds);
|
||||
FD_SET(socket_fd,&readfds);
|
||||
|
||||
if (select(8*sizeof(readfds),&readfds,
|
||||
(fd_set *)0,(fd_set *)0, (struct timeval *)0) < 0)
|
||||
{
|
||||
fprintf(stderr,"Error in select\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (FD_ISSET(socket_fd,&readfds))
|
||||
handle_connection(socket_fd);
|
||||
|
||||
while (XPending(dpy))
|
||||
handle_xevent();
|
||||
}
|
||||
|
||||
XCloseDisplay (dpy);
|
||||
exit (0);
|
||||
}
|
116
gdk/gxid_lib.c
Normal file
116
gdk/gxid_lib.c
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* gxid version 0.3
|
||||
*
|
||||
* Copyright 1997 Owen Taylor <owt1@cornell.edu>
|
||||
*/
|
||||
|
||||
#include "../config.h"
|
||||
|
||||
#ifdef XINPUT_GXI
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include "gxid_lib.h"
|
||||
|
||||
/* handles mechanics of communicating with a client */
|
||||
static int
|
||||
gxid_send_message(char *host, int port, GxidMessage *msg)
|
||||
{
|
||||
int socket_fd;
|
||||
struct sockaddr_in sin;
|
||||
int count;
|
||||
GxidI32 retval;
|
||||
struct hostent *he;
|
||||
|
||||
if (!port) port = 6951;
|
||||
|
||||
if (!host || strcmp(host,"localhost") )
|
||||
{
|
||||
/* looking it up as localhost can be _SLOW_ on ppp systems */
|
||||
/* FIXME: Could localhost be anything other than loopback? */
|
||||
host = "127.0.0.1";
|
||||
}
|
||||
|
||||
he = gethostbyname(host);
|
||||
if (!he)
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: error looking up %s\n",host);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
sin.sin_family = he->h_addrtype;
|
||||
sin.sin_port = htons(port);
|
||||
memcpy(&sin.sin_addr,he->h_addr_list[0],he->h_length);
|
||||
|
||||
socket_fd = socket(AF_INET,SOCK_STREAM,0);
|
||||
if (socket_fd < 0)
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: can't get socket");
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (connect(socket_fd, (struct sockaddr *)&sin,
|
||||
sizeof sin) < 0)
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: can't connect to %s:%d\n",host,port);
|
||||
close(socket_fd);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
count = write(socket_fd,(char *)msg,ntohl(msg->any.length));
|
||||
if (count != ntohl(msg->any.length))
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: error writing");
|
||||
close(socket_fd);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
/* now read the return code */
|
||||
count = read(socket_fd,(char *)&retval,sizeof(GxidI32));
|
||||
if (count != sizeof(GxidI32))
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: error reading return code");
|
||||
close(socket_fd);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
close (socket_fd);
|
||||
return ntohl(retval);
|
||||
}
|
||||
|
||||
/* claim a device. If exclusive, device is claimed exclusively */
|
||||
int
|
||||
gxid_claim_device(char *host, int port, GxidU32 device, GxidU32 window,
|
||||
int exclusive)
|
||||
{
|
||||
GxidClaimDevice msg;
|
||||
msg.type = htonl(GXID_CLAIM_DEVICE);
|
||||
msg.length = htonl(sizeof(GxidClaimDevice));
|
||||
msg.device = htonl(device);
|
||||
msg.window = htonl(window);
|
||||
msg.exclusive = htonl(exclusive);
|
||||
|
||||
return gxid_send_message(host,port,(GxidMessage *)&msg);
|
||||
}
|
||||
|
||||
/* release a device/window pair */
|
||||
int
|
||||
gxid_release_device(char *host, int port, GxidU32 device, GxidU32 window)
|
||||
{
|
||||
GxidReleaseDevice msg;
|
||||
msg.type = htonl(GXID_RELEASE_DEVICE);
|
||||
msg.length = htonl(sizeof(GxidReleaseDevice));
|
||||
msg.device = htonl(device);
|
||||
msg.window = htonl(window);
|
||||
|
||||
return gxid_send_message(host,port,(GxidMessage *)&msg);
|
||||
}
|
||||
|
||||
#endif /* XINPUT_GXI */
|
||||
|
6
gdk/gxid_lib.h
Normal file
6
gdk/gxid_lib.h
Normal file
@ -0,0 +1,6 @@
|
||||
#include "gxid_proto.h"
|
||||
|
||||
int gxid_claim_device(char *host, int port,
|
||||
GxidU32 device, GxidU32 window, int exclusive);
|
||||
int gxid_release_device(char *host, int port, GxidU32 device,
|
||||
GxidU32 window);
|
39
gdk/gxid_proto.h
Normal file
39
gdk/gxid_proto.h
Normal file
@ -0,0 +1,39 @@
|
||||
#define GXID_CLAIM_DEVICE 1
|
||||
#define GXID_RELEASE_DEVICE 2
|
||||
|
||||
#define GXID_RETURN_OK 0
|
||||
#define GXID_RETURN_ERROR -1
|
||||
|
||||
typedef struct GxidClaimDevice_ GxidClaimDevice;
|
||||
typedef struct GxidReleaseDevice_ GxidReleaseDevice;
|
||||
typedef struct GxidMessageAny_ GxidMessageAny;
|
||||
typedef union GxidMessage_ GxidMessage;
|
||||
|
||||
typedef unsigned long GxidU32;
|
||||
typedef long GxidI32;
|
||||
|
||||
struct GxidClaimDevice_ {
|
||||
GxidU32 type;
|
||||
GxidU32 length;
|
||||
GxidU32 device;
|
||||
GxidU32 window;
|
||||
GxidU32 exclusive;
|
||||
};
|
||||
|
||||
struct GxidReleaseDevice_ {
|
||||
GxidU32 type;
|
||||
GxidU32 length;
|
||||
GxidU32 device;
|
||||
GxidU32 window;
|
||||
};
|
||||
|
||||
struct GxidMessageAny_ {
|
||||
GxidU32 type;
|
||||
GxidU32 length;
|
||||
};
|
||||
|
||||
union GxidMessage_ {
|
||||
GxidMessageAny any;
|
||||
GxidClaimDevice claim;
|
||||
GxidReleaseDevice release;
|
||||
};
|
5
gdk/makecursors
Executable file
5
gdk/makecursors
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
sed -f makecursors.sed $1 > .makecursors.tmp
|
||||
awk '{printf "%s = %s,\n", $1, $2}' .makecursors.tmp
|
||||
rm .makecursors.tmp
|
3
gdk/makecursors.sed
Normal file
3
gdk/makecursors.sed
Normal file
@ -0,0 +1,3 @@
|
||||
/define/ ! d
|
||||
/define/ y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
|
||||
s/^.*XC_/GDK_/g
|
5
gdk/makekeysyms
Executable file
5
gdk/makekeysyms
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
sed -f makekeysyms.sed $1 > .makekeysms.tmp
|
||||
awk '{printf "#define %s %s\n", $1, $2}' .makekeysms.tmp
|
||||
rm .makekeysms.tmp
|
3
gdk/makekeysyms.sed
Normal file
3
gdk/makekeysyms.sed
Normal file
@ -0,0 +1,3 @@
|
||||
/define/ ! d
|
||||
s/^.*XK_/GDK_/g
|
||||
s/0X/0x/g
|
718
gdk/x11/gdkcolor-x11.c
Normal file
718
gdk/x11/gdkcolor-x11.c
Normal file
@ -0,0 +1,718 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
static gint gdk_colormap_match_color (GdkColormap *cmap,
|
||||
GdkColor *color,
|
||||
const gchar *available);
|
||||
static void gdk_colormap_add (GdkColormap *cmap);
|
||||
static void gdk_colormap_remove (GdkColormap *cmap);
|
||||
static guint gdk_colormap_hash (Colormap *cmap);
|
||||
static gint gdk_colormap_cmp (Colormap *a,
|
||||
Colormap *b);
|
||||
|
||||
static GHashTable *colormap_hash = NULL;
|
||||
|
||||
|
||||
GdkColormap*
|
||||
gdk_colormap_new (GdkVisual *visual,
|
||||
gint private_cmap)
|
||||
{
|
||||
GdkColormap *colormap;
|
||||
GdkColormapPrivate *private;
|
||||
Visual *xvisual;
|
||||
XColor default_colors[256];
|
||||
int size;
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (visual != NULL, NULL);
|
||||
|
||||
private = g_new (GdkColormapPrivate, 1);
|
||||
colormap = (GdkColormap*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->visual = visual;
|
||||
private->next_color = 0;
|
||||
private->ref_count = 1;
|
||||
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
||||
|
||||
switch (visual->type)
|
||||
{
|
||||
case GDK_VISUAL_GRAYSCALE:
|
||||
case GDK_VISUAL_PSEUDO_COLOR:
|
||||
private->private_val = private_cmap;
|
||||
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
|
||||
xvisual, (private_cmap) ? (AllocAll) : (AllocNone));
|
||||
|
||||
if (private_cmap)
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
default_colors[i].pixel = i;
|
||||
|
||||
XQueryColors (private->xdisplay,
|
||||
DefaultColormap (private->xdisplay, gdk_screen),
|
||||
default_colors, visual->colormap_size);
|
||||
|
||||
for (i = 0; i < visual->colormap_size; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = default_colors[i].pixel;
|
||||
colormap->colors[i].red = default_colors[i].red;
|
||||
colormap->colors[i].green = default_colors[i].green;
|
||||
colormap->colors[i].blue = default_colors[i].blue;
|
||||
}
|
||||
|
||||
gdk_colormap_change (colormap, visual->colormap_size);
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_DIRECT_COLOR:
|
||||
private->private_val = TRUE;
|
||||
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
|
||||
xvisual, AllocAll);
|
||||
|
||||
size = 1 << visual->red_prec;
|
||||
for (i = 0; i < size; i++)
|
||||
colormap->colors[i].red = i * 65535 / (size - 1);
|
||||
|
||||
size = 1 << visual->green_prec;
|
||||
for (i = 0; i < size; i++)
|
||||
colormap->colors[i].green = i * 65535 / (size - 1);
|
||||
|
||||
size = 1 << visual->blue_prec;
|
||||
for (i = 0; i < size; i++)
|
||||
colormap->colors[i].blue = i * 65535 / (size - 1);
|
||||
|
||||
gdk_colormap_change (colormap, visual->colormap_size);
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_STATIC_GRAY:
|
||||
case GDK_VISUAL_STATIC_COLOR:
|
||||
case GDK_VISUAL_TRUE_COLOR:
|
||||
private->private_val = FALSE;
|
||||
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
|
||||
xvisual, AllocNone);
|
||||
break;
|
||||
}
|
||||
|
||||
gdk_colormap_add (colormap);
|
||||
|
||||
return colormap;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_real_destroy (GdkColormap *colormap)
|
||||
{
|
||||
GdkColormapPrivate *private = (GdkColormapPrivate*) colormap;
|
||||
|
||||
g_return_if_fail (colormap != NULL);
|
||||
|
||||
if (private->ref_count > 0)
|
||||
return;
|
||||
|
||||
gdk_colormap_remove (colormap);
|
||||
XFreeColormap (private->xdisplay, private->xcolormap);
|
||||
g_free (colormap);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_destroy (GdkColormap *colormap)
|
||||
{
|
||||
gdk_colormap_unref (colormap);
|
||||
}
|
||||
|
||||
GdkColormap*
|
||||
gdk_colormap_ref (GdkColormap *cmap)
|
||||
{
|
||||
GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
|
||||
g_return_val_if_fail (cmap != NULL, NULL);
|
||||
|
||||
private->ref_count += 1;
|
||||
return cmap;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_unref (GdkColormap *cmap)
|
||||
{
|
||||
GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
|
||||
g_return_if_fail (cmap != NULL);
|
||||
|
||||
private->ref_count -= 1;
|
||||
if (private->ref_count == 0)
|
||||
gdk_colormap_real_destroy (cmap);
|
||||
}
|
||||
|
||||
GdkColormap*
|
||||
gdk_colormap_get_system (void)
|
||||
{
|
||||
static GdkColormap *colormap = NULL;
|
||||
GdkColormapPrivate *private;
|
||||
XColor xpalette[256];
|
||||
gint i;
|
||||
|
||||
if (!colormap)
|
||||
{
|
||||
private = g_new (GdkColormapPrivate, 1);
|
||||
colormap = (GdkColormap*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->xcolormap = DefaultColormap (gdk_display, gdk_screen);
|
||||
private->visual = gdk_visual_get_system ();
|
||||
private->private_val = FALSE;
|
||||
private->next_color = 0;
|
||||
private->ref_count = 1;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
xpalette[i].pixel = i;
|
||||
xpalette[i].red = 0;
|
||||
xpalette[i].green = 0;
|
||||
xpalette[i].blue = 0;
|
||||
}
|
||||
|
||||
XQueryColors (gdk_display, private->xcolormap, xpalette, 256);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = xpalette[i].pixel;
|
||||
colormap->colors[i].red = xpalette[i].red;
|
||||
colormap->colors[i].green = xpalette[i].green;
|
||||
colormap->colors[i].blue = xpalette[i].blue;
|
||||
}
|
||||
|
||||
gdk_colormap_add (colormap);
|
||||
}
|
||||
|
||||
return colormap;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_colormap_get_system_size (void)
|
||||
{
|
||||
return DisplayCells (gdk_display, gdk_screen);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_change (GdkColormap *colormap,
|
||||
gint ncolors)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
GdkVisual *visual;
|
||||
XColor palette[256];
|
||||
gint shift;
|
||||
int max_colors;
|
||||
int size;
|
||||
int i;
|
||||
|
||||
g_return_if_fail (colormap != NULL);
|
||||
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
switch (private->visual->type)
|
||||
{
|
||||
case GDK_VISUAL_GRAYSCALE:
|
||||
case GDK_VISUAL_PSEUDO_COLOR:
|
||||
for (i = 0; i < ncolors; i++)
|
||||
{
|
||||
palette[i].pixel = colormap->colors[i].pixel;
|
||||
palette[i].red = colormap->colors[i].red;
|
||||
palette[i].green = colormap->colors[i].green;
|
||||
palette[i].blue = colormap->colors[i].blue;
|
||||
palette[i].flags = DoRed | DoGreen | DoBlue;
|
||||
}
|
||||
|
||||
XStoreColors (private->xdisplay, private->xcolormap, palette, ncolors);
|
||||
private->next_color = MAX (private->next_color, ncolors);
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_DIRECT_COLOR:
|
||||
visual = private->visual;
|
||||
|
||||
shift = visual->red_shift;
|
||||
max_colors = 1 << visual->red_prec;
|
||||
size = (ncolors < max_colors) ? (ncolors) : (max_colors);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
palette[i].pixel = i << shift;
|
||||
palette[i].red = colormap->colors[i].red;
|
||||
palette[i].flags = DoRed;
|
||||
}
|
||||
|
||||
XStoreColors (private->xdisplay, private->xcolormap, palette, size);
|
||||
|
||||
shift = visual->green_shift;
|
||||
max_colors = 1 << visual->green_prec;
|
||||
size = (ncolors < max_colors) ? (ncolors) : (max_colors);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
palette[i].pixel = i << shift;
|
||||
palette[i].green = colormap->colors[i].green;
|
||||
palette[i].flags = DoGreen;
|
||||
}
|
||||
|
||||
XStoreColors (private->xdisplay, private->xcolormap, palette, size);
|
||||
|
||||
shift = visual->blue_shift;
|
||||
max_colors = 1 << visual->blue_prec;
|
||||
size = (ncolors < max_colors) ? (ncolors) : (max_colors);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
palette[i].pixel = i << shift;
|
||||
palette[i].blue = colormap->colors[i].blue;
|
||||
palette[i].flags = DoBlue;
|
||||
}
|
||||
|
||||
XStoreColors (private->xdisplay, private->xcolormap, palette, size);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colors_store (GdkColormap *colormap,
|
||||
GdkColor *colors,
|
||||
gint ncolors)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < ncolors; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = colors[i].pixel;
|
||||
colormap->colors[i].red = colors[i].red;
|
||||
colormap->colors[i].green = colors[i].green;
|
||||
colormap->colors[i].blue = colors[i].blue;
|
||||
}
|
||||
|
||||
gdk_colormap_change (colormap, ncolors);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_colors_alloc (GdkColormap *colormap,
|
||||
gint contiguous,
|
||||
gulong *planes,
|
||||
gint nplanes,
|
||||
gulong *pixels,
|
||||
gint npixels)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, 0);
|
||||
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
|
||||
return_val = XAllocColorCells (private->xdisplay, private->xcolormap,
|
||||
contiguous, planes, nplanes, pixels, npixels);
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colors_free (GdkColormap *colormap,
|
||||
gulong *pixels,
|
||||
gint npixels,
|
||||
gulong planes)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
|
||||
g_return_if_fail (colormap != NULL);
|
||||
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
|
||||
XFreeColors (private->xdisplay, private->xcolormap,
|
||||
pixels, npixels, planes);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_white (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
|
||||
if (color)
|
||||
{
|
||||
color->pixel = WhitePixel (gdk_display, gdk_screen);
|
||||
color->red = 65535;
|
||||
color->green = 65535;
|
||||
color->blue = 65535;
|
||||
|
||||
return_val = gdk_color_alloc (colormap, color);
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_black (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
|
||||
if (color)
|
||||
{
|
||||
color->pixel = BlackPixel (gdk_display, gdk_screen);
|
||||
color->red = 0;
|
||||
color->green = 0;
|
||||
color->blue = 0;
|
||||
|
||||
return_val = gdk_color_alloc (colormap, color);
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_parse (const gchar *spec,
|
||||
GdkColor *color)
|
||||
{
|
||||
Colormap xcolormap;
|
||||
XColor xcolor;
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (spec != NULL, FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
xcolormap = DefaultColormap (gdk_display, gdk_screen);
|
||||
|
||||
if (XParseColor (gdk_display, xcolormap, spec, &xcolor))
|
||||
{
|
||||
return_val = TRUE;
|
||||
color->red = xcolor.red;
|
||||
color->green = xcolor.green;
|
||||
color->blue = xcolor.blue;
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_alloc (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
GdkVisual *visual;
|
||||
XColor xcolor;
|
||||
gchar available[256];
|
||||
gint available_init;
|
||||
gint return_val;
|
||||
gint i, index;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
xcolor.red = color->red;
|
||||
xcolor.green = color->green;
|
||||
xcolor.blue = color->blue;
|
||||
xcolor.pixel = color->pixel;
|
||||
xcolor.flags = DoRed | DoGreen | DoBlue;
|
||||
|
||||
return_val = FALSE;
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
|
||||
switch (private->visual->type)
|
||||
{
|
||||
case GDK_VISUAL_GRAYSCALE:
|
||||
case GDK_VISUAL_PSEUDO_COLOR:
|
||||
if (private->private_val)
|
||||
{
|
||||
if (private->next_color > 255)
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
available[i] = TRUE;
|
||||
|
||||
index = gdk_colormap_match_color (colormap, color, available);
|
||||
if (index != -1)
|
||||
{
|
||||
available[index] = FALSE;
|
||||
*color = colormap->colors[index];
|
||||
return_val = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return_val = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xcolor.pixel = 255 - private->next_color;
|
||||
color->pixel = xcolor.pixel;
|
||||
private->next_color += 1;
|
||||
|
||||
XStoreColor (private->xdisplay, private->xcolormap, &xcolor);
|
||||
return_val = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
available_init = 1;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor))
|
||||
{
|
||||
color->pixel = xcolor.pixel;
|
||||
color->red = xcolor.red;
|
||||
color->green = xcolor.green;
|
||||
color->blue = xcolor.blue;
|
||||
|
||||
colormap->colors[color->pixel] = *color;
|
||||
|
||||
return_val = TRUE;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (available_init)
|
||||
{
|
||||
available_init = 0;
|
||||
for (i = 0; i < 256; i++)
|
||||
available[i] = TRUE;
|
||||
}
|
||||
|
||||
index = gdk_colormap_match_color (colormap, color, available);
|
||||
if (index != -1)
|
||||
{
|
||||
available[index] = FALSE;
|
||||
xcolor.red = colormap->colors[index].red;
|
||||
xcolor.green = colormap->colors[index].green;
|
||||
xcolor.blue = colormap->colors[index].blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return_val = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_DIRECT_COLOR:
|
||||
visual = private->visual;
|
||||
xcolor.pixel = (((xcolor.red >> (16 - visual->red_prec)) << visual->red_shift) +
|
||||
((xcolor.green >> (16 - visual->green_prec)) << visual->green_shift) +
|
||||
((xcolor.blue >> (16 - visual->blue_prec)) << visual->blue_shift));
|
||||
color->pixel = xcolor.pixel;
|
||||
return_val = TRUE;
|
||||
break;
|
||||
|
||||
case GDK_VISUAL_STATIC_GRAY:
|
||||
case GDK_VISUAL_STATIC_COLOR:
|
||||
case GDK_VISUAL_TRUE_COLOR:
|
||||
if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor))
|
||||
{
|
||||
color->pixel = xcolor.pixel;
|
||||
return_val = TRUE;
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_change (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
XColor xcolor;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
xcolor.pixel = color->pixel;
|
||||
xcolor.red = color->red;
|
||||
xcolor.green = color->green;
|
||||
xcolor.blue = color->blue;
|
||||
xcolor.flags = DoRed | DoGreen | DoBlue;
|
||||
|
||||
private = (GdkColormapPrivate*) colormap;
|
||||
XStoreColor (private->xdisplay, private->xcolormap, &xcolor);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_color_equal (GdkColor *colora,
|
||||
GdkColor *colorb)
|
||||
{
|
||||
g_return_val_if_fail (colora != NULL, FALSE);
|
||||
g_return_val_if_fail (colorb != NULL, FALSE);
|
||||
|
||||
return ((colora->red == colorb->red) &&
|
||||
(colora->green == colorb->green) &&
|
||||
(colora->blue == colorb->blue));
|
||||
}
|
||||
|
||||
GdkColormap*
|
||||
gdkx_colormap_get (Colormap xcolormap)
|
||||
{
|
||||
GdkColormap *colormap;
|
||||
GdkColormapPrivate *private;
|
||||
XColor xpalette[256];
|
||||
gint i;
|
||||
|
||||
colormap = gdk_colormap_lookup (xcolormap);
|
||||
if (colormap)
|
||||
return colormap;
|
||||
|
||||
if (xcolormap == DefaultColormap (gdk_display, gdk_screen))
|
||||
return gdk_colormap_get_system ();
|
||||
|
||||
private = g_new (GdkColormapPrivate, 1);
|
||||
colormap = (GdkColormap*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->xcolormap = xcolormap;
|
||||
private->visual = NULL;
|
||||
private->private_val = TRUE;
|
||||
private->next_color = 0;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
xpalette[i].pixel = i;
|
||||
xpalette[i].red = 0;
|
||||
xpalette[i].green = 0;
|
||||
xpalette[i].blue = 0;
|
||||
}
|
||||
|
||||
XQueryColors (gdk_display, private->xcolormap, xpalette, 256);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = xpalette[i].pixel;
|
||||
colormap->colors[i].red = xpalette[i].red;
|
||||
colormap->colors[i].green = xpalette[i].green;
|
||||
colormap->colors[i].blue = xpalette[i].blue;
|
||||
}
|
||||
|
||||
gdk_colormap_add (colormap);
|
||||
|
||||
return colormap;
|
||||
}
|
||||
|
||||
|
||||
static gint
|
||||
gdk_colormap_match_color (GdkColormap *cmap,
|
||||
GdkColor *color,
|
||||
const gchar *available)
|
||||
{
|
||||
GdkColor *colors;
|
||||
guint sum, max;
|
||||
gint rdiff, gdiff, bdiff;
|
||||
gint i, index;
|
||||
|
||||
g_return_val_if_fail (cmap != NULL, 0);
|
||||
g_return_val_if_fail (color != NULL, 0);
|
||||
|
||||
colors = cmap->colors;
|
||||
max = 3 * (65536);
|
||||
index = -1;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
if ((!available) || (available && available[i]))
|
||||
{
|
||||
rdiff = (color->red - colors[i].red);
|
||||
gdiff = (color->green - colors[i].green);
|
||||
bdiff = (color->blue - colors[i].blue);
|
||||
|
||||
sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
|
||||
|
||||
if (sum < max)
|
||||
{
|
||||
index = i;
|
||||
max = sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
GdkColormap*
|
||||
gdk_colormap_lookup (Colormap xcolormap)
|
||||
{
|
||||
GdkColormap *cmap;
|
||||
|
||||
if (!colormap_hash)
|
||||
return NULL;
|
||||
|
||||
cmap = g_hash_table_lookup (colormap_hash, &xcolormap);
|
||||
return cmap;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_colormap_add (GdkColormap *cmap)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
|
||||
if (!colormap_hash)
|
||||
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
|
||||
(GCompareFunc) gdk_colormap_cmp);
|
||||
|
||||
private = (GdkColormapPrivate*) cmap;
|
||||
|
||||
g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_colormap_remove (GdkColormap *cmap)
|
||||
{
|
||||
GdkColormapPrivate *private;
|
||||
|
||||
if (!colormap_hash)
|
||||
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
|
||||
(GCompareFunc) gdk_colormap_cmp);
|
||||
|
||||
private = (GdkColormapPrivate*) cmap;
|
||||
|
||||
g_hash_table_remove (colormap_hash, &private->xcolormap);
|
||||
}
|
||||
|
||||
static guint
|
||||
gdk_colormap_hash (Colormap *cmap)
|
||||
{
|
||||
return *cmap;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_colormap_cmp (Colormap *a,
|
||||
Colormap *b)
|
||||
{
|
||||
return (*a == *b);
|
||||
}
|
52
gdk/x11/gdkcursor-x11.c
Normal file
52
gdk/x11/gdkcursor-x11.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
GdkCursor*
|
||||
gdk_cursor_new (GdkCursorType cursor_type)
|
||||
{
|
||||
GdkCursorPrivate *private;
|
||||
GdkCursor *cursor;
|
||||
Cursor xcursor;
|
||||
|
||||
xcursor = XCreateFontCursor (gdk_display, cursor_type);
|
||||
private = g_new (GdkCursorPrivate, 1);
|
||||
private->xdisplay = gdk_display;
|
||||
private->xcursor = xcursor;
|
||||
cursor = (GdkCursor*) private;
|
||||
cursor->type = cursor_type;
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_cursor_destroy (GdkCursor *cursor)
|
||||
{
|
||||
GdkCursorPrivate *private;
|
||||
|
||||
g_return_if_fail (cursor != NULL);
|
||||
|
||||
private = (GdkCursorPrivate *) cursor;
|
||||
XFreeCursor (private->xdisplay, private->xcursor);
|
||||
|
||||
g_free (private);
|
||||
}
|
379
gdk/x11/gdkfont-x11.c
Normal file
379
gdk/x11/gdkfont-x11.c
Normal file
@ -0,0 +1,379 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xos.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
GdkFont*
|
||||
gdk_font_load (const gchar *font_name)
|
||||
{
|
||||
GdkFont *font;
|
||||
GdkFontPrivate *private;
|
||||
|
||||
private = g_new (GdkFontPrivate, 1);
|
||||
font = (GdkFont*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->xfont = XLoadQueryFont (private->xdisplay, font_name);
|
||||
private->ref_count = 1;
|
||||
|
||||
if (!private->xfont)
|
||||
{
|
||||
g_free (font);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
font->type = GDK_FONT_FONT;
|
||||
font->ascent = ((XFontStruct *) private->xfont)->ascent;
|
||||
font->descent = ((XFontStruct *) private->xfont)->descent;
|
||||
}
|
||||
|
||||
gdk_xid_table_insert (&((XFontStruct *) private->xfont)->fid, font);
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
GdkFont*
|
||||
gdk_fontset_load(gchar *fontset_name)
|
||||
{
|
||||
GdkFont *font;
|
||||
GdkFontPrivate *private;
|
||||
XFontSet fontset;
|
||||
gint missing_charset_count;
|
||||
gchar **missing_charset_list;
|
||||
gchar *def_string;
|
||||
|
||||
private = g_new (GdkFontPrivate, 1);
|
||||
font = (GdkFont*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
fontset = XCreateFontSet (gdk_display, fontset_name,
|
||||
&missing_charset_list, &missing_charset_count,
|
||||
&def_string);
|
||||
|
||||
if (missing_charset_count)
|
||||
{
|
||||
g_print ("Missing charsets in FontSet creation");
|
||||
XFreeStringList (missing_charset_list);
|
||||
}
|
||||
|
||||
private->ref_count = 1;
|
||||
|
||||
if (!fontset)
|
||||
{
|
||||
g_free (font);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
XFontSetExtents *extent = XExtentsOfFontSet(fontset);
|
||||
|
||||
private->xfont = fontset;
|
||||
font->type = GDK_FONT_FONTSET;
|
||||
/* how to define ascent and descent for fontset ??? */
|
||||
font->ascent = extent->max_logical_extent.height;
|
||||
font->descent = font->ascent / 4 ;
|
||||
}
|
||||
return font;
|
||||
}
|
||||
void
|
||||
gdk_font_free (GdkFont *font)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
|
||||
g_return_if_fail (font != NULL);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
private->ref_count -= 1;
|
||||
if (private->ref_count == 0)
|
||||
{
|
||||
gdk_xid_table_remove (((XFontStruct *) private->xfont)->fid);
|
||||
XFreeFont (private->xdisplay, (XFontStruct *) private->xfont);
|
||||
g_free (font);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_fontset_free (GdkFont *font)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
|
||||
g_return_if_fail (font != NULL);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
private->ref_count -= 1;
|
||||
if (private->ref_count == 0)
|
||||
{
|
||||
XFreeFontSet (private->xdisplay, (XFontSet) private->xfont);
|
||||
g_free (font);
|
||||
}
|
||||
}
|
||||
|
||||
GdkFont*
|
||||
gdk_font_ref (GdkFont *font)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
|
||||
g_return_val_if_fail (font != NULL, NULL);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
private->ref_count += 1;
|
||||
return font;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_font_id (GdkFont *font)
|
||||
{
|
||||
GdkFontPrivate *font_private;
|
||||
|
||||
g_return_val_if_fail (font != NULL, 0);
|
||||
|
||||
font_private = (GdkFontPrivate*) font;
|
||||
|
||||
if (font->type == GDK_FONT_FONT)
|
||||
{
|
||||
return ((XFontStruct *) font_private->xfont)->fid;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_font_equal (GdkFont *fonta,
|
||||
GdkFont *fontb)
|
||||
{
|
||||
GdkFontPrivate *privatea;
|
||||
GdkFontPrivate *privateb;
|
||||
|
||||
g_return_val_if_fail (fonta != NULL, FALSE);
|
||||
g_return_val_if_fail (fontb != NULL, FALSE);
|
||||
|
||||
privatea = (GdkFontPrivate*) fonta;
|
||||
privateb = (GdkFontPrivate*) fontb;
|
||||
|
||||
if (fonta->type == GDK_FONT_FONT && fontb->type == GDK_FONT_FONT)
|
||||
{
|
||||
return (((XFontStruct *) privatea->xfont)->fid ==
|
||||
((XFontStruct *) privateb->xfont)->fid);
|
||||
}
|
||||
else if (fonta->type == GDK_FONT_FONTSET && fontb->type == GDK_FONT_FONTSET)
|
||||
{
|
||||
/* how to compare two fontsets ?? by basename or XFontSet ?? */
|
||||
return (((XFontSet) privatea->xfont) == ((XFontSet) privateb->xfont));
|
||||
}
|
||||
else
|
||||
/* fontset != font */
|
||||
return 0;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_string_width (GdkFont *font,
|
||||
const gchar *string)
|
||||
{
|
||||
GdkFontPrivate *font_private;
|
||||
gint width;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (string != NULL, -1);
|
||||
|
||||
font_private = (GdkFontPrivate*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
xfont = (XFontStruct *) font_private->xfont;
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
width = XTextWidth (xfont, string, strlen (string));
|
||||
}
|
||||
else
|
||||
{
|
||||
width = XTextWidth16 (xfont, (XChar2b *) string, strlen (string) / 2);
|
||||
}
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) font_private->xfont;
|
||||
width = XmbTextEscapement (fontset, string, strlen(string));
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_width (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
gint width;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (text != NULL, -1);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
width = XTextWidth (xfont, text, text_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
width = XTextWidth16 (xfont, (XChar2b *) text, text_length / 2);
|
||||
}
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) private->xfont;
|
||||
width = XmbTextEscapement (fontset, text, text_length);
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
/* Problem: What if a character is a 16 bits character ?? */
|
||||
gint
|
||||
gdk_char_width (GdkFont *font,
|
||||
gchar character)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
XCharStruct *chars;
|
||||
gint width;
|
||||
guint ch = character & 0xff; /* get rid of sign-extension */
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
/* only 8 bits characters are considered here */
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
if ((xfont->min_byte1 == 0) &&
|
||||
(xfont->max_byte1 == 0) &&
|
||||
(ch >= xfont->min_char_or_byte2) &&
|
||||
(ch <= xfont->max_char_or_byte2))
|
||||
{
|
||||
chars = xfont->per_char;
|
||||
if (chars)
|
||||
width = chars[ch - xfont->min_char_or_byte2].width;
|
||||
else
|
||||
width = xfont->min_bounds.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = XTextWidth (xfont, &character, 1);
|
||||
}
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) private->xfont;
|
||||
width = XmbTextEscapement (fontset, &character, 1) ;
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_string_measure (GdkFont *font,
|
||||
const gchar *string)
|
||||
{
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (string != NULL, -1);
|
||||
|
||||
return gdk_text_measure (font, string, strlen (string));
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_measure (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
GdkFontPrivate *private;
|
||||
XCharStruct overall;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
XRectangle ink, log;
|
||||
int direction;
|
||||
int font_ascent;
|
||||
int font_descent;
|
||||
gint width;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (text != NULL, -1);
|
||||
|
||||
private = (GdkFontPrivate*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
XTextExtents (xfont, text, text_length,
|
||||
&direction, &font_ascent, &font_descent,
|
||||
&overall);
|
||||
}
|
||||
else
|
||||
{
|
||||
XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
|
||||
&direction, &font_ascent, &font_descent,
|
||||
&overall);
|
||||
}
|
||||
width = overall.rbearing;
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) private->xfont;
|
||||
XmbTextExtents (fontset, text, text_length, &ink, &log);
|
||||
width = log.width;
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_char_measure (GdkFont *font,
|
||||
gchar character)
|
||||
{
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
|
||||
return gdk_text_measure (font, &character, 1);
|
||||
}
|
47
gdk/x11/gdkglobals-x11.c
Normal file
47
gdk/x11/gdkglobals-x11.c
Normal file
@ -0,0 +1,47 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include "gdktypes.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
gint gdk_debug_level = 0;
|
||||
gint gdk_show_events = FALSE;
|
||||
gint gdk_use_xshm = TRUE;
|
||||
gchar *gdk_display_name = NULL;
|
||||
Display *gdk_display = NULL;
|
||||
gint gdk_screen;
|
||||
Window gdk_root_window;
|
||||
Window gdk_leader_window;
|
||||
GdkWindowPrivate gdk_root_parent;
|
||||
Atom gdk_wm_delete_window;
|
||||
Atom gdk_wm_take_focus;
|
||||
Atom gdk_wm_protocols;
|
||||
Atom gdk_wm_window_protocols[2];
|
||||
Atom gdk_selection_property;
|
||||
GdkDndGlobals gdk_dnd = {None,None,None,
|
||||
None,None,None,
|
||||
None,
|
||||
None,None,
|
||||
NULL,
|
||||
0, 0,
|
||||
{0,0}};
|
||||
gchar *gdk_progname = NULL;
|
||||
gchar *gdk_progclass = NULL;
|
||||
gint gdk_error_code;
|
||||
gint gdk_error_warnings = TRUE;
|
492
gdk/x11/gdkimage-x11.c
Normal file
492
gdk/x11/gdkimage-x11.c
Normal file
@ -0,0 +1,492 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include "../config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined (HAVE_IPC_H) && defined (HAVE_SHM_H) && defined (HAVE_XSHM_H)
|
||||
#define USE_SHM
|
||||
#endif
|
||||
|
||||
#ifdef USE_SHM
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#endif /* USE_SHM */
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#ifdef USE_SHM
|
||||
#include <X11/extensions/XShm.h>
|
||||
#endif /* USE_SHM */
|
||||
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
static void gdk_image_put_normal (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height);
|
||||
static void gdk_image_put_shared (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
|
||||
static GList *image_list = NULL;
|
||||
|
||||
|
||||
void
|
||||
gdk_image_exit ()
|
||||
{
|
||||
GdkImage *image;
|
||||
|
||||
while (image_list)
|
||||
{
|
||||
image = image_list->data;
|
||||
gdk_image_destroy (image);
|
||||
}
|
||||
}
|
||||
|
||||
GdkImage *
|
||||
gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h)
|
||||
/*
|
||||
* Desc: create a new bitmap image
|
||||
*/
|
||||
{
|
||||
Visual *xvisual;
|
||||
GdkImage *image;
|
||||
GdkImagePrivate *private;
|
||||
private = g_new(GdkImagePrivate, 1);
|
||||
image = (GdkImage *) private;
|
||||
private->xdisplay = gdk_display;
|
||||
private->image_put = gdk_image_put_normal;
|
||||
image->type = GDK_IMAGE_NORMAL;
|
||||
image->visual = visual;
|
||||
image->width = w;
|
||||
image->height = h;
|
||||
image->depth = 1;
|
||||
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
||||
private->ximage = XCreateImage(private->xdisplay, xvisual, 1, XYBitmap,
|
||||
0, 0, w ,h, 8, 0);
|
||||
private->ximage->data = data;
|
||||
private->ximage->bitmap_bit_order = MSBFirst;
|
||||
private->ximage->byte_order = MSBFirst;
|
||||
image->byte_order = MSBFirst;
|
||||
image->mem = private->ximage->data;
|
||||
image->bpl = private->ximage->bytes_per_line;
|
||||
image->bpp = 1;
|
||||
return(image);
|
||||
} /* gdk_image_new_bitmap() */
|
||||
|
||||
static int
|
||||
gdk_image_check_xshm(Display *display)
|
||||
/*
|
||||
* Desc: query the server for support for the MIT_SHM extension
|
||||
* Return: 0 = not available
|
||||
* 1 = shared XImage support available
|
||||
* 2 = shared Pixmap support available also
|
||||
*/
|
||||
{
|
||||
#ifdef USE_SHM
|
||||
int major, minor, ignore;
|
||||
Bool pixmaps;
|
||||
|
||||
if (XQueryExtension(display, "MIT-SHM", &ignore, &ignore, &ignore))
|
||||
{
|
||||
if (XShmQueryVersion(display, &major, &minor, &pixmaps )==True)
|
||||
{
|
||||
return (pixmaps==True) ? 2 : 1;
|
||||
}
|
||||
}
|
||||
#endif /* USE_SHM */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_image_init ()
|
||||
{
|
||||
if (gdk_use_xshm)
|
||||
{
|
||||
if (!gdk_image_check_xshm (gdk_display))
|
||||
{
|
||||
g_warning ("MIT-SHM Extension not availible on server");
|
||||
gdk_use_xshm = False;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GdkImage*
|
||||
gdk_image_new (GdkImageType type,
|
||||
GdkVisual *visual,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkImage *image;
|
||||
GdkImagePrivate *private;
|
||||
#ifdef USE_SHM
|
||||
XShmSegmentInfo *x_shm_info;
|
||||
#endif /* USE_SHM */
|
||||
Visual *xvisual;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GDK_IMAGE_FASTEST:
|
||||
image = gdk_image_new (GDK_IMAGE_SHARED, visual, width, height);
|
||||
|
||||
if (!image)
|
||||
image = gdk_image_new (GDK_IMAGE_NORMAL, visual, width, height);
|
||||
break;
|
||||
|
||||
default:
|
||||
private = g_new (GdkImagePrivate, 1);
|
||||
image = (GdkImage*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->image_put = NULL;
|
||||
|
||||
image->type = type;
|
||||
image->visual = visual;
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
image->depth = visual->depth;
|
||||
|
||||
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GDK_IMAGE_SHARED:
|
||||
#ifdef USE_SHM
|
||||
if (gdk_use_xshm)
|
||||
{
|
||||
private->image_put = gdk_image_put_shared;
|
||||
|
||||
private->x_shm_info = g_new (XShmSegmentInfo, 1);
|
||||
x_shm_info = private->x_shm_info;
|
||||
|
||||
private->ximage = XShmCreateImage (private->xdisplay, xvisual, visual->depth,
|
||||
ZPixmap, NULL, x_shm_info, width, height);
|
||||
if (private->ximage == NULL)
|
||||
{
|
||||
g_warning ("XShmCreateImage failed");
|
||||
|
||||
g_free (image);
|
||||
gdk_use_xshm = False;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
x_shm_info->shmid = shmget (IPC_PRIVATE,
|
||||
private->ximage->bytes_per_line * private->ximage->height,
|
||||
IPC_CREAT | 0777);
|
||||
|
||||
if (x_shm_info->shmid == -1)
|
||||
{
|
||||
g_warning ("shmget failed!");
|
||||
|
||||
XDestroyImage (private->ximage);
|
||||
g_free (private->x_shm_info);
|
||||
g_free (image);
|
||||
|
||||
gdk_use_xshm = False;
|
||||
gdk_use_xshm = False;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
x_shm_info->readOnly = False;
|
||||
x_shm_info->shmaddr = shmat (x_shm_info->shmid, 0, 0);
|
||||
private->ximage->data = x_shm_info->shmaddr;
|
||||
|
||||
if (x_shm_info->shmaddr == (char*) -1)
|
||||
{
|
||||
g_warning ("shmat failed!");
|
||||
|
||||
XDestroyImage (private->ximage);
|
||||
shmctl (x_shm_info->shmid, IPC_RMID, 0);
|
||||
|
||||
g_free (private->x_shm_info);
|
||||
g_free (image);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef IPC_RMID_DEFERRED_RELEASE
|
||||
if (x_shm_info->shmaddr != (char*) -1)
|
||||
shmctl (x_shm_info->shmid, IPC_RMID, 0);
|
||||
#endif
|
||||
|
||||
gdk_error_code = 0;
|
||||
gdk_error_warnings = 0;
|
||||
|
||||
XShmAttach (private->xdisplay, x_shm_info);
|
||||
XSync (private->xdisplay, False);
|
||||
|
||||
gdk_error_warnings = 1;
|
||||
if (gdk_error_code == -1)
|
||||
{
|
||||
g_warning ("XShmAttach failed!");
|
||||
|
||||
XDestroyImage (private->ximage);
|
||||
shmdt (x_shm_info->shmaddr);
|
||||
shmctl (x_shm_info->shmid, IPC_RMID, 0);
|
||||
|
||||
g_free (private->x_shm_info);
|
||||
g_free (image);
|
||||
|
||||
gdk_use_xshm = False;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (image)
|
||||
image_list = g_list_prepend (image_list, image);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (image);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
#else /* USE_SHM */
|
||||
g_free (image);
|
||||
return NULL;
|
||||
#endif /* USE_SHM */
|
||||
case GDK_IMAGE_NORMAL:
|
||||
private->image_put = gdk_image_put_normal;
|
||||
|
||||
private->ximage = XCreateImage (private->xdisplay, xvisual, visual->depth,
|
||||
ZPixmap, 0, 0, width, height, 32, 0);
|
||||
|
||||
private->ximage->data = g_new (char, private->ximage->bytes_per_line *
|
||||
private->ximage->height);
|
||||
break;
|
||||
|
||||
case GDK_IMAGE_FASTEST:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if (image)
|
||||
{
|
||||
image->byte_order = private->ximage->byte_order;
|
||||
image->mem = private->ximage->data;
|
||||
image->bpl = private->ximage->bytes_per_line;
|
||||
|
||||
switch (private->ximage->bits_per_pixel)
|
||||
{
|
||||
case 8:
|
||||
image->bpp = 1;
|
||||
break;
|
||||
case 16:
|
||||
image->bpp = 2;
|
||||
break;
|
||||
case 24:
|
||||
image->bpp = 3;
|
||||
break;
|
||||
case 32:
|
||||
image->bpp = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
GdkImage*
|
||||
gdk_image_get (GdkWindow *window,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkImage *image;
|
||||
GdkImagePrivate *private;
|
||||
GdkWindowPrivate *win_private;
|
||||
|
||||
g_return_val_if_fail (window != NULL, NULL);
|
||||
|
||||
win_private = (GdkWindowPrivate *) window;
|
||||
|
||||
private = g_new (GdkImagePrivate, 1);
|
||||
image = (GdkImage*) private;
|
||||
|
||||
private->xdisplay = gdk_display;
|
||||
private->image_put = gdk_image_put_normal;
|
||||
private->ximage = XGetImage (private->xdisplay,
|
||||
win_private->xwindow,
|
||||
x, y, width, height,
|
||||
AllPlanes, ZPixmap);
|
||||
|
||||
image->type = GDK_IMAGE_NORMAL;
|
||||
image->visual = gdk_window_get_visual (window);
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
image->depth = private->ximage->depth;
|
||||
|
||||
image->mem = private->ximage->data;
|
||||
image->bpl = private->ximage->bytes_per_line;
|
||||
image->bpp = 1;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
guint32
|
||||
gdk_image_get_pixel (GdkImage *image,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
guint32 pixel;
|
||||
GdkImagePrivate *private;
|
||||
|
||||
g_return_val_if_fail (image != NULL, 0);
|
||||
|
||||
private = (GdkImagePrivate *) image;
|
||||
|
||||
pixel = XGetPixel (private->ximage, x, y);
|
||||
|
||||
return pixel;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_image_put_pixel (GdkImage *image,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 pixel)
|
||||
{
|
||||
GdkImagePrivate *private;
|
||||
|
||||
g_return_if_fail (image != NULL);
|
||||
|
||||
private = (GdkImagePrivate *) image;
|
||||
|
||||
pixel = XPutPixel (private->ximage, x, y, pixel);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_image_destroy (GdkImage *image)
|
||||
{
|
||||
GdkImagePrivate *private;
|
||||
#ifdef USE_SHM
|
||||
XShmSegmentInfo *x_shm_info;
|
||||
#endif /* USE_SHM */
|
||||
|
||||
g_return_if_fail (image != NULL);
|
||||
|
||||
private = (GdkImagePrivate*) image;
|
||||
switch (image->type)
|
||||
{
|
||||
case GDK_IMAGE_NORMAL:
|
||||
XDestroyImage (private->ximage);
|
||||
break;
|
||||
|
||||
case GDK_IMAGE_SHARED:
|
||||
#ifdef USE_SHM
|
||||
XShmDetach (private->xdisplay, private->x_shm_info);
|
||||
XDestroyImage (private->ximage);
|
||||
|
||||
x_shm_info = private->x_shm_info;
|
||||
shmdt (x_shm_info->shmaddr);
|
||||
shmctl (x_shm_info->shmid, IPC_RMID, 0);
|
||||
|
||||
g_free (private->x_shm_info);
|
||||
|
||||
image_list = g_list_remove (image_list, image);
|
||||
#else /* USE_SHM */
|
||||
g_error ("trying to destroy shared memory image when gdk was compiled without shared memory support");
|
||||
#endif /* USE_SHM */
|
||||
break;
|
||||
|
||||
case GDK_IMAGE_FASTEST:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
g_free (image);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_image_put_normal (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkImagePrivate *image_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (image != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
image_private = (GdkImagePrivate*) image;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
g_return_if_fail (image->type == GDK_IMAGE_NORMAL);
|
||||
|
||||
XPutImage (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, image_private->ximage,
|
||||
xsrc, ysrc, xdest, ydest, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_image_put_shared (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkImage *image,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
#ifdef USE_SHM
|
||||
GdkWindowPrivate *drawable_private;
|
||||
GdkImagePrivate *image_private;
|
||||
GdkGCPrivate *gc_private;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (image != NULL);
|
||||
g_return_if_fail (gc != NULL);
|
||||
|
||||
drawable_private = (GdkWindowPrivate*) drawable;
|
||||
image_private = (GdkImagePrivate*) image;
|
||||
gc_private = (GdkGCPrivate*) gc;
|
||||
|
||||
g_return_if_fail (image->type == GDK_IMAGE_SHARED);
|
||||
|
||||
XShmPutImage (drawable_private->xdisplay, drawable_private->xwindow,
|
||||
gc_private->xgc, image_private->ximage,
|
||||
xsrc, ysrc, xdest, ydest, width, height, False);
|
||||
#else /* USE_SHM */
|
||||
g_error ("trying to draw shared memory image when gdk was compiled without shared memory support");
|
||||
#endif /* USE_SHM */
|
||||
}
|
628
gdk/x11/gdkinput-gxi.c
Normal file
628
gdk/x11/gdkinput-gxi.c
Normal file
@ -0,0 +1,628 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef XINPUT_GXI
|
||||
|
||||
/* #define DEBUG_SWITCHING */
|
||||
|
||||
#include <gxid_lib.h>
|
||||
|
||||
/* Forward declarations */
|
||||
static void gdk_input_gxi_select_notify (GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode);
|
||||
static gint gdk_input_is_extension_device (guint32 deviceid);
|
||||
static void gdk_input_gxi_configure_event (XConfigureEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static void gdk_input_gxi_enter_event (XCrossingEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static gint gdk_input_gxi_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static void gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev);
|
||||
|
||||
static gint gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent);
|
||||
static gint gdk_input_gxi_enable_window (GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_gxi_disable_window (GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static Window gdk_input_find_root_child(Display *dpy, Window w);
|
||||
static void gdk_input_compute_obscuring(GdkInputWindow *input_window);
|
||||
static gint gdk_input_is_obscured(GdkInputWindow *input_window, gdouble x,
|
||||
gdouble y);
|
||||
static GdkTimeCoord *gdk_input_gxi_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return);
|
||||
static void gdk_input_gxi_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask);
|
||||
static gint gdk_input_gxi_grab_pointer (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time);
|
||||
static void gdk_input_gxi_ungrab_pointer (guint32 time);
|
||||
|
||||
/* Local variables */
|
||||
|
||||
static GdkDevicePrivate *gdk_input_current_device;
|
||||
static GdkDevicePrivate *gdk_input_core_pointer;
|
||||
|
||||
void
|
||||
gdk_input_init(void)
|
||||
{
|
||||
GList *tmp_list;
|
||||
|
||||
gdk_input_vtable.set_mode = gdk_input_gxi_set_mode;
|
||||
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
|
||||
gdk_input_vtable.motion_events = gdk_input_gxi_motion_events;
|
||||
gdk_input_vtable.get_pointer = gdk_input_gxi_get_pointer;
|
||||
gdk_input_vtable.grab_pointer = gdk_input_gxi_grab_pointer;
|
||||
gdk_input_vtable.ungrab_pointer = gdk_input_gxi_ungrab_pointer;
|
||||
gdk_input_vtable.configure_event = gdk_input_gxi_configure_event;
|
||||
gdk_input_vtable.enter_event = gdk_input_gxi_enter_event;
|
||||
gdk_input_vtable.other_event = gdk_input_gxi_other_event;
|
||||
gdk_input_vtable.window_none_event = gdk_input_gxi_window_none_event;
|
||||
gdk_input_vtable.enable_window = gdk_input_gxi_enable_window;
|
||||
gdk_input_vtable.disable_window = gdk_input_gxi_disable_window;
|
||||
|
||||
gdk_input_ignore_core = FALSE;
|
||||
gdk_input_core_pointer = NULL;
|
||||
|
||||
if (!gdk_input_gxid_host)
|
||||
{
|
||||
gdk_input_gxid_host = getenv("GXID_HOST");
|
||||
}
|
||||
if (!gdk_input_gxid_port)
|
||||
{
|
||||
char *t = getenv("GXID_PORT");
|
||||
if (t)
|
||||
gdk_input_gxid_port = atoi(t);
|
||||
}
|
||||
|
||||
gdk_input_common_init(TRUE);
|
||||
|
||||
/* find initial core pointer */
|
||||
|
||||
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdk_input_is_extension_device(gdkdev->info.deviceid))
|
||||
{
|
||||
gdk_input_gxi_select_notify (gdkdev);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
|
||||
gdk_input_core_pointer = gdkdev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_select_notify (GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
XEventClass class;
|
||||
|
||||
ChangeDeviceNotify (gdkdev->xdevice, gdkdev->changenotify_type, class);
|
||||
|
||||
XSelectExtensionEvent (gdk_display, gdk_root_window, &class, 1);
|
||||
}
|
||||
|
||||
/* Set the core pointer. Device should already be enabled. */
|
||||
static gint
|
||||
gdk_input_gxi_set_core_pointer(GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
int x_axis,y_axis;
|
||||
|
||||
g_return_val_if_fail(gdkdev->xdevice,FALSE);
|
||||
|
||||
x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
|
||||
y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
|
||||
|
||||
g_return_val_if_fail(x_axis != -1 && y_axis != -1,FALSE);
|
||||
|
||||
/* core_pointer might not be up to date so we check with the server
|
||||
before change the pointer */
|
||||
|
||||
if ( !gdk_input_is_extension_device(gdkdev->info.deviceid) )
|
||||
{
|
||||
#if 0
|
||||
if (gdkdev != gdk_input_core_pointer)
|
||||
g_warning("core pointer inconsistency");
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( XChangePointerDevice(gdk_display,gdkdev->xdevice, x_axis, y_axis)
|
||||
!= Success )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_input_gxi_update_device (gdk_input_core_pointer);
|
||||
gdk_input_core_pointer = gdkdev;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* FIXME, merge with gdk_input_xfree_set_mode */
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GdkInputMode old_mode;
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
gdkdev = gdk_input_find_device(deviceid);
|
||||
g_return_val_if_fail (gdkdev != NULL,FALSE);
|
||||
old_mode = gdkdev->info.mode;
|
||||
|
||||
if (gdkdev->info.mode == mode)
|
||||
return TRUE;
|
||||
|
||||
gdkdev->info.mode = mode;
|
||||
|
||||
if (old_mode != GDK_MODE_DISABLED)
|
||||
{
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
|
||||
gdk_input_disable_window (input_window->window, gdkdev);
|
||||
}
|
||||
}
|
||||
|
||||
if (mode != GDK_MODE_DISABLED)
|
||||
{
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
|
||||
if (!gdk_input_enable_window(input_window->window, gdkdev))
|
||||
{
|
||||
gdk_input_set_mode(deviceid, old_mode);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_input_is_extension_device (guint32 deviceid)
|
||||
{
|
||||
XDeviceInfo *devices;
|
||||
int num_devices, loop;
|
||||
|
||||
if (deviceid == GDK_CORE_POINTER)
|
||||
return FALSE;
|
||||
|
||||
devices = XListInputDevices(gdk_display, &num_devices);
|
||||
for(loop=0; loop<num_devices; loop++)
|
||||
{
|
||||
if ((devices[loop].id == deviceid) && (devices[loop].use == IsXExtensionDevice))
|
||||
{
|
||||
XFreeDeviceList(devices);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
XFreeDeviceList(devices);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_configure_event (XConfigureEvent *xevent, GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
gint root_x, root_y;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_if_fail (input_window != NULL);
|
||||
|
||||
gdk_input_get_root_relative_geometry(gdk_display,GDK_WINDOW_XWINDOW(window),
|
||||
&root_x, &root_y, NULL, NULL);
|
||||
input_window->root_x = root_x;
|
||||
input_window->root_y = root_y;
|
||||
gdk_input_compute_obscuring(input_window);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_enter_event (XCrossingEvent *xevent, GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_if_fail (input_window != NULL);
|
||||
|
||||
gdk_input_compute_obscuring(input_window);
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
GdkDevicePrivate *gdkdev;
|
||||
gint return_val;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_val_if_fail (window != NULL, -1);
|
||||
|
||||
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
|
||||
but it's potentially faster than scanning through the types of
|
||||
every device. If we were deceived, then it won't match any of
|
||||
the types for the device anyways */
|
||||
gdkdev = gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
|
||||
|
||||
if (!gdkdev) {
|
||||
return -1; /* we don't handle it - not an XInput event */
|
||||
}
|
||||
|
||||
if (gdkdev->info.mode == GDK_MODE_DISABLED ||
|
||||
input_window->mode == GDK_EXTENSION_EVENTS_CURSOR)
|
||||
return FALSE;
|
||||
|
||||
if (gdkdev != gdk_input_current_device &&
|
||||
xevent->type != gdkdev->changenotify_type)
|
||||
{
|
||||
gdk_input_current_device = gdkdev;
|
||||
}
|
||||
|
||||
return_val = gdk_input_common_other_event (event, xevent,
|
||||
input_window, gdkdev);
|
||||
|
||||
if (return_val > 0 && event->type == GDK_MOTION_NOTIFY &&
|
||||
(!gdkdev->button_state) && (!input_window->grabbed) &&
|
||||
((event->motion.x < 0) || (event->motion.y < 0) ||
|
||||
(event->motion.x > ((GdkWindowPrivate *)window)->width) ||
|
||||
(event->motion.y > ((GdkWindowPrivate *)window)->height) ||
|
||||
gdk_input_is_obscured(input_window,event->motion.x,event->motion.y)))
|
||||
{
|
||||
#ifdef DEBUG_SWITCHING
|
||||
g_print("gdkinput: Setting core pointer to %d on motion at (%f,%f)\n",
|
||||
gdkdev->info.deviceid,event->motion.x,event->motion.y);
|
||||
g_print(" window geometry is: %dx%d\n",
|
||||
((GdkWindowPrivate *)window)->width,
|
||||
((GdkWindowPrivate *)window)->height);
|
||||
#endif
|
||||
gdk_input_gxi_set_core_pointer(gdkdev);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
return return_val;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
GList *t;
|
||||
|
||||
if (gdk_input_is_extension_device (gdkdev->info.deviceid))
|
||||
{
|
||||
if (!gdkdev->xdevice)
|
||||
{
|
||||
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
|
||||
gdk_input_gxi_select_notify (gdkdev);
|
||||
gdkdev->needs_update = 1;
|
||||
}
|
||||
if (gdkdev->needs_update && gdkdev->xdevice)
|
||||
{
|
||||
for (t = gdk_input_windows; t; t = t->next)
|
||||
gdk_input_common_select_events (((GdkInputWindow *)t->data)->window,
|
||||
gdkdev);
|
||||
gdkdev->needs_update = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev =
|
||||
gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
|
||||
|
||||
if (!gdkdev) {
|
||||
return -1; /* we don't handle it - not an XInput event */
|
||||
}
|
||||
|
||||
if (xevent->type == gdkdev->changenotify_type)
|
||||
{
|
||||
if (gdk_input_core_pointer != gdkdev)
|
||||
{
|
||||
#ifdef DEBUG_SWITCHING
|
||||
g_print("ChangeNotify from %d to %d:\n",
|
||||
gdk_input_core_pointer->info.deviceid,
|
||||
gdkdev->info.deviceid);
|
||||
#endif
|
||||
gdk_input_gxi_update_device (gdk_input_core_pointer);
|
||||
gdk_input_core_pointer = gdkdev;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
input_window = gdk_input_window_find (window);
|
||||
g_return_val_if_fail (input_window != NULL, FALSE);
|
||||
|
||||
if (!gdkdev->claimed)
|
||||
{
|
||||
if (gxid_claim_device(gdk_input_gxid_host, gdk_input_gxid_port,
|
||||
gdkdev->info.deviceid,
|
||||
GDK_WINDOW_XWINDOW(window), FALSE) !=
|
||||
GXID_RETURN_OK)
|
||||
{
|
||||
g_warning("Could not get device (is gxid running?)\n");
|
||||
return FALSE;
|
||||
}
|
||||
gdkdev->claimed = TRUE;
|
||||
}
|
||||
|
||||
if (gdkdev->xdevice && gdkdev != gdk_input_core_pointer)
|
||||
gdk_input_common_select_events(window, gdkdev);
|
||||
else
|
||||
gdkdev->needs_update = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
input_window = gdk_input_window_find (window);
|
||||
g_return_val_if_fail (input_window != NULL, FALSE);
|
||||
|
||||
if (gdkdev->claimed)
|
||||
{
|
||||
gxid_release_device(gdk_input_gxid_host, gdk_input_gxid_port,
|
||||
gdkdev->info.deviceid,
|
||||
GDK_WINDOW_XWINDOW(window));
|
||||
|
||||
gdkdev->claimed = FALSE;
|
||||
}
|
||||
|
||||
if (gdkdev->xdevice && gdkdev != gdk_input_core_pointer)
|
||||
gdk_input_common_select_events(window, gdkdev);
|
||||
else
|
||||
gdkdev->needs_update = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_is_obscured(GdkInputWindow *input_window, gdouble x, gdouble y)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<input_window->num_obscuring;i++)
|
||||
{
|
||||
GdkRectangle *rect = &input_window->obscuring[i];
|
||||
if ((x >= rect->x) &&
|
||||
(y >= rect->y) &&
|
||||
(x < rect->x + rect->width) &&
|
||||
(y < rect->y + rect->height))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If this routine needs fixing, the corresponding routine
|
||||
in gxid.c will need it too. */
|
||||
|
||||
static Window
|
||||
gdk_input_find_root_child(Display *dpy, Window w)
|
||||
{
|
||||
Window root,parent;
|
||||
Window *children;
|
||||
int nchildren;
|
||||
|
||||
parent = w;
|
||||
do
|
||||
{
|
||||
w = parent;
|
||||
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
|
||||
if (children) XFree(children);
|
||||
}
|
||||
while (parent != root);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_compute_obscuring(GdkInputWindow *input_window)
|
||||
{
|
||||
int i;
|
||||
int x,y,width,height;
|
||||
int xc,yc,widthc,heightc,border_widthc,depthc;
|
||||
|
||||
Window root,parent;
|
||||
Window *children;
|
||||
int nchildren;
|
||||
|
||||
Window w = GDK_WINDOW_XWINDOW(input_window->window);
|
||||
Window root_child = gdk_input_find_root_child(gdk_display,w);
|
||||
gdk_input_get_root_relative_geometry(gdk_display,w,&x,&y,&width,&height);
|
||||
|
||||
input_window->root_x = x;
|
||||
input_window->root_y = y;
|
||||
|
||||
XQueryTree(gdk_display,GDK_ROOT_WINDOW(),
|
||||
&root,&parent,&children,&nchildren);
|
||||
|
||||
|
||||
if (input_window->obscuring)
|
||||
g_free(input_window->obscuring);
|
||||
input_window->obscuring = 0;
|
||||
input_window->num_obscuring = 0;
|
||||
|
||||
for (i=0;i<nchildren;i++)
|
||||
if (children[i] == root_child)
|
||||
break;
|
||||
|
||||
if (i>=nchildren-1)
|
||||
{
|
||||
if (nchildren)
|
||||
XFree(children);
|
||||
return;
|
||||
}
|
||||
|
||||
input_window->obscuring = g_new(GdkRectangle,(nchildren-i-1));
|
||||
|
||||
for (i=i+1;i<nchildren;i++)
|
||||
{
|
||||
int xmin, xmax, ymin, ymax;
|
||||
XGetGeometry(gdk_display,children[i],&root,&xc,&yc,&widthc,&heightc,
|
||||
&border_widthc, &depthc);
|
||||
xmin = xc>x ? xc : x;
|
||||
xmax = (xc+widthc)<(x+width) ? xc+widthc : x+width;
|
||||
ymin = yc>y ? yc : y;
|
||||
ymax = (yc+heightc)<(y+height) ? yc+heightc : y+height;
|
||||
if ((xmin < xmax) && (ymin < ymax))
|
||||
{
|
||||
XWindowAttributes attributes;
|
||||
XGetWindowAttributes(gdk_display,children[i],&attributes);
|
||||
if (attributes.map_state == IsViewable)
|
||||
{
|
||||
GdkRectangle *rect = &input_window->obscuring[input_window->num_obscuring];
|
||||
|
||||
/* we store the whole window, not just the obscuring part */
|
||||
rect->x = xc - x;
|
||||
rect->y = yc - y;
|
||||
rect->width = widthc;
|
||||
rect->height = heightc;
|
||||
input_window->num_obscuring++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nchildren)
|
||||
XFree(children);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
|
||||
if (gdkdev == gdk_input_core_pointer)
|
||||
gdk_input_common_get_pointer (window, GDK_CORE_POINTER, x, y,
|
||||
pressure, xtilt, ytilt, mask);
|
||||
else
|
||||
gdk_input_common_get_pointer (window, deviceid, x, y,
|
||||
pressure, xtilt, ytilt, mask);
|
||||
}
|
||||
|
||||
static GdkTimeCoord *
|
||||
gdk_input_gxi_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
g_return_val_if_fail (gdkdev != NULL, NULL);
|
||||
|
||||
|
||||
if (gdkdev == gdk_input_core_pointer)
|
||||
return gdk_input_motion_events (window, GDK_CORE_POINTER, start, stop,
|
||||
nevents_return);
|
||||
else
|
||||
return gdk_input_common_motion_events (window, deviceid, start, stop,
|
||||
nevents_return);
|
||||
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_gxi_grab_pointer (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window, *new_window;
|
||||
GList *tmp_list;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
return AlreadyGrabbed;
|
||||
|
||||
if (input_window->window == window)
|
||||
new_window = input_window;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
new_window->grabbed = TRUE;
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_gxi_ungrab_pointer (guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
GList *tmp_list;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
input_window->grabbed = FALSE;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* XINPUT_GXI */
|
72
gdk/x11/gdkinput-none.c
Normal file
72
gdk/x11/gdkinput-none.c
Normal file
@ -0,0 +1,72 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef XINPUT_NONE
|
||||
|
||||
static void gdk_input_none_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask);
|
||||
|
||||
void
|
||||
gdk_input_init ()
|
||||
{
|
||||
gdk_input_vtable.set_mode = NULL;
|
||||
gdk_input_vtable.set_axes = NULL;
|
||||
gdk_input_vtable.motion_events = NULL;
|
||||
gdk_input_vtable.get_pointer = gdk_input_none_get_pointer;
|
||||
gdk_input_vtable.grab_pointer = NULL;
|
||||
gdk_input_vtable.ungrab_pointer = NULL;
|
||||
gdk_input_vtable.configure_event = NULL;
|
||||
gdk_input_vtable.enter_event = NULL;
|
||||
gdk_input_vtable.other_event = NULL;
|
||||
gdk_input_vtable.window_none_event = NULL;
|
||||
gdk_input_vtable.enable_window = NULL;
|
||||
gdk_input_vtable.disable_window = NULL;
|
||||
|
||||
gdk_input_devices = g_list_append (NULL, &gdk_input_core_info);
|
||||
|
||||
gdk_input_ignore_core = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_none_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
gint x_int, y_int;
|
||||
|
||||
gdk_window_get_pointer (window, &x_int, &y_int, mask);
|
||||
|
||||
if (x) *x = x_int;
|
||||
if (y) *y = y_int;
|
||||
if (pressure) *pressure = 0.5;
|
||||
if (xtilt) *xtilt = 0;
|
||||
if (ytilt) *ytilt = 0;
|
||||
}
|
||||
|
||||
#endif /* XINPUT_NONE */
|
687
gdk/x11/gdkinput-x11.c
Normal file
687
gdk/x11/gdkinput-x11.c
Normal file
@ -0,0 +1,687 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#if defined(XINPUT_GXI) || defined(XINPUT_XFREE)
|
||||
|
||||
/* Forward declarations */
|
||||
static void gdk_input_get_root_relative_geometry (Display *dpy, Window w,
|
||||
int *x_ret, int *y_ret,
|
||||
int *width_ret,
|
||||
int *height_ret);
|
||||
static GdkDevicePrivate *gdk_input_device_new(XDeviceInfo *device,
|
||||
gint include_core);
|
||||
static void gdk_input_common_find_events(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev,
|
||||
gint mask,
|
||||
XEventClass *classes,
|
||||
int *num_classes);
|
||||
static void gdk_input_common_select_events(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static void gdk_input_translate_coordinates(GdkDevicePrivate *gdkdev,
|
||||
GdkInputWindow *input_window,
|
||||
gint *axis_data,
|
||||
gdouble *x, gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt, gdouble *ytilt);
|
||||
static guint gdk_input_translate_state(guint state, guint device_state);
|
||||
static gint gdk_input_common_init(gint include_core);
|
||||
static gint gdk_input_common_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkInputWindow *input_window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static void gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes);
|
||||
static GdkTimeCoord * gdk_input_common_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return);
|
||||
static void gdk_input_common_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask);
|
||||
|
||||
/* Global variables */
|
||||
|
||||
static gint gdk_input_root_width;
|
||||
static gint gdk_input_root_height;
|
||||
|
||||
static void
|
||||
gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_ret,
|
||||
int *width_ret, int *height_ret)
|
||||
{
|
||||
Window root,parent;
|
||||
Window *children;
|
||||
int nchildren;
|
||||
int x,y,width,height;
|
||||
int xc,yc,widthc,heightc,border_widthc,depthc;
|
||||
|
||||
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
|
||||
if (children) XFree(children);
|
||||
XGetGeometry(dpy,w,&root,&x,&y,&width,&height,&border_widthc,
|
||||
&depthc);
|
||||
x += border_widthc;
|
||||
y += border_widthc;
|
||||
|
||||
while (root != parent)
|
||||
{
|
||||
w = parent;
|
||||
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
|
||||
if (children) XFree(children);
|
||||
XGetGeometry(dpy,w,&root,&xc,&yc,&widthc,&heightc,
|
||||
&border_widthc,&depthc);
|
||||
x += xc + border_widthc;
|
||||
y += yc + border_widthc;
|
||||
}
|
||||
|
||||
if (x_ret)
|
||||
*x_ret = x;
|
||||
if (y_ret)
|
||||
*y_ret = y;
|
||||
if (width_ret)
|
||||
*width_ret = width;
|
||||
if (height_ret)
|
||||
*height_ret = height;
|
||||
}
|
||||
|
||||
static GdkDevicePrivate *
|
||||
gdk_input_device_new(XDeviceInfo *device, gint include_core)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev;
|
||||
gchar *tmp_name, *p;
|
||||
XAnyClassPtr class;
|
||||
gint i,j;
|
||||
|
||||
gdkdev = g_new(GdkDevicePrivate,1);
|
||||
|
||||
gdkdev->info.deviceid = device->id;
|
||||
if (device->name[0]) {
|
||||
gdkdev->info.name = g_new(char, strlen(device->name)+1);
|
||||
strcpy(gdkdev->info.name,device->name);
|
||||
} else {
|
||||
/* XFree86 3.2 gives an empty name to the default core devices,
|
||||
(fixed in 3.2A) */
|
||||
gdkdev->info.name = g_strdup("pointer");
|
||||
strcpy(gdkdev->info.name,"pointer");
|
||||
gdkdev->info.source = GDK_SOURCE_MOUSE;
|
||||
}
|
||||
|
||||
gdkdev->info.mode = GDK_MODE_DISABLED;
|
||||
|
||||
/* Try to figure out what kind of device this is by its name -
|
||||
could invite a very, very, long list... Lowercase name
|
||||
for comparison purposes */
|
||||
|
||||
tmp_name = g_strdup(gdkdev->info.name);
|
||||
for (p = tmp_name; *p; p++)
|
||||
{
|
||||
if (*p >= 'A' && *p <= 'Z')
|
||||
*p += 'a' - 'A';
|
||||
}
|
||||
|
||||
if (!strcmp (tmp_name, "pointer"))
|
||||
gdkdev->info.source = GDK_SOURCE_MOUSE;
|
||||
else if (!strcmp (tmp_name, "wacom") ||
|
||||
!strcmp (tmp_name, "pen"))
|
||||
gdkdev->info.source = GDK_SOURCE_PEN;
|
||||
else if (!strcmp (tmp_name, "eraser"))
|
||||
gdkdev->info.source = GDK_SOURCE_ERASER;
|
||||
else if (!strcmp (tmp_name, "cursor"))
|
||||
gdkdev->info.source = GDK_SOURCE_CURSOR;
|
||||
else
|
||||
gdkdev->info.source = GDK_SOURCE_PEN;
|
||||
|
||||
g_free(tmp_name);
|
||||
|
||||
gdkdev->xdevice = NULL;
|
||||
|
||||
/* step through the classes */
|
||||
|
||||
gdkdev->info.num_axes = 0;
|
||||
gdkdev->axes = 0;
|
||||
gdkdev->info.has_cursor = 0;
|
||||
gdkdev->needs_update = FALSE;
|
||||
gdkdev->claimed = FALSE;
|
||||
gdkdev->button_state = 0;
|
||||
|
||||
class = device->inputclassinfo;
|
||||
for (i=0;i<device->num_classes;i++)
|
||||
{
|
||||
switch (class->class) {
|
||||
case ButtonClass:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ValuatorClass:
|
||||
{
|
||||
XValuatorInfo *xvi = (XValuatorInfo *)class;
|
||||
gdkdev->info.num_axes = xvi->num_axes;
|
||||
gdkdev->axes = g_new(GdkAxisInfo, xvi->num_axes);
|
||||
gdkdev->info.axes = g_new(GdkAxisUse, xvi->num_axes);
|
||||
for (j=0;j<xvi->num_axes;j++)
|
||||
{
|
||||
gdkdev->axes[j].resolution =
|
||||
gdkdev->axes[j].xresolution = xvi->axes[j].resolution;
|
||||
gdkdev->axes[j].min_value =
|
||||
gdkdev->axes[j].xmin_value = xvi->axes[j].min_value;
|
||||
gdkdev->axes[j].max_value =
|
||||
gdkdev->axes[j].xmax_value = xvi->axes[j].max_value;
|
||||
gdkdev->info.axes[j] = GDK_AXIS_IGNORE;
|
||||
}
|
||||
j=0;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_X;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_Y;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_PRESSURE;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_XTILT;
|
||||
if (j<xvi->num_axes)
|
||||
gdkdev->info.axes[j++] = GDK_AXIS_YTILT;
|
||||
|
||||
/* set up reverse lookup on axis use */
|
||||
for (j=GDK_AXIS_IGNORE;j<GDK_AXIS_LAST;j++)
|
||||
gdkdev->axis_for_use[j] = -1;
|
||||
|
||||
for (j=0;j<xvi->num_axes;j++)
|
||||
if (gdkdev->info.axes[j] != GDK_AXIS_IGNORE)
|
||||
gdkdev->axis_for_use[gdkdev->info.axes[j]] = j;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
class = (XAnyClassPtr)(((char *)class) + class->length);
|
||||
}
|
||||
/* return NULL if no axes */
|
||||
if (!gdkdev->info.num_axes || !gdkdev->axes ||
|
||||
(!include_core && device->use == IsXPointer))
|
||||
{
|
||||
g_free(gdkdev->info.name);
|
||||
if (gdkdev->axes)
|
||||
g_free(gdkdev->axes);
|
||||
g_free(gdkdev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (device->use != IsXPointer)
|
||||
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
|
||||
|
||||
return gdkdev;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_common_find_events(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev,
|
||||
gint mask,
|
||||
XEventClass *classes,
|
||||
int *num_classes)
|
||||
{
|
||||
gint i;
|
||||
XEventClass class;
|
||||
|
||||
i = 0;
|
||||
/* We have to track press and release events in pairs to keep
|
||||
track of button state correctly and implement grabbing */
|
||||
if (mask & GDK_BUTTON_PRESS_MASK || mask & GDK_BUTTON_RELEASE_MASK)
|
||||
{
|
||||
DeviceButtonPress (gdkdev->xdevice, gdkdev->buttonpress_type,
|
||||
class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
DeviceButtonRelease (gdkdev->xdevice, gdkdev->buttonrelease_type,
|
||||
class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_POINTER_MOTION_MASK)
|
||||
{
|
||||
DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_POINTER_MOTION_HINT_MASK)
|
||||
{
|
||||
/* We'll get into trouble if the macros change, but at least we'll
|
||||
know about it, and we avoid warnings now */
|
||||
DevicePointerMotionHint (gdkdev->xdevice, 0, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_PROXIMITY_IN_MASK)
|
||||
{
|
||||
ProximityIn (gdkdev->xdevice, gdkdev->proximityin_type, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
if (mask & GDK_PROXIMITY_OUT_MASK)
|
||||
{
|
||||
ProximityOut (gdkdev->xdevice, gdkdev->proximityout_type, class);
|
||||
if (class != 0)
|
||||
classes[i++] = class;
|
||||
}
|
||||
|
||||
*num_classes = i;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_common_select_events(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
XEventClass classes[6];
|
||||
gint num_classes;
|
||||
|
||||
if (gdkdev->info.mode == GDK_MODE_DISABLED)
|
||||
gdk_input_common_find_events(window, gdkdev, 0, classes, &num_classes);
|
||||
else
|
||||
gdk_input_common_find_events(window, gdkdev,
|
||||
((GdkWindowPrivate *)window)->extension_events,
|
||||
classes, &num_classes);
|
||||
|
||||
XSelectExtensionEvent (gdk_display,
|
||||
GDK_WINDOW_XWINDOW(window),
|
||||
classes, num_classes);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_input_common_init(gint include_core)
|
||||
{
|
||||
char **extensions;
|
||||
XDeviceInfo *devices;
|
||||
int num_devices;
|
||||
int num_extensions, loop;
|
||||
Display *display = gdk_display;
|
||||
|
||||
/* Init global vars */
|
||||
gdk_window_get_geometry(NULL, /* use root window */
|
||||
NULL,NULL,
|
||||
&gdk_input_root_width,&gdk_input_root_height,
|
||||
NULL);
|
||||
|
||||
/* Init XInput extension */
|
||||
|
||||
extensions = XListExtensions(display, &num_extensions);
|
||||
for (loop = 0; loop < num_extensions &&
|
||||
(strcmp(extensions[loop], "XInputExtension") != 0); loop++);
|
||||
XFreeExtensionList(extensions);
|
||||
if (loop == num_extensions) /* XInput extension not found */
|
||||
return FALSE;
|
||||
|
||||
gdk_input_devices = 0;
|
||||
devices = XListInputDevices(display, &num_devices);
|
||||
|
||||
for(loop=0; loop<num_devices; loop++)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = gdk_input_device_new(&devices[loop],
|
||||
include_core);
|
||||
if (gdkdev)
|
||||
gdk_input_devices = g_list_append(gdk_input_devices, gdkdev);
|
||||
}
|
||||
XFreeDeviceList(devices);
|
||||
|
||||
gdk_input_devices = g_list_append (gdk_input_devices, &gdk_input_core_info);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
|
||||
GdkInputWindow *input_window,
|
||||
gint *axis_data,
|
||||
gdouble *x, gdouble *y, gdouble *pressure,
|
||||
gdouble *xtilt, gdouble *ytilt)
|
||||
{
|
||||
GdkWindowPrivate *win_priv;
|
||||
|
||||
int x_axis, y_axis, pressure_axis, xtilt_axis, ytilt_axis;
|
||||
|
||||
double device_width, device_height;
|
||||
double x_offset, y_offset, x_scale, y_scale;
|
||||
|
||||
win_priv = (GdkWindowPrivate *) input_window->window;
|
||||
|
||||
x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
|
||||
y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
|
||||
pressure_axis = gdkdev->axis_for_use[GDK_AXIS_PRESSURE];
|
||||
xtilt_axis = gdkdev->axis_for_use[GDK_AXIS_XTILT];
|
||||
ytilt_axis = gdkdev->axis_for_use[GDK_AXIS_YTILT];
|
||||
|
||||
device_width = gdkdev->axes[x_axis].max_value -
|
||||
gdkdev->axes[x_axis].min_value;
|
||||
device_height = gdkdev->axes[y_axis].max_value -
|
||||
gdkdev->axes[y_axis].min_value;
|
||||
|
||||
if (gdkdev->info.mode == GDK_MODE_SCREEN)
|
||||
{
|
||||
x_scale = gdk_input_root_width / device_width;
|
||||
y_scale = gdk_input_root_height / device_height;
|
||||
|
||||
x_offset = - input_window->root_x;
|
||||
y_offset = - input_window->root_y;
|
||||
}
|
||||
else /* GDK_MODE_WINDOW */
|
||||
{
|
||||
double device_aspect = (device_height*gdkdev->axes[y_axis].resolution) /
|
||||
(device_width*gdkdev->axes[x_axis].resolution);
|
||||
|
||||
if (device_aspect * win_priv->width >= win_priv->height)
|
||||
{
|
||||
/* device taller than window */
|
||||
x_scale = win_priv->width / device_width;
|
||||
y_scale = (x_scale * gdkdev->axes[x_axis].resolution)
|
||||
/ gdkdev->axes[y_axis].resolution;
|
||||
|
||||
x_offset = 0;
|
||||
y_offset = -(device_height * y_scale -
|
||||
win_priv->height)/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* window taller than device */
|
||||
y_scale = win_priv->height / device_height;
|
||||
x_scale = (y_scale * gdkdev->axes[y_axis].resolution)
|
||||
/ gdkdev->axes[x_axis].resolution;
|
||||
|
||||
y_offset = 0;
|
||||
x_offset = - (device_width * x_scale - win_priv->width)/2;
|
||||
}
|
||||
}
|
||||
|
||||
if (x) *x = x_offset + x_scale*axis_data[x_axis];
|
||||
if (y) *y = y_offset + y_scale*axis_data[y_axis];
|
||||
|
||||
if (pressure)
|
||||
{
|
||||
if (pressure_axis != -1)
|
||||
*pressure = ((double)axis_data[pressure_axis]
|
||||
- gdkdev->axes[pressure_axis].min_value)
|
||||
/ (gdkdev->axes[pressure_axis].max_value
|
||||
- gdkdev->axes[pressure_axis].min_value);
|
||||
else
|
||||
*pressure = 0.5;
|
||||
}
|
||||
|
||||
if (xtilt)
|
||||
{
|
||||
if (xtilt_axis != -1)
|
||||
{
|
||||
*xtilt = 2. * (double)(axis_data[xtilt_axis] -
|
||||
(gdkdev->axes[xtilt_axis].min_value +
|
||||
gdkdev->axes[xtilt_axis].max_value)/2) /
|
||||
(gdkdev->axes[xtilt_axis].max_value -
|
||||
gdkdev->axes[xtilt_axis].min_value);
|
||||
}
|
||||
else *xtilt = 0;
|
||||
}
|
||||
|
||||
if (ytilt)
|
||||
{
|
||||
if (ytilt_axis != -1)
|
||||
{
|
||||
*ytilt = 2. * (double)(axis_data[ytilt_axis] -
|
||||
(gdkdev->axes[ytilt_axis].min_value +
|
||||
gdkdev->axes[ytilt_axis].max_value)/2) /
|
||||
(gdkdev->axes[ytilt_axis].max_value -
|
||||
gdkdev->axes[ytilt_axis].min_value);
|
||||
}
|
||||
else
|
||||
*ytilt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* combine the state of the core device and the device state
|
||||
into one - for now we do this in a simple-minded manner -
|
||||
we just take the keyboard portion of the core device and
|
||||
the button portion (all of?) the device state.
|
||||
Any button remapping should go on here. */
|
||||
static guint
|
||||
gdk_input_translate_state(guint state, guint device_state)
|
||||
{
|
||||
return device_state | (state & 0xFF);
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_common_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkInputWindow *input_window,
|
||||
GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
if ((xevent->type == gdkdev->buttonpress_type) ||
|
||||
(xevent->type == gdkdev->buttonrelease_type))
|
||||
{
|
||||
XDeviceButtonEvent *xdbe = (XDeviceButtonEvent *)(xevent);
|
||||
|
||||
if (xdbe->type == gdkdev->buttonpress_type)
|
||||
{
|
||||
event->button.type = GDK_BUTTON_PRESS;
|
||||
gdkdev->button_state |= 1 << xdbe->button;
|
||||
}
|
||||
else
|
||||
{
|
||||
event->button.type = GDK_BUTTON_RELEASE;
|
||||
gdkdev->button_state &= ~(1 << xdbe->button);
|
||||
}
|
||||
event->button.window = input_window->window;
|
||||
event->button.time = xdbe->time;
|
||||
event->button.source = gdkdev->info.source;
|
||||
event->button.deviceid = xdbe->deviceid;
|
||||
|
||||
gdk_input_translate_coordinates (gdkdev,input_window, xdbe->axis_data,
|
||||
&event->button.x,&event->button.y,
|
||||
&event->button.pressure,
|
||||
&event->button.xtilt,
|
||||
&event->button.ytilt);
|
||||
event->button.state = gdk_input_translate_state(xdbe->state,xdbe->device_state);
|
||||
event->button.button = xdbe->button;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (xevent->type == gdkdev->motionnotify_type)
|
||||
{
|
||||
XDeviceMotionEvent *xdme = (XDeviceMotionEvent *)(xevent);
|
||||
|
||||
gdk_input_translate_coordinates(gdkdev,input_window,xdme->axis_data,
|
||||
&event->motion.x,&event->motion.y,
|
||||
&event->motion.pressure,
|
||||
&event->motion.xtilt,
|
||||
&event->motion.ytilt);
|
||||
|
||||
event->motion.type = GDK_MOTION_NOTIFY;
|
||||
event->motion.window = input_window->window;
|
||||
event->motion.time = xdme->time;
|
||||
event->motion.deviceid = xdme->deviceid;
|
||||
event->motion.state = gdk_input_translate_state(xdme->state,
|
||||
xdme->device_state);
|
||||
event->motion.source = gdkdev->info.source;
|
||||
event->motion.deviceid = xdme->deviceid;
|
||||
|
||||
if (gdk_show_events)
|
||||
g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f hint: %s\n",
|
||||
xdme->window,
|
||||
xdme->deviceid,
|
||||
event->motion.x, event->motion.y,
|
||||
(xevent->xmotion.is_hint) ? "true" : "false");
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (xevent->type == gdkdev->proximityin_type ||
|
||||
xevent->type == gdkdev->proximityout_type)
|
||||
{
|
||||
XProximityNotifyEvent *xpne = (XProximityNotifyEvent *)(xevent);
|
||||
|
||||
event->proximity.type = (xevent->type == gdkdev->proximityin_type)?
|
||||
GDK_PROXIMITY_IN:GDK_PROXIMITY_OUT;
|
||||
event->proximity.window = input_window->window;
|
||||
event->proximity.time = xpne->time;
|
||||
event->proximity.source = gdkdev->info.source;
|
||||
event->proximity.deviceid = xpne->deviceid;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return -1; /* wasn't one of our event types */
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
|
||||
{
|
||||
int i;
|
||||
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
|
||||
for (i=GDK_AXIS_IGNORE;i<GDK_AXIS_LAST;i++)
|
||||
{
|
||||
gdkdev->axis_for_use[i] = -1;
|
||||
}
|
||||
|
||||
for (i=0;i<gdkdev->info.num_axes;i++)
|
||||
{
|
||||
gdkdev->info.axes[i] = axes[i];
|
||||
gdkdev->axis_for_use[axes[i]] = i;
|
||||
}
|
||||
}
|
||||
|
||||
static GdkTimeCoord *
|
||||
gdk_input_common_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return)
|
||||
{
|
||||
GdkTimeCoord *coords;
|
||||
XDeviceTimeCoord *device_coords;
|
||||
GdkInputWindow *input_window;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
int mode_return;
|
||||
int axis_count_return;
|
||||
int i;
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
input_window = gdk_input_window_find (window);
|
||||
|
||||
g_return_val_if_fail (gdkdev != NULL, NULL);
|
||||
g_return_val_if_fail (gdkdev->xdevice != NULL, NULL);
|
||||
g_return_val_if_fail (input_window != NULL, NULL);
|
||||
|
||||
device_coords = XGetDeviceMotionEvents (gdk_display,
|
||||
gdkdev->xdevice,
|
||||
start, stop,
|
||||
nevents_return, &mode_return,
|
||||
&axis_count_return);
|
||||
|
||||
if (device_coords)
|
||||
{
|
||||
coords = g_new (GdkTimeCoord, *nevents_return);
|
||||
|
||||
for (i=0; i<*nevents_return; i++)
|
||||
{
|
||||
gdk_input_translate_coordinates (gdkdev, input_window,
|
||||
device_coords[i].data,
|
||||
&coords[i].x, &coords[i].y,
|
||||
&coords[i].pressure,
|
||||
&coords[i].xtilt, &coords[i].ytilt);
|
||||
}
|
||||
XFreeDeviceMotionEvents (device_coords);
|
||||
|
||||
return coords;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_common_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GdkInputWindow *input_window;
|
||||
XDeviceState *state;
|
||||
XInputClass *input_class;
|
||||
gint x_int, y_int;
|
||||
gint i;
|
||||
|
||||
/* we probably need to get the mask in any case */
|
||||
|
||||
if (deviceid == GDK_CORE_POINTER)
|
||||
{
|
||||
gdk_window_get_pointer (window, &x_int, &y_int, mask);
|
||||
if (x) *x = x_int;
|
||||
if (y) *y = y_int;
|
||||
if (pressure) *pressure = 0.5;
|
||||
if (xtilt) *xtilt = 0;
|
||||
if (ytilt) *ytilt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mask)
|
||||
gdk_window_get_pointer (window, NULL, NULL, mask);
|
||||
|
||||
gdkdev = gdk_input_find_device (deviceid);
|
||||
input_window = gdk_input_window_find (window);
|
||||
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
g_return_if_fail (gdkdev->xdevice != NULL);
|
||||
g_return_if_fail (input_window != NULL);
|
||||
|
||||
state = XQueryDeviceState (gdk_display, gdkdev->xdevice);
|
||||
input_class = state->data;
|
||||
for (i=0; i<state->num_classes; i++)
|
||||
{
|
||||
switch (input_class->class)
|
||||
{
|
||||
case ValuatorClass:
|
||||
gdk_input_translate_coordinates(gdkdev, input_window,
|
||||
((XValuatorState *)input_class)->valuators,
|
||||
x, y, pressure,
|
||||
xtilt, ytilt);
|
||||
|
||||
|
||||
break;
|
||||
case ButtonClass:
|
||||
if (mask)
|
||||
{
|
||||
*mask &= ~(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK |
|
||||
GDK_BUTTON3_MASK | GDK_BUTTON4_MASK |
|
||||
GDK_BUTTON5_MASK);
|
||||
for (i=0; i < ((XButtonState *)input_class)->num_buttons; i++)
|
||||
{
|
||||
if (((XButtonState *)input_class)->buttons[i])
|
||||
*mask |= GDK_BUTTON1_MASK << i;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
input_class = (XInputClass *)(((char *)input_class)+input_class->length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
368
gdk/x11/gdkinput-xfree.c
Normal file
368
gdk/x11/gdkinput-xfree.c
Normal file
@ -0,0 +1,368 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef XINPUT_XFREE
|
||||
|
||||
/* forward declarations */
|
||||
|
||||
static gint gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode);
|
||||
static void gdk_input_check_proximity();
|
||||
static void gdk_input_xfree_configure_event (XConfigureEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static void gdk_input_xfree_enter_event (XCrossingEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static gint gdk_input_xfree_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkWindow *window);
|
||||
static gint gdk_input_xfree_enable_window(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_xfree_disable_window(GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_xfree_grab_pointer (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time);
|
||||
static void gdk_input_xfree_ungrab_pointer (guint32 time);
|
||||
|
||||
void
|
||||
gdk_input_init(void)
|
||||
{
|
||||
gdk_input_vtable.set_mode = gdk_input_xfree_set_mode;
|
||||
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
|
||||
gdk_input_vtable.motion_events = gdk_input_common_motion_events;
|
||||
gdk_input_vtable.get_pointer = gdk_input_common_get_pointer;
|
||||
gdk_input_vtable.grab_pointer = gdk_input_xfree_grab_pointer;
|
||||
gdk_input_vtable.ungrab_pointer = gdk_input_xfree_ungrab_pointer;
|
||||
gdk_input_vtable.configure_event = gdk_input_xfree_configure_event;
|
||||
gdk_input_vtable.enter_event = gdk_input_xfree_enter_event;
|
||||
gdk_input_vtable.other_event = gdk_input_xfree_other_event;
|
||||
gdk_input_vtable.window_none_event = NULL;
|
||||
gdk_input_vtable.enable_window = gdk_input_xfree_enable_window;
|
||||
gdk_input_vtable.disable_window = gdk_input_xfree_disable_window;
|
||||
|
||||
gdk_input_ignore_core = FALSE;
|
||||
gdk_input_common_init(FALSE);
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GdkInputMode old_mode;
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
gdkdev = gdk_input_find_device(deviceid);
|
||||
g_return_val_if_fail (gdkdev != NULL,FALSE);
|
||||
old_mode = gdkdev->info.mode;
|
||||
|
||||
if (gdkdev->info.mode == mode)
|
||||
return TRUE;
|
||||
|
||||
gdkdev->info.mode = mode;
|
||||
|
||||
if (mode == GDK_MODE_WINDOW)
|
||||
{
|
||||
gdkdev->info.has_cursor = FALSE;
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
|
||||
gdk_input_enable_window (input_window->window, gdkdev);
|
||||
else
|
||||
if (old_mode != GDK_MODE_DISABLED)
|
||||
gdk_input_disable_window (input_window->window, gdkdev);
|
||||
}
|
||||
}
|
||||
else if (mode == GDK_MODE_SCREEN)
|
||||
{
|
||||
gdkdev->info.has_cursor = TRUE;
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
gdk_input_enable_window (((GdkInputWindow *)tmp_list->data)->window,
|
||||
gdkdev);
|
||||
}
|
||||
else /* mode == GDK_MODE_DISABLED */
|
||||
{
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (old_mode != GDK_MODE_WINDOW ||
|
||||
input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
|
||||
gdk_input_disable_window (input_window->window, gdkdev);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_check_proximity()
|
||||
{
|
||||
gint new_proximity = 0;
|
||||
GList *tmp_list = gdk_input_devices;
|
||||
|
||||
while (tmp_list && !new_proximity)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
||||
|
||||
if (gdkdev->info.mode != GDK_MODE_DISABLED
|
||||
&& gdkdev->info.deviceid != GDK_CORE_POINTER
|
||||
&& gdkdev->xdevice)
|
||||
{
|
||||
XDeviceState *state = XQueryDeviceState(GDK_DISPLAY(),
|
||||
gdkdev->xdevice);
|
||||
XInputClass *xic;
|
||||
int i;
|
||||
|
||||
xic = state->data;
|
||||
for (i=0; i<state->num_classes; i++)
|
||||
{
|
||||
if (xic->class == ValuatorClass)
|
||||
{
|
||||
XValuatorState *xvs = (XValuatorState *)xic;
|
||||
if ((xvs->mode & ProximityState) == InProximity)
|
||||
{
|
||||
new_proximity = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
xic = (XInputClass *)((char *)xic + xic->length);
|
||||
}
|
||||
}
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
gdk_input_ignore_core = new_proximity;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_xfree_configure_event (XConfigureEvent *xevent, GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
gint root_x, root_y;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_if_fail (window != NULL);
|
||||
|
||||
gdk_input_get_root_relative_geometry(GDK_DISPLAY(),GDK_WINDOW_XWINDOW(window),
|
||||
&root_x,
|
||||
&root_y, NULL, NULL);
|
||||
|
||||
input_window->root_x = root_x;
|
||||
input_window->root_y = root_y;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_xfree_enter_event (XCrossingEvent *xevent,
|
||||
GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
gint root_x, root_y;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_if_fail (window != NULL);
|
||||
|
||||
gdk_input_check_proximity();
|
||||
|
||||
gdk_input_get_root_relative_geometry(GDK_DISPLAY(),GDK_WINDOW_XWINDOW(window),
|
||||
&root_x,
|
||||
&root_y, NULL, NULL);
|
||||
|
||||
input_window->root_x = root_x;
|
||||
input_window->root_y = root_y;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_other_event (GdkEvent *event,
|
||||
XEvent *xevent,
|
||||
GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
GdkDevicePrivate *gdkdev;
|
||||
gint return_val;
|
||||
|
||||
input_window = gdk_input_window_find(window);
|
||||
g_return_val_if_fail (window != NULL, -1);
|
||||
|
||||
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
|
||||
but it's potentially faster than scanning through the types of
|
||||
every device. If we were deceived, then it won't match any of
|
||||
the types for the device anyways */
|
||||
gdkdev = gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
|
||||
|
||||
if (!gdkdev) {
|
||||
return -1; /* we don't handle it - not an XInput event */
|
||||
}
|
||||
|
||||
/* FIXME: It would be nice if we could just get rid of the events
|
||||
entirely, instead of having to ignore them */
|
||||
if (gdkdev->info.mode == GDK_MODE_DISABLED ||
|
||||
(gdkdev->info.mode == GDK_MODE_WINDOW
|
||||
&& input_window->mode == GDK_EXTENSION_EVENTS_CURSOR))
|
||||
return FALSE;
|
||||
|
||||
if (!gdk_input_ignore_core)
|
||||
gdk_input_check_proximity();
|
||||
|
||||
return_val = gdk_input_common_other_event (event, xevent,
|
||||
input_window, gdkdev);
|
||||
|
||||
if (return_val > 0 && event->type == GDK_PROXIMITY_OUT &&
|
||||
gdk_input_ignore_core)
|
||||
gdk_input_check_proximity();
|
||||
|
||||
/* Do a passive button grab. We have to be careful not to release
|
||||
an explicit grab, if any. Doubling the grab should be harmless,
|
||||
but we check anyways. */
|
||||
|
||||
/* FIXME, finding the proper events here is going to be SLOW - but
|
||||
we might have different sets for each window/device combination */
|
||||
|
||||
if (return_val> 0 && !input_window->grabbed)
|
||||
{
|
||||
if (event->type == GDK_BUTTON_PRESS)
|
||||
{
|
||||
XEventClass event_classes[6];
|
||||
gint num_classes;
|
||||
|
||||
gdk_input_common_find_events (window, gdkdev,
|
||||
((GdkWindowPrivate *)window)->extension_events,
|
||||
event_classes, &num_classes);
|
||||
|
||||
XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
|
||||
GDK_WINDOW_XWINDOW (window),
|
||||
TRUE, num_classes, event_classes,
|
||||
GrabModeAsync, GrabModeAsync, event->button.time);
|
||||
}
|
||||
else if (event->type == GDK_BUTTON_RELEASE)
|
||||
XUngrabDevice( GDK_DISPLAY(), gdkdev->xdevice, event->button.time);
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_enable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
/* FIXME: watchout, gdkdev might be core pointer, never opened */
|
||||
gdk_input_common_select_events (window, gdkdev);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
gdk_input_common_select_events (window, gdkdev);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_xfree_grab_pointer (GdkWindow * window,
|
||||
gint owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window, *new_window;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GList *tmp_list;
|
||||
XEventClass event_classes[6];
|
||||
gint num_classes;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
new_window = NULL;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
return AlreadyGrabbed;
|
||||
|
||||
if (input_window->window == window)
|
||||
{
|
||||
new_window = input_window;
|
||||
break;
|
||||
}
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
g_return_if_fail (new_window == NULL);
|
||||
|
||||
new_window->grabbed = TRUE;
|
||||
|
||||
tmp_list = gdk_input_devices;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
|
||||
gdkdev->xdevice && !gdkdev->button_state)
|
||||
{
|
||||
gdk_input_common_find_events (window, gdkdev,
|
||||
((GdkWindowPrivate *)window)->extension_events,
|
||||
event_classes, &num_classes);
|
||||
|
||||
/* FIXME: we should do something on failure */
|
||||
XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
|
||||
GDK_WINDOW_XWINDOW (window),
|
||||
TRUE, num_classes, event_classes,
|
||||
GrabModeAsync, GrabModeAsync, time);
|
||||
}
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_input_xfree_ungrab_pointer (guint32 time)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
GList *tmp_list;
|
||||
|
||||
tmp_list = gdk_input_windows;
|
||||
while (tmp_list)
|
||||
{
|
||||
input_window = (GdkInputWindow *)tmp_list->data;
|
||||
if (input_window->grabbed)
|
||||
break;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
if (tmp_list) /* we found a grabbed window */
|
||||
{
|
||||
input_window->grabbed = FALSE;
|
||||
|
||||
tmp_list = gdk_input_devices;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
|
||||
gdkdev->xdevice && !gdkdev->button_state)
|
||||
{
|
||||
XUngrabDevice( gdk_display, gdkdev->xdevice, time);
|
||||
}
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* XINPUT_XFREE */
|
324
gdk/x11/gdkinput.c
Normal file
324
gdk/x11/gdkinput.c
Normal file
@ -0,0 +1,324 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "../config.h"
|
||||
#include "gdk.h"
|
||||
#include "gdkx.h"
|
||||
#include "gdkprivate.h"
|
||||
#include "gdkinput.h"
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
|
||||
static gint gdk_input_enable_window (GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static gint gdk_input_disable_window (GdkWindow *window,
|
||||
GdkDevicePrivate *gdkdev);
|
||||
static GdkInputWindow *gdk_input_window_find (GdkWindow *window);
|
||||
static GdkDevicePrivate *gdk_input_find_device (guint32 id);
|
||||
|
||||
|
||||
/* Incorporate the specific routines depending on compilation options */
|
||||
|
||||
static GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y };
|
||||
|
||||
static GdkDeviceInfo gdk_input_core_info =
|
||||
{
|
||||
GDK_CORE_POINTER,
|
||||
"Core Pointer",
|
||||
GDK_SOURCE_MOUSE,
|
||||
GDK_MODE_SCREEN,
|
||||
TRUE,
|
||||
2,
|
||||
gdk_input_core_axes
|
||||
};
|
||||
|
||||
/* Global variables */
|
||||
|
||||
GdkInputVTable gdk_input_vtable;
|
||||
/* information about network port and host for gxid daemon */
|
||||
gchar *gdk_input_gxid_host;
|
||||
gint gdk_input_gxid_port;
|
||||
gint gdk_input_ignore_core;
|
||||
|
||||
/* Local variables */
|
||||
|
||||
static GList *gdk_input_devices;
|
||||
static GList *gdk_input_windows;
|
||||
|
||||
#include "gdkinputnone.h"
|
||||
#include "gdkinputcommon.h"
|
||||
#include "gdkinputxfree.h"
|
||||
#include "gdkinputgxi.h"
|
||||
|
||||
GList *
|
||||
gdk_input_list_devices ()
|
||||
{
|
||||
return gdk_input_devices;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_set_source (guint32 deviceid, GdkInputSource source)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
|
||||
g_return_if_fail (gdkdev != NULL);
|
||||
|
||||
gdkdev->info.source = source;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_input_set_mode (guint32 deviceid, GdkInputMode mode)
|
||||
{
|
||||
if (deviceid == GDK_CORE_POINTER)
|
||||
return FALSE;
|
||||
|
||||
if (gdk_input_vtable.set_mode)
|
||||
return gdk_input_vtable.set_mode(deviceid,mode);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_set_axes (guint32 deviceid, GdkAxisUse *axes)
|
||||
{
|
||||
if (deviceid != GDK_CORE_POINTER && gdk_input_vtable.set_axes)
|
||||
gdk_input_vtable.set_axes (deviceid, axes);
|
||||
}
|
||||
|
||||
GdkTimeCoord *
|
||||
gdk_input_motion_events (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
guint32 start,
|
||||
guint32 stop,
|
||||
gint *nevents_return)
|
||||
{
|
||||
XTimeCoord *xcoords;
|
||||
GdkTimeCoord *coords;
|
||||
int i;
|
||||
|
||||
if (deviceid == GDK_CORE_POINTER)
|
||||
{
|
||||
xcoords = XGetMotionEvents (gdk_display,
|
||||
((GdkWindowPrivate *)window)->xwindow,
|
||||
start, stop, nevents_return);
|
||||
if (xcoords)
|
||||
{
|
||||
coords = g_new (GdkTimeCoord, *nevents_return);
|
||||
for (i=0; i<*nevents_return; i++)
|
||||
{
|
||||
coords[i].time = xcoords[i].time;
|
||||
coords[i].x = xcoords[i].x;
|
||||
coords[i].y = xcoords[i].y;
|
||||
coords[i].pressure = 0.5;
|
||||
coords[i].xtilt = 0.0;
|
||||
coords[i].ytilt = 0.0;
|
||||
}
|
||||
|
||||
XFree(xcoords);
|
||||
|
||||
return coords;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gdk_input_vtable.motion_events)
|
||||
{
|
||||
return gdk_input_vtable.motion_events(window,
|
||||
deviceid, start, stop,
|
||||
nevents_return);
|
||||
}
|
||||
else
|
||||
{
|
||||
*nevents_return = 0;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
if (gdk_input_vtable.enable_window)
|
||||
return gdk_input_vtable.enable_window (window, gdkdev);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_input_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
|
||||
{
|
||||
if (gdk_input_vtable.disable_window)
|
||||
return gdk_input_vtable.disable_window(window,gdkdev);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static GdkInputWindow *
|
||||
gdk_input_window_find(GdkWindow *window)
|
||||
{
|
||||
GList *tmp_list;
|
||||
|
||||
for (tmp_list=gdk_input_windows; tmp_list; tmp_list=tmp_list->next)
|
||||
if (((GdkInputWindow *)(tmp_list->data))->window == window)
|
||||
return (GdkInputWindow *)(tmp_list->data);
|
||||
|
||||
return NULL; /* Not found */
|
||||
}
|
||||
|
||||
/* FIXME: this routine currently needs to be called between creation
|
||||
and the corresponding configure event (because it doesn't get the
|
||||
root_relative_geometry). This should work with
|
||||
gtk_window_set_extension_events, but will likely fail in other
|
||||
cases */
|
||||
|
||||
void
|
||||
gdk_input_set_extension_events (GdkWindow *window, gint mask,
|
||||
GdkExtensionMode mode)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GdkInputWindow *iw;
|
||||
|
||||
g_return_if_fail (window != NULL);
|
||||
|
||||
if (mode == GDK_EXTENSION_EVENTS_NONE)
|
||||
mask = 0;
|
||||
|
||||
if (mask != 0)
|
||||
{
|
||||
iw = g_new(GdkInputWindow,1);
|
||||
|
||||
iw->window = window;
|
||||
iw->mode = mode;
|
||||
|
||||
iw->obscuring = NULL;
|
||||
iw->num_obscuring = 0;
|
||||
iw->grabbed = FALSE;
|
||||
|
||||
gdk_input_windows = g_list_append(gdk_input_windows,iw);
|
||||
((GdkWindowPrivate *)window)->extension_events = mask;
|
||||
|
||||
/* Add enter window events to the event mask */
|
||||
/* FIXME, this is not needed for XINPUT_NONE */
|
||||
gdk_window_set_events (window,
|
||||
gdk_window_get_events (window) |
|
||||
GDK_ENTER_NOTIFY_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
iw = gdk_input_window_find (window);
|
||||
if (iw)
|
||||
{
|
||||
gdk_input_windows = g_list_remove(gdk_input_windows,iw);
|
||||
g_free(iw);
|
||||
}
|
||||
|
||||
((GdkWindowPrivate *)window)->extension_events = 0;
|
||||
}
|
||||
|
||||
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
||||
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
|
||||
{
|
||||
if (mask != 0 && gdkdev->info.mode != GDK_MODE_DISABLED
|
||||
&& (gdkdev->info.has_cursor || mode == GDK_EXTENSION_EVENTS_ALL))
|
||||
gdk_input_enable_window(window,gdkdev);
|
||||
else
|
||||
gdk_input_disable_window(window,gdkdev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_window_destroy (GdkWindow *window)
|
||||
{
|
||||
GdkInputWindow *input_window;
|
||||
|
||||
input_window = gdk_input_window_find (window);
|
||||
g_return_if_fail (input_window != NULL);
|
||||
|
||||
gdk_input_windows = g_list_remove(gdk_input_windows,input_window);
|
||||
g_free(input_window);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_exit (void)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
|
||||
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
||||
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
|
||||
{
|
||||
gdk_input_set_mode(gdkdev->info.deviceid,GDK_MODE_DISABLED);
|
||||
|
||||
g_free(gdkdev->info.name);
|
||||
#ifndef XINPUT_NONE
|
||||
g_free(gdkdev->axes);
|
||||
#endif
|
||||
g_free(gdkdev->info.axes);
|
||||
g_free(gdkdev);
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free(gdk_input_devices);
|
||||
|
||||
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
g_free(tmp_list->data);
|
||||
}
|
||||
g_list_free(gdk_input_windows);
|
||||
}
|
||||
|
||||
static GdkDevicePrivate *
|
||||
gdk_input_find_device(guint32 id)
|
||||
{
|
||||
GList *tmp_list = gdk_input_devices;
|
||||
GdkDevicePrivate *gdkdev;
|
||||
while (tmp_list)
|
||||
{
|
||||
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
||||
if (gdkdev->info.deviceid == id)
|
||||
return gdkdev;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_input_window_get_pointer (GdkWindow *window,
|
||||
guint32 deviceid,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *pressure,
|
||||
gdouble *xtilt,
|
||||
gdouble *ytilt,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
if (gdk_input_vtable.get_pointer)
|
||||
gdk_input_vtable.get_pointer (window, deviceid, x, y, pressure,
|
||||
xtilt, ytilt, mask);
|
||||
}
|
2897
gdk/x11/gdkmain-x11.c
Normal file
2897
gdk/x11/gdkmain-x11.c
Normal file
File diff suppressed because it is too large
Load Diff
657
gdk/x11/gdkpixmap-x11.c
Normal file
657
gdk/x11/gdkpixmap-x11.c
Normal file
@ -0,0 +1,657 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include "../config.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *color_string;
|
||||
GdkColor color;
|
||||
gint transparent;
|
||||
} _GdkPixmapColor;
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_new (GdkWindow *window,
|
||||
gint width,
|
||||
gint height,
|
||||
gint depth)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkWindowPrivate *private;
|
||||
GdkWindowPrivate *window_private;
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
if (depth == -1)
|
||||
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
|
||||
|
||||
private = g_new (GdkWindowPrivate, 1);
|
||||
pixmap = (GdkPixmap*) private;
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
|
||||
private->xdisplay = window_private->xdisplay;
|
||||
private->window_type = GDK_WINDOW_PIXMAP;
|
||||
private->xwindow = XCreatePixmap (private->xdisplay, window_private->xwindow,
|
||||
width, height, depth);
|
||||
private->parent = NULL;
|
||||
private->x = 0;
|
||||
private->y = 0;
|
||||
private->width = width;
|
||||
private->height = height;
|
||||
private->resize_count = 0;
|
||||
private->ref_count = 1;
|
||||
private->destroyed = 0;
|
||||
|
||||
gdk_xid_table_insert (&private->xwindow, pixmap);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap *
|
||||
gdk_bitmap_create_from_data (GdkWindow *window,
|
||||
gchar *data,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkWindowPrivate *private;
|
||||
GdkWindowPrivate *window_private;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
private = g_new (GdkWindowPrivate, 1);
|
||||
pixmap = (GdkPixmap*) private;
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
|
||||
private->parent = NULL;
|
||||
private->xdisplay = window_private->xdisplay;
|
||||
private->window_type = GDK_WINDOW_PIXMAP;
|
||||
private->x = 0;
|
||||
private->y = 0;
|
||||
private->width = width;
|
||||
private->height = height;
|
||||
private->resize_count = 0;
|
||||
private->ref_count = 1;
|
||||
private->destroyed = FALSE;
|
||||
|
||||
private->xwindow = XCreateBitmapFromData (private->xdisplay,
|
||||
window_private->xwindow,
|
||||
data, width, height);
|
||||
|
||||
gdk_xid_table_insert (&private->xwindow, pixmap);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_data (GdkWindow *window,
|
||||
gchar *data,
|
||||
gint width,
|
||||
gint height,
|
||||
gint depth,
|
||||
GdkColor *fg,
|
||||
GdkColor *bg)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkWindowPrivate *private;
|
||||
GdkWindowPrivate *window_private;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
g_return_val_if_fail (fg != NULL, NULL);
|
||||
g_return_val_if_fail (bg != NULL, NULL);
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
if (depth == -1)
|
||||
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
|
||||
|
||||
private = g_new (GdkWindowPrivate, 1);
|
||||
pixmap = (GdkPixmap*) private;
|
||||
|
||||
window_private = (GdkWindowPrivate*) window;
|
||||
|
||||
private->parent = NULL;
|
||||
private->xdisplay = window_private->xdisplay;
|
||||
private->window_type = GDK_WINDOW_PIXMAP;
|
||||
private->x = 0;
|
||||
private->y = 0;
|
||||
private->width = width;
|
||||
private->height = height;
|
||||
private->resize_count = 0;
|
||||
private->ref_count = 1;
|
||||
private->destroyed = FALSE;
|
||||
|
||||
private->xwindow = XCreatePixmapFromBitmapData (private->xdisplay,
|
||||
window_private->xwindow,
|
||||
data, width, height,
|
||||
fg->pixel, bg->pixel, depth);
|
||||
|
||||
gdk_xid_table_insert (&private->xwindow, pixmap);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_pixmap_seek_string (FILE *infile,
|
||||
const gchar *str,
|
||||
gint skip_comments)
|
||||
{
|
||||
char instr[1024];
|
||||
|
||||
while (!feof (infile))
|
||||
{
|
||||
fscanf (infile, "%s", instr);
|
||||
if (skip_comments == TRUE && strcmp (instr, "/*") == 0)
|
||||
{
|
||||
fscanf (infile, "%s", instr);
|
||||
while (!feof (infile) && strcmp (instr, "*/") != 0)
|
||||
fscanf (infile, "%s", instr);
|
||||
fscanf(infile, "%s", instr);
|
||||
}
|
||||
if (strcmp (instr, str)==0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_pixmap_seek_char (FILE *infile,
|
||||
gchar c)
|
||||
{
|
||||
gchar b, oldb;
|
||||
|
||||
while (!feof (infile))
|
||||
{
|
||||
fscanf(infile, "%c", &b);
|
||||
if (c != b && b == '/')
|
||||
{
|
||||
fscanf (infile, "%c", &b);
|
||||
if (b == '*')
|
||||
{
|
||||
oldb = b;
|
||||
while (!feof (infile) && !(oldb == '*' && b == '/'))
|
||||
{
|
||||
oldb = b;
|
||||
fscanf (infile, "%c", &b);
|
||||
}
|
||||
fscanf (infile, "%c", &b);
|
||||
}
|
||||
}
|
||||
if (c == b)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_pixmap_read_string (FILE *infile,
|
||||
gchar **buffer,
|
||||
int *buffer_size)
|
||||
{
|
||||
gchar c;
|
||||
gint cnt = 0;
|
||||
|
||||
if ((*buffer) == NULL)
|
||||
{
|
||||
(*buffer_size) = 10 * sizeof (gchar);
|
||||
(*buffer) = (gchar *) malloc (*buffer_size);
|
||||
}
|
||||
|
||||
do
|
||||
fscanf (infile, "%c", &c);
|
||||
while (!feof (infile) && c != '"');
|
||||
|
||||
if (c != '"')
|
||||
return FALSE;
|
||||
|
||||
while (!feof (infile))
|
||||
{
|
||||
fscanf (infile, "%c", &c);
|
||||
|
||||
if (cnt == (*buffer_size))
|
||||
{
|
||||
(*buffer_size) *= 2;
|
||||
(*buffer) = (gchar *) realloc ((*buffer), *buffer_size);
|
||||
}
|
||||
|
||||
if (c != '"')
|
||||
(*buffer)[cnt++] = c;
|
||||
else
|
||||
{
|
||||
(*buffer)[cnt++] = 0;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gchar*
|
||||
gdk_pixmap_skip_whitespaces (gchar *buffer)
|
||||
{
|
||||
gint32 index = 0;
|
||||
|
||||
while (buffer[index] != 0 && (buffer[index] == 0x20 || buffer[index] == 0x09))
|
||||
index++;
|
||||
|
||||
return &buffer[index];
|
||||
}
|
||||
|
||||
gchar*
|
||||
gdk_pixmap_skip_string (gchar *buffer)
|
||||
{
|
||||
gint32 index = 0;
|
||||
|
||||
while (buffer[index] != 0 && buffer[index] != 0x20 && buffer[index] != 0x09)
|
||||
index++;
|
||||
|
||||
return &buffer[index];
|
||||
}
|
||||
|
||||
gchar*
|
||||
gdk_pixmap_extract_color (gchar *buffer)
|
||||
{
|
||||
gint counter, finished = FALSE, numnames;
|
||||
gchar *ptr = NULL, ch, temp[128];
|
||||
gchar color[128], *retcol;
|
||||
|
||||
counter = 0;
|
||||
while (ptr == NULL)
|
||||
{
|
||||
if (buffer[counter] == 'c')
|
||||
{
|
||||
ch = buffer[counter + 1];
|
||||
if (ch == 0x20 || ch == 0x09)
|
||||
ptr = &buffer[counter + 1];
|
||||
}
|
||||
else if (buffer[counter] == 0)
|
||||
return NULL;
|
||||
|
||||
counter++;
|
||||
}
|
||||
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
ptr = gdk_pixmap_skip_whitespaces (ptr);
|
||||
|
||||
if (ptr[0] == 0)
|
||||
return NULL;
|
||||
else if (ptr[0] == '#')
|
||||
{
|
||||
retcol = g_new(gchar, strlen (ptr) + 1);
|
||||
strcpy (retcol, ptr);
|
||||
return retcol;
|
||||
}
|
||||
|
||||
color[0] = 0;
|
||||
numnames = 0;
|
||||
|
||||
while (finished == FALSE)
|
||||
{
|
||||
sscanf (ptr, "%s", temp);
|
||||
|
||||
if ((gint)ptr[0] == 0 || strcmp ("s", temp) == 0 || strcmp ("m", temp) == 0 ||
|
||||
strcmp ("g", temp) == 0 || strcmp ("g4", temp) == 0)
|
||||
finished = TRUE;
|
||||
else
|
||||
{
|
||||
if (numnames > 0)
|
||||
strcat (color, " ");
|
||||
strcat (color, temp);
|
||||
ptr = gdk_pixmap_skip_string (ptr);
|
||||
ptr = gdk_pixmap_skip_whitespaces (ptr);
|
||||
numnames++;
|
||||
}
|
||||
}
|
||||
|
||||
retcol = g_new(gchar, strlen (color) + 1);
|
||||
strcpy (retcol, color);
|
||||
return retcol;
|
||||
}
|
||||
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_xpm (GdkWindow *window,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
const gchar *filename)
|
||||
{
|
||||
FILE *infile = NULL;
|
||||
GdkPixmap *pixmap = NULL;
|
||||
GdkImage *image = NULL;
|
||||
GdkColormap *colormap;
|
||||
GdkVisual *visual;
|
||||
GdkGC *gc;
|
||||
GdkColor tmp_color;
|
||||
gint width, height, num_cols, cpp, cnt, n, ns, xcnt, ycnt;
|
||||
gchar *buffer = NULL, *color_name = NULL, pixel_str[32];
|
||||
guint buffer_size = 0;
|
||||
_GdkPixmapColor *colors = NULL, *color = NULL;
|
||||
gulong index;
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
infile = fopen (filename, "rb");
|
||||
if (infile != NULL)
|
||||
{
|
||||
if (gdk_pixmap_seek_string (infile, "XPM", FALSE) == TRUE)
|
||||
{
|
||||
if (gdk_pixmap_seek_char (infile,'{') == TRUE)
|
||||
{
|
||||
gdk_pixmap_seek_char (infile, '"');
|
||||
fseek (infile, -1, SEEK_CUR);
|
||||
gdk_pixmap_read_string (infile, &buffer, &buffer_size);
|
||||
|
||||
sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp);
|
||||
|
||||
colors = g_new(_GdkPixmapColor, num_cols);
|
||||
|
||||
colormap = gdk_window_get_colormap (window);
|
||||
visual = gdk_window_get_visual (window);
|
||||
|
||||
if (transparent_color == NULL)
|
||||
{
|
||||
gdk_color_white (colormap, &tmp_color);
|
||||
transparent_color = &tmp_color;
|
||||
}
|
||||
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
{
|
||||
gdk_pixmap_seek_char (infile, '"');
|
||||
fseek (infile, -1, SEEK_CUR);
|
||||
gdk_pixmap_read_string (infile, &buffer, &buffer_size);
|
||||
|
||||
colors[cnt].color_string = g_new(gchar, cpp + 1);
|
||||
for (n = 0; n < cpp; n++)
|
||||
colors[cnt].color_string[n] = buffer[n];
|
||||
colors[cnt].color_string[n] = 0;
|
||||
colors[cnt].transparent = FALSE;
|
||||
|
||||
if (color_name != NULL)
|
||||
g_free (color_name);
|
||||
|
||||
color_name = gdk_pixmap_extract_color (&buffer[cpp]);
|
||||
|
||||
if (color_name != NULL)
|
||||
{
|
||||
if (gdk_color_parse (color_name, &colors[cnt].color) == FALSE)
|
||||
{
|
||||
colors[cnt].color = *transparent_color;
|
||||
colors[cnt].transparent = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
colors[cnt].color = *transparent_color;
|
||||
colors[cnt].transparent = TRUE;
|
||||
}
|
||||
|
||||
gdk_color_alloc (colormap, &colors[cnt].color);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
image = gdk_image_new (GDK_IMAGE_FASTEST, visual, width, height);
|
||||
|
||||
gc = NULL;
|
||||
if (mask)
|
||||
{
|
||||
*mask = gdk_pixmap_new (window, width, height, 1);
|
||||
gc = gdk_gc_new (*mask);
|
||||
|
||||
gdk_color_black (colormap, &tmp_color);
|
||||
gdk_gc_set_foreground (gc, &tmp_color);
|
||||
gdk_draw_rectangle (*mask, gc, TRUE, 0, 0, -1, -1);
|
||||
|
||||
gdk_color_white (colormap, &tmp_color);
|
||||
gdk_gc_set_foreground (gc, &tmp_color);
|
||||
}
|
||||
|
||||
for (ycnt = 0; ycnt < height; ycnt++)
|
||||
{
|
||||
gdk_pixmap_read_string (infile, &buffer, &buffer_size);
|
||||
|
||||
for (n = 0, cnt = 0, xcnt = 0; n < (width * cpp); n += cpp, xcnt++)
|
||||
{
|
||||
strncpy (pixel_str, &buffer[n], cpp);
|
||||
pixel_str[cpp] = 0;
|
||||
color = NULL;
|
||||
ns = 0;
|
||||
|
||||
while (color == NULL)
|
||||
{
|
||||
if (strcmp (pixel_str, colors[ns].color_string) == 0)
|
||||
color = &colors[ns];
|
||||
else
|
||||
ns++;
|
||||
}
|
||||
|
||||
gdk_image_put_pixel (image, xcnt, ycnt, color->color.pixel);
|
||||
|
||||
if (mask && color->transparent)
|
||||
{
|
||||
if (cnt < xcnt)
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
cnt = xcnt + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask && (cnt < xcnt))
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
gdk_gc_destroy (gc);
|
||||
|
||||
pixmap = gdk_pixmap_new (window, width, height, visual->depth);
|
||||
|
||||
gc = gdk_gc_new (pixmap);
|
||||
gdk_gc_set_foreground (gc, transparent_color);
|
||||
gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
|
||||
gdk_gc_destroy (gc);
|
||||
gdk_image_destroy (image);
|
||||
}
|
||||
}
|
||||
|
||||
fclose (infile);
|
||||
free (buffer);
|
||||
|
||||
if (colors != NULL)
|
||||
{
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
g_free (colors[cnt].color_string);
|
||||
g_free (colors);
|
||||
}
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_xpm_d (GdkWindow *window,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
gchar **data)
|
||||
{
|
||||
GdkPixmap *pixmap = NULL;
|
||||
GdkImage *image = NULL;
|
||||
GdkColormap *colormap;
|
||||
GdkVisual *visual;
|
||||
GdkGC *gc;
|
||||
GdkColor tmp_color;
|
||||
gint width, height, num_cols, cpp, cnt, n, ns, xcnt, ycnt, i;
|
||||
gchar *buffer, *color_name = NULL, pixel_str[32];
|
||||
_GdkPixmapColor *colors = NULL, *color = NULL;
|
||||
gulong index;
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
i = 0;
|
||||
buffer = data[i++];
|
||||
sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp);
|
||||
|
||||
colors = g_new(_GdkPixmapColor, num_cols);
|
||||
|
||||
colormap = gdk_window_get_colormap (window);
|
||||
visual = gdk_window_get_visual (window);
|
||||
|
||||
if (transparent_color == NULL)
|
||||
{
|
||||
gdk_color_white (colormap, &tmp_color);
|
||||
transparent_color = &tmp_color;
|
||||
}
|
||||
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
{
|
||||
buffer = data[i++];
|
||||
|
||||
colors[cnt].color_string = g_new(gchar, cpp + 1);
|
||||
for (n = 0; n < cpp; n++)
|
||||
colors[cnt].color_string[n] = buffer[n];
|
||||
colors[cnt].color_string[n] = 0;
|
||||
colors[cnt].transparent = FALSE;
|
||||
|
||||
if (color_name != NULL)
|
||||
g_free (color_name);
|
||||
|
||||
color_name = gdk_pixmap_extract_color (&buffer[cpp]);
|
||||
|
||||
if (color_name != NULL)
|
||||
{
|
||||
if (gdk_color_parse (color_name, &colors[cnt].color) == FALSE)
|
||||
{
|
||||
colors[cnt].color = *transparent_color;
|
||||
colors[cnt].transparent = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
colors[cnt].color = *transparent_color;
|
||||
colors[cnt].transparent = TRUE;
|
||||
}
|
||||
|
||||
gdk_color_alloc (colormap, &colors[cnt].color);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
image = gdk_image_new (GDK_IMAGE_FASTEST, visual, width, height);
|
||||
|
||||
gc = NULL;
|
||||
if (mask)
|
||||
{
|
||||
*mask = gdk_pixmap_new (window, width, height, 1);
|
||||
gc = gdk_gc_new (*mask);
|
||||
|
||||
gdk_color_black (colormap, &tmp_color);
|
||||
gdk_gc_set_foreground (gc, &tmp_color);
|
||||
gdk_draw_rectangle (*mask, gc, TRUE, 0, 0, -1, -1);
|
||||
|
||||
gdk_color_white (colormap, &tmp_color);
|
||||
gdk_gc_set_foreground (gc, &tmp_color);
|
||||
}
|
||||
|
||||
for (ycnt = 0; ycnt < height; ycnt++)
|
||||
{
|
||||
buffer = data[i++];
|
||||
|
||||
for (n = 0, cnt = 0, xcnt = 0; n < (width * cpp); n += cpp, xcnt++)
|
||||
{
|
||||
strncpy (pixel_str, &buffer[n], cpp);
|
||||
pixel_str[cpp] = 0;
|
||||
color = NULL;
|
||||
ns = 0;
|
||||
|
||||
while (color == NULL)
|
||||
{
|
||||
if (strcmp (pixel_str, colors[ns].color_string) == 0)
|
||||
color = &colors[ns];
|
||||
else
|
||||
ns++;
|
||||
}
|
||||
|
||||
gdk_image_put_pixel (image, xcnt, ycnt, color->color.pixel);
|
||||
|
||||
if (mask && color->transparent)
|
||||
{
|
||||
if (cnt < xcnt)
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
cnt = xcnt + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask && (cnt < xcnt))
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
gdk_gc_destroy (gc);
|
||||
|
||||
pixmap = gdk_pixmap_new (window, width, height, visual->depth);
|
||||
|
||||
gc = gdk_gc_new (pixmap);
|
||||
gdk_gc_set_foreground (gc, transparent_color);
|
||||
gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
|
||||
gdk_gc_destroy (gc);
|
||||
gdk_image_destroy (image);
|
||||
|
||||
if (colors != NULL)
|
||||
{
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
g_free (colors[cnt].color_string);
|
||||
g_free (colors);
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_pixmap_destroy (GdkPixmap *pixmap)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
|
||||
g_return_if_fail (pixmap != NULL);
|
||||
|
||||
private = (GdkPixmapPrivate*) pixmap;
|
||||
if (private->ref_count <= 0)
|
||||
{
|
||||
XFreePixmap (private->xdisplay, private->xwindow);
|
||||
gdk_xid_table_remove (private->xwindow);
|
||||
g_free (pixmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
private->ref_count -= 1;
|
||||
}
|
||||
}
|
194
gdk/x11/gdkproperty-x11.c
Normal file
194
gdk/x11/gdkproperty-x11.c
Normal file
@ -0,0 +1,194 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <string.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
GdkAtom
|
||||
gdk_atom_intern (const gchar *atom_name,
|
||||
gint only_if_exists)
|
||||
{
|
||||
return XInternAtom (gdk_display, atom_name, only_if_exists);
|
||||
}
|
||||
|
||||
gchar *
|
||||
gdk_atom_name (GdkAtom atom)
|
||||
{
|
||||
gchar *t;
|
||||
gchar *name;
|
||||
|
||||
/* If this atom doesn't exist, we'll die with an X error unless
|
||||
we take precautions */
|
||||
|
||||
gdk_error_warnings = 0;
|
||||
t = XGetAtomName (gdk_display, atom);
|
||||
gdk_error_warnings = 1;
|
||||
|
||||
if (gdk_error_code == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = g_strdup (t);
|
||||
XFree (t);
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_property_get (GdkWindow *window,
|
||||
GdkAtom property,
|
||||
GdkAtom type,
|
||||
gulong offset,
|
||||
gulong length,
|
||||
gint pdelete,
|
||||
GdkAtom *actual_property_type,
|
||||
gint *actual_format_type,
|
||||
gint *actual_length,
|
||||
guchar **data)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
Display *xdisplay;
|
||||
Window xwindow;
|
||||
Atom ret_prop_type;
|
||||
gint ret_format;
|
||||
gulong ret_nitems;
|
||||
gulong ret_bytes_after;
|
||||
gulong ret_length;
|
||||
guchar *ret_data;
|
||||
|
||||
if (window)
|
||||
{
|
||||
private = (GdkWindowPrivate*) window;
|
||||
xdisplay = private->xdisplay;
|
||||
xwindow = private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdisplay = gdk_display;
|
||||
xwindow = gdk_root_window;
|
||||
}
|
||||
|
||||
XGetWindowProperty (xdisplay, xwindow, property,
|
||||
offset, (length + 3) / 4, pdelete,
|
||||
type, &ret_prop_type, &ret_format,
|
||||
&ret_nitems, &ret_bytes_after,
|
||||
&ret_data);
|
||||
|
||||
if ((ret_prop_type == None) && (ret_format == 0))
|
||||
return FALSE;
|
||||
|
||||
if (actual_property_type)
|
||||
*actual_property_type = ret_prop_type;
|
||||
if (actual_format_type)
|
||||
*actual_format_type = ret_format;
|
||||
|
||||
if (ret_prop_type != property)
|
||||
{
|
||||
XFree (ret_data);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* FIXME: ignoring bytes_after could have very bad effects */
|
||||
|
||||
if (data)
|
||||
{
|
||||
switch (ret_format)
|
||||
{
|
||||
case 8:
|
||||
ret_length = ret_nitems;
|
||||
break;
|
||||
case 16:
|
||||
ret_length = 2 * ret_nitems;
|
||||
break;
|
||||
case 32:
|
||||
ret_length = 4 * ret_nitems;
|
||||
break;
|
||||
default:
|
||||
g_warning ("unknown property return format: %d", ret_format);
|
||||
XFree (ret_data);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*data = g_new (guchar, ret_length);
|
||||
memcpy (*data, ret_data, ret_length);
|
||||
if (actual_length)
|
||||
*actual_length = ret_length;
|
||||
}
|
||||
|
||||
XFree (ret_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_property_change (GdkWindow *window,
|
||||
GdkAtom property,
|
||||
GdkAtom type,
|
||||
gint format,
|
||||
GdkPropMode mode,
|
||||
guchar *data,
|
||||
gint nelements)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
Display *xdisplay;
|
||||
Window xwindow;
|
||||
|
||||
if (window)
|
||||
{
|
||||
private = (GdkWindowPrivate*) window;
|
||||
xdisplay = private->xdisplay;
|
||||
xwindow = private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdisplay = gdk_display;
|
||||
xwindow = gdk_root_window;
|
||||
}
|
||||
|
||||
XChangeProperty (xdisplay, xwindow, property, type,
|
||||
format, mode, data, nelements);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_property_delete (GdkWindow *window,
|
||||
GdkAtom property)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
Display *xdisplay;
|
||||
Window xwindow;
|
||||
|
||||
if (window)
|
||||
{
|
||||
private = (GdkWindowPrivate*) window;
|
||||
xdisplay = private->xdisplay;
|
||||
xwindow = private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdisplay = gdk_display;
|
||||
xwindow = gdk_root_window;
|
||||
}
|
||||
|
||||
XDeleteProperty (xdisplay, xwindow, property);
|
||||
}
|
168
gdk/x11/gdkselection-x11.c
Normal file
168
gdk/x11/gdkselection-x11.c
Normal file
@ -0,0 +1,168 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <string.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
gint
|
||||
gdk_selection_owner_set (GdkWindow *owner,
|
||||
GdkAtom selection,
|
||||
guint32 time,
|
||||
gint send_event)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
Display *xdisplay;
|
||||
Window xwindow;
|
||||
|
||||
if (owner)
|
||||
{
|
||||
private = (GdkWindowPrivate*) owner;
|
||||
xdisplay = private->xdisplay;
|
||||
xwindow = private->xwindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdisplay = gdk_display;
|
||||
xwindow = None;
|
||||
}
|
||||
|
||||
XSetSelectionOwner (xdisplay, selection, xwindow, time);
|
||||
|
||||
return (XGetSelectionOwner (xdisplay, selection) == xwindow);
|
||||
}
|
||||
|
||||
GdkWindow*
|
||||
gdk_selection_owner_get (GdkAtom selection)
|
||||
{
|
||||
Window xwindow;
|
||||
|
||||
xwindow = XGetSelectionOwner (gdk_display, selection);
|
||||
if (xwindow == None)
|
||||
return NULL;
|
||||
|
||||
return gdk_window_lookup (xwindow);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_selection_convert (GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
|
||||
g_return_if_fail (requestor != NULL);
|
||||
|
||||
private = (GdkWindowPrivate*) requestor;
|
||||
|
||||
XConvertSelection (private->xdisplay, selection, target,
|
||||
gdk_selection_property, private->xwindow, time);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_selection_property_get (GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *ret_type,
|
||||
gint *ret_format)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
gulong nitems;
|
||||
gulong nbytes;
|
||||
gulong length;
|
||||
GdkAtom prop_type;
|
||||
gint prop_format;
|
||||
guchar *t;
|
||||
|
||||
g_return_val_if_fail (requestor != NULL, 0);
|
||||
|
||||
/* If retrieved chunks are typically small, (and the ICCM says the
|
||||
should be) it would be a win to try first with a buffer of
|
||||
moderate length, to avoid two round trips to the server */
|
||||
|
||||
private = (GdkWindowPrivate*) requestor;
|
||||
|
||||
XGetWindowProperty (private->xdisplay, private->xwindow,
|
||||
gdk_selection_property, 0, 0, False,
|
||||
AnyPropertyType, &prop_type, &prop_format,
|
||||
&nitems, &nbytes, &t);
|
||||
|
||||
if (ret_type)
|
||||
*ret_type = prop_type;
|
||||
if (ret_format)
|
||||
*ret_format = prop_format;
|
||||
|
||||
if (prop_type == None)
|
||||
{
|
||||
*data = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
XFree (t);
|
||||
|
||||
/* Add on an extra byte to handle null termination. X guarantees
|
||||
that t will be 1 longer than nbytes and null terminated */
|
||||
length = nbytes + 1;
|
||||
|
||||
/* We can't delete the selection here, because it might be the INCR
|
||||
protocol, in which case the client has to make sure they'll be
|
||||
notified of PropertyChange events _before_ the property is deleted.
|
||||
Otherwise there's no guarantee we'll win the race ... */
|
||||
XGetWindowProperty (private->xdisplay, private->xwindow,
|
||||
gdk_selection_property, 0, (nbytes + 3) / 4, False,
|
||||
AnyPropertyType, &prop_type, &prop_format,
|
||||
&nitems, &nbytes, &t);
|
||||
|
||||
if (prop_type != None)
|
||||
{
|
||||
*data = g_new (guchar, length);
|
||||
memcpy (*data, t, length);
|
||||
XFree (t);
|
||||
return length-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*data = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gdk_selection_send_notify (guint32 requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time)
|
||||
{
|
||||
XSelectionEvent xevent;
|
||||
|
||||
xevent.type = SelectionNotify;
|
||||
xevent.serial = 0;
|
||||
xevent.send_event = True;
|
||||
xevent.display = gdk_display;
|
||||
xevent.requestor = requestor;
|
||||
xevent.selection = selection;
|
||||
xevent.target = target;
|
||||
xevent.property = property;
|
||||
xevent.time = time;
|
||||
|
||||
XSendEvent (gdk_display, requestor, False, NoEventMask, (XEvent*) &xevent);
|
||||
}
|
431
gdk/x11/gdkvisual-x11.c
Normal file
431
gdk/x11/gdkvisual-x11.c
Normal file
@ -0,0 +1,431 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "gdk.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
static void gdk_visual_add (GdkVisual *visual);
|
||||
static void gdk_visual_decompose_mask (gulong mask,
|
||||
gint *shift,
|
||||
gint *prec);
|
||||
static guint gdk_visual_hash (Visual *key);
|
||||
static gint gdk_visual_compare (Visual *a,
|
||||
Visual *b);
|
||||
|
||||
|
||||
static GdkVisualPrivate *system_visual;
|
||||
static GdkVisualPrivate *visuals;
|
||||
static gint nvisuals;
|
||||
|
||||
static gint available_depths[4];
|
||||
static gint navailable_depths;
|
||||
|
||||
static GdkVisualType available_types[6];
|
||||
static gint navailable_types;
|
||||
|
||||
static char* visual_names[] =
|
||||
{
|
||||
"static gray",
|
||||
"grayscale",
|
||||
"static color",
|
||||
"pseudo color",
|
||||
"true color",
|
||||
"direct color",
|
||||
};
|
||||
|
||||
static GHashTable *visual_hash = NULL;
|
||||
|
||||
void
|
||||
gdk_visual_init ()
|
||||
{
|
||||
static gint possible_depths[5] = { 32, 24, 16, 15, 8 };
|
||||
static GdkVisualType possible_types[6] =
|
||||
{
|
||||
GDK_VISUAL_DIRECT_COLOR,
|
||||
GDK_VISUAL_TRUE_COLOR,
|
||||
GDK_VISUAL_PSEUDO_COLOR,
|
||||
GDK_VISUAL_STATIC_COLOR,
|
||||
GDK_VISUAL_GRAYSCALE,
|
||||
GDK_VISUAL_STATIC_GRAY
|
||||
};
|
||||
|
||||
static gint npossible_depths = 5;
|
||||
static gint npossible_types = 6;
|
||||
|
||||
XVisualInfo *visual_list;
|
||||
XVisualInfo visual_template;
|
||||
GdkVisualPrivate temp_visual;
|
||||
Visual *default_xvisual;
|
||||
int nxvisuals;
|
||||
int i, j;
|
||||
|
||||
visual_template.screen = gdk_screen;
|
||||
visual_list = XGetVisualInfo (gdk_display, VisualScreenMask, &visual_template, &nxvisuals);
|
||||
visuals = g_new (GdkVisualPrivate, nxvisuals);
|
||||
|
||||
default_xvisual = DefaultVisual (gdk_display, gdk_screen);
|
||||
|
||||
nvisuals = 0;
|
||||
for (i = 0; i < nxvisuals; i++)
|
||||
{
|
||||
if (visual_list[i].depth >= 8)
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
switch (visual_list[i].c_class)
|
||||
#else /* __cplusplus */
|
||||
switch (visual_list[i].class)
|
||||
#endif /* __cplusplus */
|
||||
{
|
||||
case StaticGray:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_STATIC_GRAY;
|
||||
break;
|
||||
case GrayScale:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_GRAYSCALE;
|
||||
break;
|
||||
case StaticColor:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_STATIC_COLOR;
|
||||
break;
|
||||
case PseudoColor:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_PSEUDO_COLOR;
|
||||
break;
|
||||
case TrueColor:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_TRUE_COLOR;
|
||||
break;
|
||||
case DirectColor:
|
||||
visuals[nvisuals].visual.type = GDK_VISUAL_DIRECT_COLOR;
|
||||
break;
|
||||
}
|
||||
|
||||
visuals[nvisuals].visual.depth = visual_list[i].depth;
|
||||
visuals[nvisuals].visual.byte_order =
|
||||
(ImageByteOrder(gdk_display) == LSBFirst) ?
|
||||
GDK_LSB_FIRST : GDK_MSB_FIRST;
|
||||
visuals[nvisuals].visual.red_mask = visual_list[i].red_mask;
|
||||
visuals[nvisuals].visual.green_mask = visual_list[i].green_mask;
|
||||
visuals[nvisuals].visual.blue_mask = visual_list[i].blue_mask;
|
||||
visuals[nvisuals].visual.colormap_size = visual_list[i].colormap_size;
|
||||
visuals[nvisuals].visual.bits_per_rgb = visual_list[i].bits_per_rgb;
|
||||
visuals[nvisuals].xvisual = visual_list[i].visual;
|
||||
|
||||
if ((visuals[nvisuals].visual.type == GDK_VISUAL_TRUE_COLOR) ||
|
||||
(visuals[nvisuals].visual.type == GDK_VISUAL_DIRECT_COLOR))
|
||||
{
|
||||
gdk_visual_decompose_mask (visuals[nvisuals].visual.red_mask,
|
||||
&visuals[nvisuals].visual.red_shift,
|
||||
&visuals[nvisuals].visual.red_prec);
|
||||
|
||||
gdk_visual_decompose_mask (visuals[nvisuals].visual.green_mask,
|
||||
&visuals[nvisuals].visual.green_shift,
|
||||
&visuals[nvisuals].visual.green_prec);
|
||||
|
||||
gdk_visual_decompose_mask (visuals[nvisuals].visual.blue_mask,
|
||||
&visuals[nvisuals].visual.blue_shift,
|
||||
&visuals[nvisuals].visual.blue_prec);
|
||||
}
|
||||
else
|
||||
{
|
||||
visuals[nvisuals].visual.red_mask = 0;
|
||||
visuals[nvisuals].visual.red_shift = 0;
|
||||
visuals[nvisuals].visual.red_prec = 0;
|
||||
|
||||
visuals[nvisuals].visual.green_mask = 0;
|
||||
visuals[nvisuals].visual.green_shift = 0;
|
||||
visuals[nvisuals].visual.green_prec = 0;
|
||||
|
||||
visuals[nvisuals].visual.blue_mask = 0;
|
||||
visuals[nvisuals].visual.blue_shift = 0;
|
||||
visuals[nvisuals].visual.blue_prec = 0;
|
||||
}
|
||||
|
||||
nvisuals += 1;
|
||||
}
|
||||
}
|
||||
|
||||
XFree (visual_list);
|
||||
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
{
|
||||
for (j = i+1; j < nvisuals; j++)
|
||||
{
|
||||
if (visuals[j].visual.depth >= visuals[i].visual.depth)
|
||||
{
|
||||
if ((visuals[j].visual.depth == 8) && (visuals[i].visual.depth == 8))
|
||||
{
|
||||
if (visuals[j].visual.type == GDK_VISUAL_PSEUDO_COLOR)
|
||||
{
|
||||
temp_visual = visuals[j];
|
||||
visuals[j] = visuals[i];
|
||||
visuals[i] = temp_visual;
|
||||
}
|
||||
else if ((visuals[i].visual.type != GDK_VISUAL_PSEUDO_COLOR) &&
|
||||
visuals[j].visual.type > visuals[i].visual.type)
|
||||
{
|
||||
temp_visual = visuals[j];
|
||||
visuals[j] = visuals[i];
|
||||
visuals[i] = temp_visual;
|
||||
}
|
||||
}
|
||||
else if ((visuals[j].visual.depth > visuals[i].visual.depth) ||
|
||||
((visuals[j].visual.depth == visuals[i].visual.depth) &&
|
||||
(visuals[j].visual.type > visuals[i].visual.type)))
|
||||
{
|
||||
temp_visual = visuals[j];
|
||||
visuals[j] = visuals[i];
|
||||
visuals[i] = temp_visual;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if (default_xvisual->visualid == visuals[i].xvisual->visualid)
|
||||
{
|
||||
system_visual = &visuals[i];
|
||||
break;
|
||||
}
|
||||
|
||||
if (gdk_debug_level >= 1)
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
g_print ("visual: %s: %d\n",
|
||||
visual_names[visuals[i].visual.type],
|
||||
visuals[i].visual.depth);
|
||||
|
||||
navailable_depths = 0;
|
||||
for (i = 0; i < npossible_depths; i++)
|
||||
{
|
||||
for (j = 0; j < nvisuals; j++)
|
||||
{
|
||||
if (visuals[j].visual.depth == possible_depths[i])
|
||||
{
|
||||
available_depths[navailable_depths++] = visuals[j].visual.depth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (navailable_depths == 0)
|
||||
g_error ("unable to find a usable depth");
|
||||
|
||||
navailable_types = 0;
|
||||
for (i = 0; i < npossible_types; i++)
|
||||
{
|
||||
for (j = 0; j < nvisuals; j++)
|
||||
{
|
||||
if (visuals[j].visual.type == possible_types[i])
|
||||
{
|
||||
available_types[navailable_types++] = visuals[j].visual.type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
gdk_visual_add ((GdkVisual*) &visuals[i]);
|
||||
|
||||
if (npossible_types == 0)
|
||||
g_error ("unable to find a usable visual type");
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_ref (GdkVisual *visual)
|
||||
{
|
||||
return visual;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_visual_unref (GdkVisual *visual)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_visual_get_best_depth ()
|
||||
{
|
||||
return available_depths[0];
|
||||
}
|
||||
|
||||
GdkVisualType
|
||||
gdk_visual_get_best_type ()
|
||||
{
|
||||
return available_types[0];
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_system ()
|
||||
{
|
||||
return ((GdkVisual*) system_visual);
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best ()
|
||||
{
|
||||
return ((GdkVisual*) &(visuals[0]));
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_depth (gint depth)
|
||||
{
|
||||
GdkVisual *return_val;
|
||||
int i;
|
||||
|
||||
return_val = NULL;
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if (depth == visuals[i].visual.depth)
|
||||
{
|
||||
return_val = (GdkVisual*) &(visuals[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_type (GdkVisualType visual_type)
|
||||
{
|
||||
GdkVisual *return_val;
|
||||
int i;
|
||||
|
||||
return_val = NULL;
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if (visual_type == visuals[i].visual.type)
|
||||
{
|
||||
return_val = (GdkVisual*) &(visuals[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_get_best_with_both (gint depth,
|
||||
GdkVisualType visual_type)
|
||||
{
|
||||
GdkVisual *return_val;
|
||||
int i;
|
||||
|
||||
return_val = NULL;
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if ((depth == visuals[i].visual.depth) &&
|
||||
(visual_type == visuals[i].visual.type))
|
||||
{
|
||||
return_val = (GdkVisual*) &(visuals[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_query_depths (gint **depths,
|
||||
gint *count)
|
||||
{
|
||||
*count = navailable_depths;
|
||||
*depths = available_depths;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_query_visual_types (GdkVisualType **visual_types,
|
||||
gint *count)
|
||||
{
|
||||
*count = navailable_types;
|
||||
*visual_types = available_types;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_query_visuals (GdkVisual **visual_return,
|
||||
gint *count)
|
||||
{
|
||||
*count = nvisuals;
|
||||
*visual_return = (GdkVisual*) visuals;
|
||||
}
|
||||
|
||||
|
||||
GdkVisual*
|
||||
gdk_visual_lookup (Visual *xvisual)
|
||||
{
|
||||
GdkVisual *visual;
|
||||
|
||||
if (!visual_hash)
|
||||
return NULL;
|
||||
|
||||
visual = g_hash_table_lookup (visual_hash, xvisual);
|
||||
return visual;
|
||||
}
|
||||
|
||||
GdkVisual*
|
||||
gdkx_visual_get (VisualID xvisualid)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nvisuals; i++)
|
||||
if (xvisualid == visuals[i].xvisual->visualid)
|
||||
return (GdkVisual*) &visuals[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gdk_visual_add (GdkVisual *visual)
|
||||
{
|
||||
GdkVisualPrivate *private;
|
||||
|
||||
if (!visual_hash)
|
||||
visual_hash = g_hash_table_new ((GHashFunc) gdk_visual_hash,
|
||||
(GCompareFunc) gdk_visual_compare);
|
||||
|
||||
private = (GdkVisualPrivate*) visual;
|
||||
|
||||
g_hash_table_insert (visual_hash, private->xvisual, visual);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_visual_decompose_mask (gulong mask,
|
||||
gint *shift,
|
||||
gint *prec)
|
||||
{
|
||||
*shift = 0;
|
||||
*prec = 0;
|
||||
|
||||
while (!(mask & 0x1))
|
||||
{
|
||||
(*shift)++;
|
||||
mask >>= 1;
|
||||
}
|
||||
|
||||
while (mask & 0x1)
|
||||
{
|
||||
(*prec)++;
|
||||
mask >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
static guint
|
||||
gdk_visual_hash (Visual *key)
|
||||
{
|
||||
return key->visualid;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_visual_compare (Visual *a,
|
||||
Visual *b)
|
||||
{
|
||||
return (a->visualid == b->visualid);
|
||||
}
|
1358
gdk/x11/gdkwindow-x11.c
Normal file
1358
gdk/x11/gdkwindow-x11.c
Normal file
File diff suppressed because it is too large
Load Diff
48
gdk/x11/gdkx.h
Normal file
48
gdk/x11/gdkx.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef __GDK_X_H__
|
||||
#define __GDK_X_H__
|
||||
|
||||
#include <gdk/gdkprivate.h>
|
||||
|
||||
|
||||
#define GDK_ROOT_WINDOW() gdk_root_window
|
||||
#define GDK_ROOT_PARENT() &gdk_root_parent
|
||||
#define GDK_DISPLAY() gdk_display
|
||||
#define GDK_WINDOW_XDISPLAY(win) (((GdkWindowPrivate*) win)->xdisplay)
|
||||
#define GDK_WINDOW_XWINDOW(win) (((GdkWindowPrivate*) win)->xwindow)
|
||||
#define GDK_IMAGE_XDISPLAY(image) (((GdkImagePrivate*) image)->xdisplay)
|
||||
#define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage)
|
||||
#define GDK_GC_XDISPLAY(gc) (((GdkGCPrivate*) gc)->xdisplay)
|
||||
#define GDK_GC_XGC(gc) (((GdkGCPrivate*) gc)->xgc)
|
||||
#define GDK_COLORMAP_XDISPLAY(cmap) (((GdkColormapPrivate*) cmap)->xdisplay)
|
||||
#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivate*) cmap)->xcolormap)
|
||||
#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate*) vis)->xvisual)
|
||||
#define GDK_FONT_XDISPLAY(font) (((GdkFontPrivate*) font)->xdisplay)
|
||||
#define GDK_FONT_XFONT(font) (((GdkFontPrivate*) font)->xfont)
|
||||
|
||||
|
||||
GdkVisual* gdkx_visual_get (VisualID xvisualid);
|
||||
GdkColormap* gdkx_colormap_get (Colormap xcolormap);
|
||||
/* Utility function in gdk.c - not sure where it belongs, but it's
|
||||
needed in more than one place, so make it public */
|
||||
Window gdk_get_client_window (Display *dpy,
|
||||
Window win);
|
||||
|
||||
|
||||
#endif /* __GDK_X_H__ */
|
74
gdk/x11/gdkxid.c
Normal file
74
gdk/x11/gdkxid.c
Normal file
@ -0,0 +1,74 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include "gdkprivate.h"
|
||||
|
||||
|
||||
static guint gdk_xid_hash (XID *xid);
|
||||
static gint gdk_xid_compare (XID *a,
|
||||
XID *b);
|
||||
|
||||
|
||||
GHashTable *xid_ht = NULL;
|
||||
|
||||
|
||||
void
|
||||
gdk_xid_table_insert (XID *xid,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_if_fail (xid != NULL);
|
||||
|
||||
if (!xid_ht)
|
||||
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
|
||||
(GCompareFunc) gdk_xid_compare);
|
||||
|
||||
g_hash_table_insert (xid_ht, xid, data);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_xid_table_remove (XID xid)
|
||||
{
|
||||
if (!xid_ht)
|
||||
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
|
||||
(GCompareFunc) gdk_xid_compare);
|
||||
|
||||
g_hash_table_remove (xid_ht, &xid);
|
||||
}
|
||||
|
||||
gpointer
|
||||
gdk_xid_table_lookup (XID xid)
|
||||
{
|
||||
gpointer data;
|
||||
|
||||
data = g_hash_table_lookup (xid_ht, &xid);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static guint
|
||||
gdk_xid_hash (XID *xid)
|
||||
{
|
||||
return *xid;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_xid_compare (XID *a,
|
||||
XID *b)
|
||||
{
|
||||
return (*a == *b);
|
||||
}
|
844
gdk/x11/gxid.c
Normal file
844
gdk/x11/gxid.c
Normal file
@ -0,0 +1,844 @@
|
||||
/*
|
||||
* gxid version 0.3
|
||||
*
|
||||
* Copyright 1997 Owen Taylor <owt1@cornell.edu>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/XInput.h>
|
||||
|
||||
#include "gxid_proto.h"
|
||||
|
||||
/* #define DEBUG_CLIENTS */
|
||||
/* #define DEBUG_EVENTS */
|
||||
|
||||
char *program_name;
|
||||
Display *dpy;
|
||||
Window root_window; /* default root window of dpy */
|
||||
int port = 0; /* port to listen on */
|
||||
int socket_fd = 0; /* file descriptor of socket */
|
||||
typedef struct GxidWindow_ GxidWindow;
|
||||
|
||||
typedef struct GxidDevice_ GxidDevice;
|
||||
struct GxidDevice_ {
|
||||
XID id;
|
||||
int exclusive;
|
||||
int ispointer;
|
||||
|
||||
XDevice *xdevice;
|
||||
int motionnotify_type;
|
||||
int changenotify_type;
|
||||
};
|
||||
|
||||
struct GxidWindow_ {
|
||||
Window xwindow;
|
||||
/* Immediate child of root that is ancestor of window */
|
||||
Window root_child;
|
||||
int num_devices;
|
||||
GxidDevice **devices;
|
||||
};
|
||||
|
||||
GxidDevice **devices = NULL;
|
||||
int num_devices = 0;
|
||||
GxidWindow **windows = NULL;
|
||||
int num_windows = 0;
|
||||
|
||||
void
|
||||
handler(int signal)
|
||||
{
|
||||
fprintf(stderr,"%s: dying on signal %d\n",program_name,signal);
|
||||
if (socket_fd)
|
||||
close(socket_fd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
init_socket()
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
|
||||
socket_fd = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
|
||||
if (socket_fd < 0)
|
||||
{
|
||||
fprintf (stderr, "%s: error getting socket\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(port);
|
||||
sin.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
if (bind(socket_fd,(struct sockaddr *)(&sin),
|
||||
sizeof(struct sockaddr_in)) < 0)
|
||||
{
|
||||
fprintf (stderr,"%s: cannot bind to port %d\n",
|
||||
program_name,port);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (listen(socket_fd,5) < 0)
|
||||
{
|
||||
fprintf (stderr,"%s: error listening on socket\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
};
|
||||
}
|
||||
|
||||
#define NUM_EVENTC 2
|
||||
static void
|
||||
enable_device(GxidDevice *dev)
|
||||
{
|
||||
XEventClass xevc[NUM_EVENTC];
|
||||
int num_eventc = NUM_EVENTC;
|
||||
int i,j;
|
||||
|
||||
if (!dev->xdevice)
|
||||
{
|
||||
if (dev->ispointer) return;
|
||||
|
||||
dev->xdevice = XOpenDevice(dpy, dev->id);
|
||||
if (!dev->xdevice) return;
|
||||
|
||||
DeviceMotionNotify (dev->xdevice, dev->motionnotify_type,
|
||||
xevc[0]);
|
||||
ChangeDeviceNotify (dev->xdevice, dev->changenotify_type,
|
||||
xevc[1]);
|
||||
|
||||
/* compress out zero event classes */
|
||||
for (i=0,j=0;i<NUM_EVENTC;i++)
|
||||
{
|
||||
if (xevc[i]) {
|
||||
xevc[j] = xevc[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
num_eventc = j;
|
||||
|
||||
XSelectExtensionEvent (dpy, root_window, xevc, num_eventc);
|
||||
}
|
||||
}
|
||||
|
||||
/* switch the core pointer from whatever it is now to something else,
|
||||
return true on success, false otherwise */
|
||||
static int
|
||||
switch_core_pointer()
|
||||
{
|
||||
GxidDevice *old_pointer = 0;
|
||||
GxidDevice *new_pointer = 0;
|
||||
int result;
|
||||
int i;
|
||||
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (devices[i]->ispointer)
|
||||
old_pointer = devices[i];
|
||||
else
|
||||
if (!new_pointer && !devices[i]->exclusive)
|
||||
new_pointer = devices[i];
|
||||
}
|
||||
|
||||
if (!old_pointer || !new_pointer)
|
||||
return 0;
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"gxid: Switching core from %ld to %ld\n",
|
||||
old_pointer->id,new_pointer->id);
|
||||
#endif
|
||||
result = XChangePointerDevice(dpy,new_pointer->xdevice, 0, 1);
|
||||
if (result != Success)
|
||||
{
|
||||
fprintf(stderr,"gxid: Error %d switching core from %ld to %ld\n",
|
||||
result, old_pointer->id, new_pointer->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_pointer->ispointer = 1;
|
||||
old_pointer->ispointer = 0;
|
||||
if (!old_pointer->xdevice)
|
||||
enable_device(old_pointer);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
disable_device(GxidDevice *dev)
|
||||
{
|
||||
if (dev->xdevice)
|
||||
{
|
||||
if (dev->ispointer)
|
||||
return;
|
||||
XCloseDevice(dpy,dev->xdevice);
|
||||
dev->xdevice = 0;
|
||||
}
|
||||
}
|
||||
|
||||
GxidDevice *
|
||||
init_device(XDeviceInfo *xdevice)
|
||||
{
|
||||
GxidDevice *dev = (GxidDevice *)malloc(sizeof(GxidDevice));
|
||||
XAnyClassPtr class;
|
||||
int num_axes, i;
|
||||
|
||||
dev->id = xdevice->id;
|
||||
dev->exclusive = 0;
|
||||
dev->xdevice = NULL;
|
||||
|
||||
dev->ispointer = (xdevice->use == IsXPointer);
|
||||
|
||||
/* step through the classes */
|
||||
|
||||
num_axes = 0;
|
||||
class = xdevice->inputclassinfo;
|
||||
for (i=0;i<xdevice->num_classes;i++)
|
||||
{
|
||||
if (class->class == ValuatorClass)
|
||||
{
|
||||
XValuatorInfo *xvi = (XValuatorInfo *)class;
|
||||
num_axes = xvi->num_axes;
|
||||
}
|
||||
class = (XAnyClassPtr)(((char *)class) + class->length);
|
||||
}
|
||||
|
||||
/* return NULL if insufficient axes */
|
||||
if (num_axes < 2)
|
||||
{
|
||||
free((void *)dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!dev->ispointer)
|
||||
enable_device(dev);
|
||||
return dev;
|
||||
}
|
||||
|
||||
void
|
||||
init_xinput()
|
||||
{
|
||||
char **extensions;
|
||||
XDeviceInfo *xdevices;
|
||||
int num_xdevices;
|
||||
int num_extensions;
|
||||
int i;
|
||||
|
||||
extensions = XListExtensions(dpy, &num_extensions);
|
||||
for (i = 0; i < num_extensions &&
|
||||
(strcmp(extensions[i], "XInputExtension") != 0); i++);
|
||||
XFreeExtensionList(extensions);
|
||||
if (i == num_extensions) /* XInput extension not found */
|
||||
{
|
||||
fprintf(stderr,"XInput extension not found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
xdevices = XListInputDevices(dpy, &num_xdevices);
|
||||
devices = (GxidDevice **)malloc(num_xdevices * sizeof(GxidDevice *));
|
||||
|
||||
num_devices = 0;
|
||||
for(i=0; i<num_xdevices; i++)
|
||||
{
|
||||
GxidDevice *dev = init_device(&xdevices[i]);
|
||||
if (dev)
|
||||
devices[num_devices++] = dev;
|
||||
}
|
||||
XFreeDeviceList(xdevices);
|
||||
}
|
||||
|
||||
/* If this routine needs fixing, the corresponding routine
|
||||
in gdkinputgxi.h will need it too. */
|
||||
|
||||
Window
|
||||
gxi_find_root_child(Display *dpy, Window w)
|
||||
{
|
||||
Window root,parent;
|
||||
Window *children;
|
||||
int nchildren;
|
||||
|
||||
parent = w;
|
||||
do
|
||||
{
|
||||
w = parent;
|
||||
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
|
||||
if (children) XFree(children);
|
||||
}
|
||||
while (parent != root);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
int
|
||||
handle_claim_device(GxidClaimDevice *msg)
|
||||
{
|
||||
int i,j;
|
||||
XID devid = ntohl(msg->device);
|
||||
XID winid = ntohl(msg->window);
|
||||
int exclusive = ntohl(msg->exclusive);
|
||||
GxidDevice *device = NULL;
|
||||
GxidWindow *window = NULL;
|
||||
|
||||
#ifdef DEBUG_CLIENTS
|
||||
fprintf(stderr,"device %ld claimed (window 0x%lx)\n",devid,winid);
|
||||
#endif
|
||||
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (devices[i]->id == devid)
|
||||
{
|
||||
device = devices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!device)
|
||||
{
|
||||
fprintf(stderr,"%s: Unknown device id %ld\n",program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (device->exclusive)
|
||||
{
|
||||
/* already in use */
|
||||
fprintf(stderr,
|
||||
"%s: Device %ld already claimed in exclusive mode\n",
|
||||
program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (exclusive)
|
||||
{
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
for (j=0;j<windows[i]->num_devices;j++)
|
||||
if (windows[i]->devices[j]->id == devid)
|
||||
{
|
||||
/* already in use */
|
||||
fprintf(stderr,
|
||||
"%s: Can't establish exclusive use of device %ld\n",
|
||||
program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
if (device->ispointer)
|
||||
if (!switch_core_pointer())
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: Can't free up core pointer %ld\n",
|
||||
program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
device->exclusive = 1;
|
||||
disable_device(device);
|
||||
XSelectInput(dpy,winid,StructureNotifyMask);
|
||||
}
|
||||
else /* !exclusive */
|
||||
{
|
||||
/* FIXME: this is a bit improper. We probably should do this only
|
||||
when a window is first claimed. But we might be fooled if
|
||||
an old client died without releasing it's windows. So until
|
||||
we look for client-window closings, do it here
|
||||
|
||||
(We do look for closings now...)
|
||||
*/
|
||||
|
||||
XSelectInput(dpy,winid,EnterWindowMask|StructureNotifyMask);
|
||||
}
|
||||
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
if (windows[i]->xwindow == winid)
|
||||
{
|
||||
window = windows[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create window structure if no devices have been previously
|
||||
claimed on it */
|
||||
if (!window)
|
||||
{
|
||||
num_windows++;
|
||||
windows = (GxidWindow **)realloc(windows,
|
||||
sizeof(GxidWindow*)*num_windows);
|
||||
window = (GxidWindow *)malloc(sizeof(GxidWindow));
|
||||
windows[num_windows-1] = window;
|
||||
|
||||
window->xwindow = winid;
|
||||
window->root_child = gxi_find_root_child(dpy,winid);
|
||||
window->num_devices = 0;
|
||||
window->devices = 0;
|
||||
}
|
||||
|
||||
|
||||
for (i=0;i<window->num_devices;i++)
|
||||
{
|
||||
if (window->devices[i] == device)
|
||||
return GXID_RETURN_OK;
|
||||
}
|
||||
|
||||
window->num_devices++;
|
||||
window->devices = (GxidDevice **)realloc(window->devices,
|
||||
sizeof(GxidDevice*)*num_devices);
|
||||
/* we need add the device to the window */
|
||||
window->devices[i] = device;
|
||||
|
||||
return GXID_RETURN_OK;
|
||||
}
|
||||
|
||||
int
|
||||
handle_release_device(GxidReleaseDevice *msg)
|
||||
{
|
||||
int i,j;
|
||||
XID devid = ntohl(msg->device);
|
||||
XID winid = ntohl(msg->window);
|
||||
|
||||
GxidDevice *device = NULL;
|
||||
|
||||
#ifdef DEBUG_CLIENTS
|
||||
fprintf(stderr,"device %ld released (window 0x%lx)\n",devid,winid);
|
||||
#endif
|
||||
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (devices[i]->id == devid)
|
||||
{
|
||||
device = devices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!device)
|
||||
{
|
||||
fprintf(stderr,"%s: Unknown device id %ld\n",program_name,devid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
GxidWindow *w = windows[i];
|
||||
|
||||
if (w->xwindow == winid)
|
||||
for (j=0;j<w->num_devices;j++)
|
||||
if (w->devices[j]->id == devid)
|
||||
{
|
||||
if (j<w->num_devices-1)
|
||||
w->devices[j] = w->devices[w->num_devices-1];
|
||||
w->num_devices--;
|
||||
|
||||
if (w->num_devices == 0)
|
||||
{
|
||||
if (i<num_windows-1)
|
||||
windows[i] = windows[num_windows-1];
|
||||
num_windows--;
|
||||
|
||||
free((void *)w);
|
||||
/* FIXME: should we deselect input? But what
|
||||
what if window is already destroyed */
|
||||
}
|
||||
|
||||
if (device->exclusive)
|
||||
{
|
||||
device->exclusive = 0;
|
||||
enable_device(device);
|
||||
}
|
||||
return GXID_RETURN_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/* device/window combination not found */
|
||||
fprintf(stderr,
|
||||
"%s: Device %ld not claimed for window 0x%lx\n",
|
||||
program_name,devid,winid);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
void
|
||||
handle_connection()
|
||||
{
|
||||
GxidMessage msg;
|
||||
GxidU32 type;
|
||||
int length;
|
||||
GxidI32 retval;
|
||||
|
||||
int conn_fd;
|
||||
struct sockaddr_in sin;
|
||||
int sin_length;
|
||||
int count;
|
||||
|
||||
sin_length = sizeof(struct sockaddr_in);
|
||||
conn_fd = accept(socket_fd,(struct sockaddr *)&sin,&sin_length);
|
||||
if (conn_fd < 0)
|
||||
{
|
||||
fprintf(stderr,"%s: Error accepting connection\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* read type and length of message */
|
||||
|
||||
count = read(conn_fd,(char *)&msg,2*sizeof(GxidU32));
|
||||
if (count != 2*sizeof(GxidU32))
|
||||
{
|
||||
fprintf(stderr,"%s: Error reading message header\n",
|
||||
program_name);
|
||||
close(conn_fd);
|
||||
return;
|
||||
}
|
||||
type = ntohl(msg.any.type);
|
||||
length = ntohl(msg.any.length);
|
||||
|
||||
/* read rest of message */
|
||||
|
||||
if (length > sizeof(GxidMessage))
|
||||
{
|
||||
fprintf(stderr,"%s: Bad message length\n",
|
||||
program_name);
|
||||
close(conn_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
count = read(conn_fd,2*sizeof(GxidU32) + (char *)&msg,
|
||||
length - 2*sizeof(GxidU32));
|
||||
if (count != length - 2*sizeof(GxidU32))
|
||||
{
|
||||
fprintf(stderr,"%s: Error reading message body\n",
|
||||
program_name);
|
||||
close(conn_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GXID_CLAIM_DEVICE:
|
||||
retval = handle_claim_device((GxidClaimDevice *)&msg);
|
||||
break;
|
||||
case GXID_RELEASE_DEVICE:
|
||||
retval = handle_release_device((GxidReleaseDevice *)&msg);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"%s: Unknown message type: %ld (ignoring)\n",
|
||||
program_name,type);
|
||||
close(conn_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
count = write(conn_fd,&retval,sizeof(GxidI32));
|
||||
if (count != sizeof(GxidI32))
|
||||
{
|
||||
fprintf(stderr,"%s: Error writing return code\n",
|
||||
program_name);
|
||||
}
|
||||
|
||||
close(conn_fd);
|
||||
}
|
||||
|
||||
void
|
||||
handle_motion_notify(XDeviceMotionEvent *event)
|
||||
{
|
||||
int i,j;
|
||||
GxidDevice *old_device = NULL;
|
||||
GxidDevice *new_device = NULL;
|
||||
Window w, root, child;
|
||||
int root_x, root_y, x, y, mask;
|
||||
|
||||
for (j=0;j<num_devices;j++)
|
||||
{
|
||||
if (devices[j]->ispointer)
|
||||
old_device = devices[j];
|
||||
if (devices[j]->id == event->deviceid)
|
||||
new_device = devices[j];
|
||||
}
|
||||
|
||||
if (new_device && !new_device->exclusive && !new_device->ispointer)
|
||||
{
|
||||
/* make sure we aren't stealing the pointer back from a slow
|
||||
client */
|
||||
child = root_window;
|
||||
do
|
||||
{
|
||||
w = child;
|
||||
/* FIXME: this fails disasterously if child vanishes between
|
||||
calls. (Which is prone to happening since we get events
|
||||
on root just as the client exits) */
|
||||
|
||||
XQueryPointer(dpy,w,&root,&child,&root_x,&root_y,
|
||||
&x,&y,&mask);
|
||||
}
|
||||
while (child != None);
|
||||
|
||||
for (i=0;i<num_windows;i++)
|
||||
if (windows[i]->xwindow == w)
|
||||
for (j=0;j<windows[i]->num_devices;j++)
|
||||
if (windows[i]->devices[j] == new_device)
|
||||
return;
|
||||
|
||||
/* FIXME: do something smarter with axes */
|
||||
XChangePointerDevice(dpy,new_device->xdevice, 0, 1);
|
||||
new_device->ispointer = 1;
|
||||
|
||||
old_device->ispointer = 0;
|
||||
if (!old_device->xdevice)
|
||||
enable_device(old_device);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_change_notify(XChangeDeviceNotifyEvent *event)
|
||||
{
|
||||
int j;
|
||||
GxidDevice *old_device = NULL;
|
||||
GxidDevice *new_device = NULL;
|
||||
|
||||
|
||||
for (j=0;j<num_devices;j++)
|
||||
{
|
||||
if (devices[j]->ispointer)
|
||||
old_device = devices[j];
|
||||
if (devices[j]->id == event->deviceid)
|
||||
new_device = devices[j];
|
||||
}
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"gxid: ChangeNotify event; old = %ld; new = %ld\n",
|
||||
old_device->id, new_device->id);
|
||||
#endif
|
||||
|
||||
if (old_device != new_device)
|
||||
{
|
||||
new_device->ispointer = 1;
|
||||
|
||||
old_device->ispointer = 0;
|
||||
if (!old_device->xdevice)
|
||||
enable_device(old_device);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_enter_notify(XEnterWindowEvent *event, GxidWindow *window)
|
||||
{
|
||||
int i;
|
||||
GxidDevice *old_pointer = NULL;
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (devices[i]->ispointer)
|
||||
{
|
||||
old_pointer = devices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"gxid: Enter event; oldpointer = %ld\n",
|
||||
old_pointer->id);
|
||||
#endif
|
||||
|
||||
if (old_pointer)
|
||||
for (i=0;i<window->num_devices;i++)
|
||||
{
|
||||
if (window->devices[i] == old_pointer)
|
||||
{
|
||||
switch_core_pointer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_destroy_notify(XDestroyWindowEvent *event)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
for (i=0;i<num_windows;i++)
|
||||
if (windows[i]->xwindow == event->window)
|
||||
{
|
||||
GxidWindow *w = windows[i];
|
||||
|
||||
for (j=0;j<w->num_devices;j++)
|
||||
{
|
||||
#ifdef DEBUG_CLIENTS
|
||||
fprintf(stderr,"device %ld released on destruction of window 0x%lx.\n",
|
||||
w->devices[j]->id,w->xwindow);
|
||||
#endif
|
||||
|
||||
if (w->devices[j]->exclusive)
|
||||
{
|
||||
w->devices[j]->exclusive = 0;
|
||||
enable_device(devices[j]);
|
||||
}
|
||||
}
|
||||
|
||||
if (i<num_windows-1)
|
||||
windows[i] = windows[num_windows-1];
|
||||
num_windows--;
|
||||
|
||||
if (w->devices)
|
||||
free((void *)w->devices);
|
||||
free((void *)w);
|
||||
/* FIXME: should we deselect input? But what
|
||||
what if window is already destroyed */
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_xevent()
|
||||
{
|
||||
int i;
|
||||
XEvent event;
|
||||
|
||||
XNextEvent (dpy, &event);
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
fprintf(stderr,"Event - type = %d; window = 0x%lx\n",
|
||||
event.type,event.xany.window);
|
||||
#endif
|
||||
|
||||
if (event.type == ConfigureNotify)
|
||||
{
|
||||
#ifdef DEBUG_EVENTS
|
||||
XConfigureEvent *xce = (XConfigureEvent *)&event;
|
||||
fprintf(stderr," configureNotify: window = 0x%lx\n",xce->window);
|
||||
#endif
|
||||
}
|
||||
else if (event.type == EnterNotify)
|
||||
{
|
||||
/* pointer entered a claimed window */
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
if (event.xany.window == windows[i]->xwindow)
|
||||
handle_enter_notify((XEnterWindowEvent *)&event,windows[i]);
|
||||
}
|
||||
}
|
||||
else if (event.type == DestroyNotify)
|
||||
{
|
||||
/* A claimed window was destroyed */
|
||||
for (i=0;i<num_windows;i++)
|
||||
{
|
||||
if (event.xany.window == windows[i]->xwindow)
|
||||
handle_destroy_notify((XDestroyWindowEvent *)&event);
|
||||
}
|
||||
}
|
||||
else
|
||||
for (i=0;i<num_devices;i++)
|
||||
{
|
||||
if (event.type == devices[i]->motionnotify_type)
|
||||
{
|
||||
handle_motion_notify((XDeviceMotionEvent *)&event);
|
||||
break;
|
||||
}
|
||||
else if (event.type == devices[i]->changenotify_type)
|
||||
{
|
||||
handle_change_notify((XChangeDeviceNotifyEvent *)&event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr,"Usage: %s [-d display] [-p --gxid-port port]\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char *display_name = NULL;
|
||||
fd_set readfds;
|
||||
|
||||
program_name = argv[0];
|
||||
|
||||
for (i=1;i<argc;i++)
|
||||
{
|
||||
if (!strcmp(argv[i],"-d"))
|
||||
{
|
||||
if (++i >= argc) usage();
|
||||
display_name = argv[i];
|
||||
}
|
||||
else if (!strcmp(argv[i],"--gxid-port") ||
|
||||
!strcmp(argv[i],"-p"))
|
||||
{
|
||||
if (++i >= argc) usage();
|
||||
port = atoi(argv[i]);
|
||||
break;
|
||||
}
|
||||
else
|
||||
usage();
|
||||
}
|
||||
|
||||
if (!port)
|
||||
{
|
||||
char *t = getenv("GXID_PORT");
|
||||
if (t)
|
||||
port = atoi(t);
|
||||
else
|
||||
port = 6951;
|
||||
}
|
||||
/* set up a signal handler so we can clean up if killed */
|
||||
|
||||
signal(SIGTERM,handler);
|
||||
signal(SIGINT,handler);
|
||||
|
||||
/* initialize the X connection */
|
||||
|
||||
dpy = XOpenDisplay (display_name);
|
||||
if (!dpy)
|
||||
{
|
||||
fprintf (stderr, "%s: unable to open display '%s'\n",
|
||||
program_name, XDisplayName (display_name));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
root_window = DefaultRootWindow(dpy);
|
||||
|
||||
/* We'll want to do this in the future if we are to support
|
||||
gxid monitoring visibility information for clients */
|
||||
#if 0
|
||||
XSelectInput(dpy,root_window,SubstructureNotifyMask);
|
||||
#endif
|
||||
init_xinput();
|
||||
|
||||
/* set up our server connection */
|
||||
|
||||
init_socket();
|
||||
|
||||
/* main loop */
|
||||
|
||||
if (XPending(dpy)) /* this seems necessary to get things
|
||||
in sync */
|
||||
handle_xevent();
|
||||
while (1)
|
||||
{
|
||||
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(ConnectionNumber(dpy),&readfds);
|
||||
FD_SET(socket_fd,&readfds);
|
||||
|
||||
if (select(8*sizeof(readfds),&readfds,
|
||||
(fd_set *)0,(fd_set *)0, (struct timeval *)0) < 0)
|
||||
{
|
||||
fprintf(stderr,"Error in select\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (FD_ISSET(socket_fd,&readfds))
|
||||
handle_connection(socket_fd);
|
||||
|
||||
while (XPending(dpy))
|
||||
handle_xevent();
|
||||
}
|
||||
|
||||
XCloseDisplay (dpy);
|
||||
exit (0);
|
||||
}
|
116
gdk/x11/gxid_lib.c
Normal file
116
gdk/x11/gxid_lib.c
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* gxid version 0.3
|
||||
*
|
||||
* Copyright 1997 Owen Taylor <owt1@cornell.edu>
|
||||
*/
|
||||
|
||||
#include "../config.h"
|
||||
|
||||
#ifdef XINPUT_GXI
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include "gxid_lib.h"
|
||||
|
||||
/* handles mechanics of communicating with a client */
|
||||
static int
|
||||
gxid_send_message(char *host, int port, GxidMessage *msg)
|
||||
{
|
||||
int socket_fd;
|
||||
struct sockaddr_in sin;
|
||||
int count;
|
||||
GxidI32 retval;
|
||||
struct hostent *he;
|
||||
|
||||
if (!port) port = 6951;
|
||||
|
||||
if (!host || strcmp(host,"localhost") )
|
||||
{
|
||||
/* looking it up as localhost can be _SLOW_ on ppp systems */
|
||||
/* FIXME: Could localhost be anything other than loopback? */
|
||||
host = "127.0.0.1";
|
||||
}
|
||||
|
||||
he = gethostbyname(host);
|
||||
if (!he)
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: error looking up %s\n",host);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
sin.sin_family = he->h_addrtype;
|
||||
sin.sin_port = htons(port);
|
||||
memcpy(&sin.sin_addr,he->h_addr_list[0],he->h_length);
|
||||
|
||||
socket_fd = socket(AF_INET,SOCK_STREAM,0);
|
||||
if (socket_fd < 0)
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: can't get socket");
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (connect(socket_fd, (struct sockaddr *)&sin,
|
||||
sizeof sin) < 0)
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: can't connect to %s:%d\n",host,port);
|
||||
close(socket_fd);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
count = write(socket_fd,(char *)msg,ntohl(msg->any.length));
|
||||
if (count != ntohl(msg->any.length))
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: error writing");
|
||||
close(socket_fd);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
/* now read the return code */
|
||||
count = read(socket_fd,(char *)&retval,sizeof(GxidI32));
|
||||
if (count != sizeof(GxidI32))
|
||||
{
|
||||
fprintf(stderr,"gxid_lib: error reading return code");
|
||||
close(socket_fd);
|
||||
return GXID_RETURN_ERROR;
|
||||
}
|
||||
|
||||
close (socket_fd);
|
||||
return ntohl(retval);
|
||||
}
|
||||
|
||||
/* claim a device. If exclusive, device is claimed exclusively */
|
||||
int
|
||||
gxid_claim_device(char *host, int port, GxidU32 device, GxidU32 window,
|
||||
int exclusive)
|
||||
{
|
||||
GxidClaimDevice msg;
|
||||
msg.type = htonl(GXID_CLAIM_DEVICE);
|
||||
msg.length = htonl(sizeof(GxidClaimDevice));
|
||||
msg.device = htonl(device);
|
||||
msg.window = htonl(window);
|
||||
msg.exclusive = htonl(exclusive);
|
||||
|
||||
return gxid_send_message(host,port,(GxidMessage *)&msg);
|
||||
}
|
||||
|
||||
/* release a device/window pair */
|
||||
int
|
||||
gxid_release_device(char *host, int port, GxidU32 device, GxidU32 window)
|
||||
{
|
||||
GxidReleaseDevice msg;
|
||||
msg.type = htonl(GXID_RELEASE_DEVICE);
|
||||
msg.length = htonl(sizeof(GxidReleaseDevice));
|
||||
msg.device = htonl(device);
|
||||
msg.window = htonl(window);
|
||||
|
||||
return gxid_send_message(host,port,(GxidMessage *)&msg);
|
||||
}
|
||||
|
||||
#endif /* XINPUT_GXI */
|
||||
|
6
gdk/x11/gxid_lib.h
Normal file
6
gdk/x11/gxid_lib.h
Normal file
@ -0,0 +1,6 @@
|
||||
#include "gxid_proto.h"
|
||||
|
||||
int gxid_claim_device(char *host, int port,
|
||||
GxidU32 device, GxidU32 window, int exclusive);
|
||||
int gxid_release_device(char *host, int port, GxidU32 device,
|
||||
GxidU32 window);
|
39
gdk/x11/gxid_proto.h
Normal file
39
gdk/x11/gxid_proto.h
Normal file
@ -0,0 +1,39 @@
|
||||
#define GXID_CLAIM_DEVICE 1
|
||||
#define GXID_RELEASE_DEVICE 2
|
||||
|
||||
#define GXID_RETURN_OK 0
|
||||
#define GXID_RETURN_ERROR -1
|
||||
|
||||
typedef struct GxidClaimDevice_ GxidClaimDevice;
|
||||
typedef struct GxidReleaseDevice_ GxidReleaseDevice;
|
||||
typedef struct GxidMessageAny_ GxidMessageAny;
|
||||
typedef union GxidMessage_ GxidMessage;
|
||||
|
||||
typedef unsigned long GxidU32;
|
||||
typedef long GxidI32;
|
||||
|
||||
struct GxidClaimDevice_ {
|
||||
GxidU32 type;
|
||||
GxidU32 length;
|
||||
GxidU32 device;
|
||||
GxidU32 window;
|
||||
GxidU32 exclusive;
|
||||
};
|
||||
|
||||
struct GxidReleaseDevice_ {
|
||||
GxidU32 type;
|
||||
GxidU32 length;
|
||||
GxidU32 device;
|
||||
GxidU32 window;
|
||||
};
|
||||
|
||||
struct GxidMessageAny_ {
|
||||
GxidU32 type;
|
||||
GxidU32 length;
|
||||
};
|
||||
|
||||
union GxidMessage_ {
|
||||
GxidMessageAny any;
|
||||
GxidClaimDevice claim;
|
||||
GxidReleaseDevice release;
|
||||
};
|
11
glib/.cvsignore
Normal file
11
glib/.cvsignore
Normal file
@ -0,0 +1,11 @@
|
||||
*.lo
|
||||
config.log
|
||||
libtool
|
||||
config.status
|
||||
stamp-h
|
||||
Makefile
|
||||
.deps
|
||||
_libs
|
||||
libglib.la
|
||||
testglib
|
||||
glibconfig.h
|
1
glib/AUTHORS
Normal file
1
glib/AUTHORS
Normal file
@ -0,0 +1 @@
|
||||
Peter Mattis (petm@xcf.berkeley.edu)
|
0
glib/COPYING
Normal file
0
glib/COPYING
Normal file
10
glib/ChangeLog
Normal file
10
glib/ChangeLog
Normal file
@ -0,0 +1,10 @@
|
||||
Tue Dec 17 13:14:07 1996 Peter Mattis <pmattis@charnley.HIP.Berkeley.EDU>
|
||||
|
||||
* glib.h: Changed 'g_return_if_fail' and 'g_return_val_if_fail' to
|
||||
not call 'g_string' but to simply stringify the
|
||||
expression. Calling 'g_string' causes the expression to be
|
||||
expanded which is undesired.
|
||||
|
||||
Sun Dec 1 01:30:48 1996 Peter Mattis <pmattis@charnley.HIP.Berkeley.EDU>
|
||||
|
||||
* Started ChangeLog
|
0
glib/INSTALL
Normal file
0
glib/INSTALL
Normal file
38
glib/Makefile.am
Normal file
38
glib/Makefile.am
Normal file
@ -0,0 +1,38 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
lib_LTLIBRARIES = libglib.la
|
||||
|
||||
libglib_la_SOURCES = \
|
||||
garray.c \
|
||||
gcache.c \
|
||||
gerror.c \
|
||||
ghash.c \
|
||||
glist.c \
|
||||
gmem.c \
|
||||
gprimes.c \
|
||||
gslist.c \
|
||||
gtimer.c \
|
||||
gtree.c \
|
||||
gutils.c \
|
||||
gstring.c
|
||||
|
||||
include_HEADERS = \
|
||||
glib.h \
|
||||
glibconfig.h
|
||||
|
||||
libglib_la_LDFLAGS = -version-info 1:0:0
|
||||
|
||||
INCLUDES =
|
||||
|
||||
noinst_PROGRAMS = testglib
|
||||
testglib_LDADD = $(top_builddir)/libglib.la
|
||||
|
||||
.PHONY: files release
|
||||
|
||||
files:
|
||||
@files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
|
||||
echo $$p; \
|
||||
done
|
||||
|
||||
release:
|
||||
$(MAKE) dist distdir=$(PACKAGE)`date +"%y%m%d"`
|
0
glib/README
Normal file
0
glib/README
Normal file
62
glib/acconfig.h
Normal file
62
glib/acconfig.h
Normal file
@ -0,0 +1,62 @@
|
||||
/* GLIB - Library of useful routines for C programming
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* acconfig.h
|
||||
This file is in the public domain.
|
||||
|
||||
Descriptive text for the C preprocessor macros that
|
||||
the distributed Autoconf macros can define.
|
||||
No software package will use all of them; autoheader copies the ones
|
||||
your configure.in uses into your configuration header file templates.
|
||||
|
||||
The entries are in sort -df order: alphabetical, case insensitive,
|
||||
ignoring punctuation (such as underscores). Although this order
|
||||
can split up related entries, it makes it easier to check whether
|
||||
a given entry is in the file.
|
||||
|
||||
Leave the following blank line there!! Autoheader needs it. */
|
||||
|
||||
|
||||
/* Other stuff */
|
||||
#undef HAVE_DOPRNT
|
||||
#undef HAVE_FLOAT_H
|
||||
#undef HAVE_LIMITS_H
|
||||
#undef HAVE_LONG_DOUBLE
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
#undef HAVE_STRERROR
|
||||
#undef HAVE_STRSIGNAL
|
||||
#undef HAVE_VALUES_H
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
#undef NO_FD_SET
|
||||
#undef NO_SYS_ERRLIST
|
||||
#undef NO_SYS_SIGLIST
|
||||
|
||||
#undef SIZEOF_CHAR
|
||||
#undef SIZEOF_SHORT
|
||||
#undef SIZEOF_LONG
|
||||
#undef SIZEOF_INT
|
||||
#undef SIZEOF_VOID_P
|
||||
|
||||
/* #undef PACKAGE */
|
||||
/* #undef VERSION */
|
||||
|
||||
|
||||
/* Leave that blank line there!! Autoheader needs it.
|
||||
If you're adding to this file, keep in mind:
|
||||
The entries are in sort -df order: alphabetical, case insensitive,
|
||||
ignoring punctuation (such as underscores). */
|
395
glib/aclocal.m4
vendored
Normal file
395
glib/aclocal.m4
vendored
Normal file
@ -0,0 +1,395 @@
|
||||
dnl aclocal.m4 generated automatically by aclocal 1.2
|
||||
|
||||
# Do all the work for Automake. This macro actually does too much --
|
||||
# some checks are only needed if your package does certain things.
|
||||
# But this isn't really a big deal.
|
||||
|
||||
# serial 1
|
||||
|
||||
dnl Usage:
|
||||
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
|
||||
|
||||
AC_DEFUN(AM_INIT_AUTOMAKE,
|
||||
[AC_REQUIRE([AM_PROG_INSTALL])
|
||||
PACKAGE=[$1]
|
||||
AC_SUBST(PACKAGE)
|
||||
VERSION=[$2]
|
||||
AC_SUBST(VERSION)
|
||||
dnl test to see if srcdir already configured
|
||||
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
|
||||
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
|
||||
fi
|
||||
ifelse([$3],,
|
||||
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
|
||||
AC_DEFINE_UNQUOTED(VERSION, "$VERSION"))
|
||||
AM_SANITY_CHECK
|
||||
AC_ARG_PROGRAM
|
||||
dnl FIXME This is truly gross.
|
||||
missing_dir=`cd $ac_aux_dir && pwd`
|
||||
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
|
||||
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
|
||||
AC_PROG_MAKE_SET])
|
||||
|
||||
|
||||
# serial 1
|
||||
|
||||
AC_DEFUN(AM_PROG_INSTALL,
|
||||
[AC_REQUIRE([AC_PROG_INSTALL])
|
||||
test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
|
||||
AC_SUBST(INSTALL_SCRIPT)dnl
|
||||
])
|
||||
|
||||
#
|
||||
# Check to make sure that the build environment is sane.
|
||||
#
|
||||
|
||||
AC_DEFUN(AM_SANITY_CHECK,
|
||||
[AC_MSG_CHECKING([whether build environment is sane])
|
||||
# Just in case
|
||||
sleep 1
|
||||
echo timestamp > conftestfile
|
||||
# Do `set' in a subshell so we don't clobber the current shell's
|
||||
# arguments. Must try -L first in case configure is actually a
|
||||
# symlink; some systems play weird games with the mod time of symlinks
|
||||
# (eg FreeBSD returns the mod time of the symlink's containing
|
||||
# directory).
|
||||
if (
|
||||
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
|
||||
if test "$@" = "X"; then
|
||||
# -L didn't work.
|
||||
set X `ls -t $srcdir/configure conftestfile`
|
||||
fi
|
||||
test "[$]2" = conftestfile
|
||||
)
|
||||
then
|
||||
# Ok.
|
||||
:
|
||||
else
|
||||
AC_MSG_ERROR([newly created file is older than distributed files!
|
||||
Check your system clock])
|
||||
fi
|
||||
rm -f conftest*
|
||||
AC_MSG_RESULT(yes)])
|
||||
|
||||
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
|
||||
dnl The program must properly implement --version.
|
||||
AC_DEFUN(AM_MISSING_PROG,
|
||||
[AC_MSG_CHECKING(for working $2)
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
# Redirect stdin to placate older versions of autoconf. Sigh.
|
||||
if ($2 --version) < /dev/null > /dev/null 2>&1; then
|
||||
$1=$2
|
||||
AC_MSG_RESULT(found)
|
||||
else
|
||||
$1="$3/missing $2"
|
||||
AC_MSG_RESULT(missing)
|
||||
fi
|
||||
AC_SUBST($1)])
|
||||
|
||||
# Like AC_CONFIG_HEADER, but automatically create stamp file.
|
||||
|
||||
AC_DEFUN(AM_CONFIG_HEADER,
|
||||
[AC_PREREQ([2.12])
|
||||
AC_CONFIG_HEADER([$1])
|
||||
dnl When config.status generates a header, we must update the stamp-h file.
|
||||
dnl This file resides in the same directory as the config header
|
||||
dnl that is generated. We must strip everything past the first ":",
|
||||
dnl and everything past the last "/".
|
||||
AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
|
||||
ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
|
||||
<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
|
||||
<<am_indx=1
|
||||
for am_file in <<$1>>; do
|
||||
case " <<$>>CONFIG_HEADERS " in
|
||||
*" <<$>>am_file "*<<)>>
|
||||
echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
|
||||
;;
|
||||
esac
|
||||
am_indx=`expr "<<$>>am_indx" + 1`
|
||||
done<<>>dnl>>)
|
||||
changequote([,]))])
|
||||
|
||||
|
||||
# serial 17 AM_PROG_LIBTOOL
|
||||
AC_DEFUN(AM_PROG_LIBTOOL,
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_REQUIRE([AC_PROG_RANLIB])
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([AM_PROG_LD])
|
||||
AC_REQUIRE([AM_PROG_NM])
|
||||
AC_REQUIRE([AC_PROG_LN_S])
|
||||
|
||||
# Always use our own libtool.
|
||||
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
|
||||
AC_SUBST(LIBTOOL)
|
||||
|
||||
dnl Allow the --disable-shared flag to stop us from building shared libs.
|
||||
AC_ARG_ENABLE(shared,
|
||||
[ --enable-shared build shared libraries [default=yes]],
|
||||
[if test "$enableval" = no; then
|
||||
libtool_enable_shared=no
|
||||
else
|
||||
libtool_enable_shared=yes
|
||||
fi])
|
||||
test -n "$libtool_enable_shared" && enable_shared="$libtool_enable_shared"
|
||||
libtool_shared=
|
||||
test "$enable_shared" = no && libtool_shared=" --disable-shared"
|
||||
|
||||
dnl Allow the --disable-static flag to stop us from building static libs.
|
||||
AC_ARG_ENABLE(static,
|
||||
[ --enable-static build static libraries [default=yes]],
|
||||
[if test "$enableval" = no; then
|
||||
libtool_enable_static=no
|
||||
else
|
||||
libtool_enable_static=yes
|
||||
fi])
|
||||
test -n "$libtool_enable_static" && enable_static="$libtool_enable_static"
|
||||
libtool_static=
|
||||
test "$enable_static" = no && libtool_static=" --disable-static"
|
||||
|
||||
libtool_flags="$libtool_shared$libtool_static"
|
||||
test "$silent" = yes && libtool_flags="$libtool_flags --silent"
|
||||
test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
|
||||
test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
|
||||
|
||||
# Some flags need to be propagated to the compiler or linker for good
|
||||
# libtool support.
|
||||
[case "$host" in
|
||||
*-*-irix6*)
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
flag_passed=no
|
||||
for f in -32 -64 -n32 ABI -cckr -mips1 -mips2 -mips3 -mips4; do
|
||||
case "$f" in
|
||||
ABI)
|
||||
test -n "$SGI_ABI" && flag_passed=yes
|
||||
if test "$flag_passed" = no && test "$ac_cv_prog_gcc" = yes; then
|
||||
# Choose the ABI flag according to GCC's specs.
|
||||
if $CC -dumpspecs 2>&1 | sed '/^\*link:$/,/^$/!d' | egrep -e '[ ]-32' >/dev/null; then
|
||||
LD="${LD-ld} -32"
|
||||
else
|
||||
LD="${LD-ld} -n32"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
if echo " $CC $CFLAGS " | egrep -e "[ ]$f[ ]" > /dev/null; then
|
||||
flag_passed=yes
|
||||
LD="${LD-ld} $f"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
;;
|
||||
|
||||
*-*-sco3.2v5*)
|
||||
# On SCO OpenServer 5, we need -belf to get full-featured binaries.
|
||||
CFLAGS="$CFLAGS -belf"
|
||||
;;
|
||||
esac]
|
||||
|
||||
# Actually configure libtool. ac_aux_dir is where install-sh is found.
|
||||
CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
|
||||
LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
|
||||
${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig \
|
||||
$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
|
||||
|| AC_MSG_ERROR([libtool configure failed])
|
||||
])
|
||||
|
||||
# AM_PROG_LD - find the path to the GNU or non-GNU linker
|
||||
AC_DEFUN(AM_PROG_LD,
|
||||
[AC_ARG_WITH(gnu-ld,
|
||||
[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
|
||||
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
ac_prog=ld
|
||||
if test "$ac_cv_prog_gcc" = yes; then
|
||||
# Check if gcc -print-prog-name=ld gives a path.
|
||||
AC_MSG_CHECKING([for ld used by GCC])
|
||||
ac_prog=`($CC -print-prog-name=ld) 2>&5`
|
||||
case "$ac_prog" in
|
||||
# Accept absolute paths.
|
||||
/*)
|
||||
test -z "$LD" && LD="$ac_prog"
|
||||
;;
|
||||
"")
|
||||
# If it fails, then pretend we aren't using GCC.
|
||||
ac_prog=ld
|
||||
;;
|
||||
*)
|
||||
# If it is relative, then search for the first ld in PATH.
|
||||
with_gnu_ld=unknown
|
||||
;;
|
||||
esac
|
||||
elif test "$with_gnu_ld" = yes; then
|
||||
AC_MSG_CHECKING([for GNU ld])
|
||||
else
|
||||
AC_MSG_CHECKING([for non-GNU ld])
|
||||
fi
|
||||
AC_CACHE_VAL(ac_cv_path_LD,
|
||||
[if test -z "$LD"; then
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -f "$ac_dir/$ac_prog"; then
|
||||
ac_cv_path_LD="$ac_dir/$ac_prog"
|
||||
# Check to see if the program is GNU ld. I'd rather use --version,
|
||||
# but apparently some GNU ld's only accept -v.
|
||||
# Break only if it was the GNU/non-GNU ld that we prefer.
|
||||
if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
|
||||
test "$with_gnu_ld" != no && break
|
||||
else
|
||||
test "$with_gnu_ld" != yes && break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
else
|
||||
ac_cv_path_LD="$LD" # Let the user override the test with a path.
|
||||
fi])
|
||||
LD="$ac_cv_path_LD"
|
||||
if test -n "$LD"; then
|
||||
AC_MSG_RESULT($LD)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
|
||||
AC_SUBST(LD)
|
||||
AM_PROG_LD_GNU
|
||||
])
|
||||
|
||||
AC_DEFUN(AM_PROG_LD_GNU,
|
||||
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
|
||||
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
|
||||
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
|
||||
ac_cv_prog_gnu_ld=yes
|
||||
else
|
||||
ac_cv_prog_gnu_ld=no
|
||||
fi])
|
||||
])
|
||||
|
||||
# AM_PROG_NM - find the path to a BSD-compatible name lister
|
||||
AC_DEFUN(AM_PROG_NM,
|
||||
[AC_MSG_CHECKING([for BSD-compatible nm])
|
||||
AC_CACHE_VAL(ac_cv_path_NM,
|
||||
[case "$NM" in
|
||||
/*)
|
||||
ac_cv_path_NM="$NM" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
|
||||
for ac_dir in /usr/ucb $PATH /bin; do
|
||||
test -z "$ac_dir" && dir=.
|
||||
if test -f $ac_dir/nm; then
|
||||
# Check to see if the nm accepts a BSD-compat flag.
|
||||
if ($ac_dir/nm -B /dev/null 2>&1; exit 0) | grep /dev/null >/dev/null; then
|
||||
ac_cv_path_NM="$ac_dir/nm -B"
|
||||
elif ($ac_dir/nm -p /dev/null 2>&1; exit 0) | grep /dev/null >/dev/null; then
|
||||
ac_cv_path_NM="$ac_dir/nm -p"
|
||||
else
|
||||
ac_cv_path_NM="$ac_dir/nm"
|
||||
fi
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
|
||||
;;
|
||||
esac])
|
||||
NM="$ac_cv_path_NM"
|
||||
AC_MSG_RESULT([$NM])
|
||||
AC_SUBST(NM)
|
||||
])
|
||||
|
||||
# Add --enable-maintainer-mode option to configure.
|
||||
# From Jim Meyering
|
||||
|
||||
# serial 1
|
||||
|
||||
AC_DEFUN(AM_MAINTAINER_MODE,
|
||||
[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
|
||||
dnl maintainer-mode is disabled by default
|
||||
AC_ARG_ENABLE(maintainer-mode,
|
||||
[ --enable-maintainer-mode enable make rules and dependencies not useful
|
||||
(and sometimes confusing) to the casual installer],
|
||||
USE_MAINTAINER_MODE=$enableval,
|
||||
USE_MAINTAINER_MODE=no)
|
||||
AC_MSG_RESULT($USE_MAINTAINER_MODE)
|
||||
if test $USE_MAINTAINER_MODE = yes; then
|
||||
MAINT=
|
||||
else
|
||||
MAINT='#M#'
|
||||
fi
|
||||
AC_SUBST(MAINT)dnl
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
# serial 1
|
||||
|
||||
# @defmac AC_PROG_CC_STDC
|
||||
# @maindex PROG_CC_STDC
|
||||
# @ovindex CC
|
||||
# If the C compiler in not in ANSI C mode by default, try to add an option
|
||||
# to output variable @code{CC} to make it so. This macro tries various
|
||||
# options that select ANSI C on some system or another. It considers the
|
||||
# compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and
|
||||
# handles function prototypes correctly.
|
||||
#
|
||||
# If you use this macro, you should check after calling it whether the C
|
||||
# compiler has been set to accept ANSI C; if not, the shell variable
|
||||
# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
|
||||
# code in ANSI C, you can make an un-ANSIfied copy of it by using the
|
||||
# program @code{ansi2knr}, which comes with Ghostscript.
|
||||
# @end defmac
|
||||
|
||||
AC_DEFUN(AM_PROG_CC_STDC,
|
||||
[AC_REQUIRE([AC_PROG_CC])
|
||||
AC_BEFORE([$0], [AC_C_INLINE])
|
||||
AC_BEFORE([$0], [AC_C_CONST])
|
||||
AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
|
||||
AC_CACHE_VAL(am_cv_prog_cc_stdc,
|
||||
[am_cv_prog_cc_stdc=no
|
||||
ac_save_CC="$CC"
|
||||
# Don't try gcc -ansi; that turns off useful extensions and
|
||||
# breaks some systems' header files.
|
||||
# AIX -qlanglvl=ansi
|
||||
# Ultrix and OSF/1 -std1
|
||||
# HP-UX -Aa -D_HPUX_SOURCE
|
||||
# SVR4 -Xc -D__EXTENSIONS__
|
||||
for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
|
||||
do
|
||||
CC="$ac_save_CC $ac_arg"
|
||||
AC_TRY_COMPILE(
|
||||
[#if !defined(__STDC__) || __STDC__ != 1
|
||||
choke me
|
||||
#endif
|
||||
/* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */
|
||||
#ifdef _SEQUENT_
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
], [
|
||||
int test (int i, double x);
|
||||
struct s1 {int (*f) (int a);};
|
||||
struct s2 {int (*f) (double a);};],
|
||||
[am_cv_prog_cc_stdc="$ac_arg"; break])
|
||||
done
|
||||
CC="$ac_save_CC"
|
||||
])
|
||||
if test -z "$am_cv_prog_cc_stdc"; then
|
||||
AC_MSG_RESULT([none needed])
|
||||
else
|
||||
AC_MSG_RESULT($am_cv_prog_cc_stdc)
|
||||
fi
|
||||
case "x$am_cv_prog_cc_stdc" in
|
||||
x|xno) ;;
|
||||
*) CC="$CC $am_cv_prog_cc_stdc" ;;
|
||||
esac
|
||||
])
|
||||
|
883
glib/config.guess
vendored
Executable file
883
glib/config.guess
vendored
Executable file
@ -0,0 +1,883 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Written by Per Bothner <bothner@cygnus.com>.
|
||||
# The master version of this file is at the FSF in /home/gd/gnu/lib.
|
||||
#
|
||||
# This script attempts to guess a canonical system name similar to
|
||||
# config.sub. If it succeeds, it prints the system name on stdout, and
|
||||
# exits with 0. Otherwise, it exits with 1.
|
||||
#
|
||||
# The plan is that this can be called by configure scripts if you
|
||||
# don't specify an explicit system type (host/target name).
|
||||
#
|
||||
# Only a few systems have been added to this list; please add others
|
||||
# (but try to keep the structure clean).
|
||||
#
|
||||
|
||||
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
|
||||
# (ghazi@noc.rutgers.edu 8/24/94.)
|
||||
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
|
||||
PATH=$PATH:/.attbin ; export PATH
|
||||
fi
|
||||
|
||||
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
|
||||
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
|
||||
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
|
||||
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
|
||||
|
||||
trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
|
||||
|
||||
# Note: order is significant - the case branches are not exclusive.
|
||||
|
||||
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
alpha:OSF1:*:*)
|
||||
if test $UNAME_RELEASE = "V4.0"; then
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
|
||||
fi
|
||||
# A Vn.n version is a released version.
|
||||
# A Tn.n version is a released field test version.
|
||||
# A Xn.n version is an unreleased experimental baselevel.
|
||||
# 1.2 uses "1.2" for uname -r.
|
||||
cat <<EOF >dummy.s
|
||||
.globl main
|
||||
.ent main
|
||||
main:
|
||||
.frame \$30,0,\$26,0
|
||||
.prologue 0
|
||||
.long 0x47e03d80 # implver $0
|
||||
lda \$2,259
|
||||
.long 0x47e20c21 # amask $2,$1
|
||||
srl \$1,8,\$2
|
||||
sll \$2,2,\$2
|
||||
sll \$0,3,\$0
|
||||
addl \$1,\$0,\$0
|
||||
addl \$2,\$0,\$0
|
||||
ret \$31,(\$26),1
|
||||
.end main
|
||||
EOF
|
||||
${CC-cc} dummy.s -o dummy 2>/dev/null
|
||||
if test "$?" = 0 ; then
|
||||
./dummy
|
||||
case "$?" in
|
||||
7)
|
||||
UNAME_MACHINE="alpha"
|
||||
;;
|
||||
15)
|
||||
UNAME_MACHINE="alphaev5"
|
||||
;;
|
||||
14)
|
||||
UNAME_MACHINE="alphaev56"
|
||||
;;
|
||||
10)
|
||||
UNAME_MACHINE="alphapca56"
|
||||
;;
|
||||
16)
|
||||
UNAME_MACHINE="alphaev6"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rm -f dummy.s dummy
|
||||
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]`
|
||||
exit 0 ;;
|
||||
21064:Windows_NT:50:3)
|
||||
echo alpha-dec-winnt3.5
|
||||
exit 0 ;;
|
||||
Amiga*:UNIX_System_V:4.0:*)
|
||||
echo m68k-cbm-sysv4
|
||||
exit 0;;
|
||||
amiga:NetBSD:*:*)
|
||||
echo m68k-cbm-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
amiga:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arc64:OpenBSD:*:*)
|
||||
echo mips64el-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
hkmips:OpenBSD:*:*)
|
||||
echo mips-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
pmax:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sgi:OpenBSD:*:*)
|
||||
echo mips-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
wgrisc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
|
||||
echo arm-acorn-riscix${UNAME_RELEASE}
|
||||
exit 0;;
|
||||
arm32:NetBSD:*:*)
|
||||
echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
SR2?01:HI-UX/MPP:*:*)
|
||||
echo hppa1.1-hitachi-hiuxmpp
|
||||
exit 0;;
|
||||
Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
|
||||
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
|
||||
if test "`(/bin/universe) 2>/dev/null`" = att ; then
|
||||
echo pyramid-pyramid-sysv3
|
||||
else
|
||||
echo pyramid-pyramid-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
NILE:*:*:dcosx)
|
||||
echo pyramid-pyramid-svr4
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
|
||||
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
i86pc:SunOS:5.*:*)
|
||||
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:6*:*)
|
||||
# According to config.sub, this is the proper way to canonicalize
|
||||
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
|
||||
# it's likely to be more like Solaris than SunOS4.
|
||||
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:*:*)
|
||||
case "`/usr/bin/arch -k`" in
|
||||
Series*|S4*)
|
||||
UNAME_RELEASE=`uname -v`
|
||||
;;
|
||||
esac
|
||||
# Japanese Language versions have a version number like `4.1.3-JL'.
|
||||
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
|
||||
exit 0 ;;
|
||||
sun3*:SunOS:*:*)
|
||||
echo m68k-sun-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun*:*:4.2BSD:*)
|
||||
UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
|
||||
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
|
||||
case "`/bin/arch`" in
|
||||
sun3)
|
||||
echo m68k-sun-sunos${UNAME_RELEASE}
|
||||
;;
|
||||
sun4)
|
||||
echo sparc-sun-sunos${UNAME_RELEASE}
|
||||
;;
|
||||
esac
|
||||
exit 0 ;;
|
||||
aushp:SunOS:*:*)
|
||||
echo sparc-auspex-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
atari*:NetBSD:*:*)
|
||||
echo m68k-atari-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
atari*:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3*:NetBSD:*:*)
|
||||
echo m68k-sun-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3*:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:NetBSD:*:*)
|
||||
echo m68k-apple-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mvme68k:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mvme88k:OpenBSD:*:*)
|
||||
echo m88k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
powerpc:machten:*:*)
|
||||
echo powerpc-apple-machten${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
RISC*:Mach:*:*)
|
||||
echo mips-dec-mach_bsd4.3
|
||||
exit 0 ;;
|
||||
RISC*:ULTRIX:*:*)
|
||||
echo mips-dec-ultrix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
VAX*:ULTRIX*:*:*)
|
||||
echo vax-dec-ultrix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
2020:CLIX:*:*)
|
||||
echo clipper-intergraph-clix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mips:*:*:UMIPS | mips:*:*:RISCos)
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
int main (argc, argv) int argc; char **argv; {
|
||||
#if defined (host_mips) && defined (MIPSEB)
|
||||
#if defined (SYSTYPE_SYSV)
|
||||
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#if defined (SYSTYPE_SVR4)
|
||||
printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
|
||||
printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
exit (-1);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy \
|
||||
&& ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
|
||||
&& rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo mips-mips-riscos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
Night_Hawk:Power_UNIX:*:*)
|
||||
echo powerpc-harris-powerunix
|
||||
exit 0 ;;
|
||||
m88k:CX/UX:7*:*)
|
||||
echo m88k-harris-cxux7
|
||||
exit 0 ;;
|
||||
m88k:*:4*:R4*)
|
||||
echo m88k-motorola-sysv4
|
||||
exit 0 ;;
|
||||
m88k:*:3*:R3*)
|
||||
echo m88k-motorola-sysv3
|
||||
exit 0 ;;
|
||||
AViiON:dgux:*:*)
|
||||
# DG/UX returns AViiON for all architectures
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
|
||||
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
|
||||
-o ${TARGET_BINARY_INTERFACE}x = x ] ; then
|
||||
echo m88k-dg-dgux${UNAME_RELEASE}
|
||||
else
|
||||
echo m88k-dg-dguxbcs${UNAME_RELEASE}
|
||||
fi
|
||||
else echo i586-dg-dgux${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
|
||||
echo m88k-dolphin-sysv3
|
||||
exit 0 ;;
|
||||
M88*:*:R3*:*)
|
||||
# Delta 88k system running SVR3
|
||||
echo m88k-motorola-sysv3
|
||||
exit 0 ;;
|
||||
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
|
||||
echo m88k-tektronix-sysv3
|
||||
exit 0 ;;
|
||||
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
|
||||
echo m68k-tektronix-bsd
|
||||
exit 0 ;;
|
||||
*:IRIX*:*:*)
|
||||
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
|
||||
exit 0 ;;
|
||||
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
|
||||
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
|
||||
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
|
||||
i?86:AIX:*:*)
|
||||
echo i386-ibm-aix
|
||||
exit 0 ;;
|
||||
*:AIX:2:3)
|
||||
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
#include <sys/systemcfg.h>
|
||||
|
||||
main()
|
||||
{
|
||||
if (!__power_pc())
|
||||
exit(1);
|
||||
puts("powerpc-ibm-aix3.2.5");
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo rs6000-ibm-aix3.2.5
|
||||
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
echo rs6000-ibm-aix3.2.4
|
||||
else
|
||||
echo rs6000-ibm-aix3.2
|
||||
fi
|
||||
exit 0 ;;
|
||||
*:AIX:*:4)
|
||||
if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
|
||||
IBM_ARCH=rs6000
|
||||
else
|
||||
IBM_ARCH=powerpc
|
||||
fi
|
||||
if [ -x /usr/bin/oslevel ] ; then
|
||||
IBM_REV=`/usr/bin/oslevel`
|
||||
else
|
||||
IBM_REV=4.${UNAME_RELEASE}
|
||||
fi
|
||||
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
|
||||
exit 0 ;;
|
||||
*:AIX:*:*)
|
||||
echo rs6000-ibm-aix
|
||||
exit 0 ;;
|
||||
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
|
||||
echo romp-ibm-bsd4.4
|
||||
exit 0 ;;
|
||||
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
|
||||
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
|
||||
exit 0 ;; # report: romp-ibm BSD 4.3
|
||||
*:BOSX:*:*)
|
||||
echo rs6000-bull-bosx
|
||||
exit 0 ;;
|
||||
DPX/2?00:B.O.S.:*:*)
|
||||
echo m68k-bull-sysv3
|
||||
exit 0 ;;
|
||||
9000/[34]??:4.3bsd:1.*:*)
|
||||
echo m68k-hp-bsd
|
||||
exit 0 ;;
|
||||
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
|
||||
echo m68k-hp-bsd4.4
|
||||
exit 0 ;;
|
||||
9000/[3478]??:HP-UX:*:*)
|
||||
case "${UNAME_MACHINE}" in
|
||||
9000/31? ) HP_ARCH=m68000 ;;
|
||||
9000/[34]?? ) HP_ARCH=m68k ;;
|
||||
9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;;
|
||||
9000/8?? ) HP_ARCH=hppa1.0 ;;
|
||||
esac
|
||||
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
|
||||
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
|
||||
exit 0 ;;
|
||||
3050*:HI-UX:*:*)
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
#include <unistd.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
long cpu = sysconf (_SC_CPU_VERSION);
|
||||
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
|
||||
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
|
||||
results, however. */
|
||||
if (CPU_IS_PA_RISC (cpu))
|
||||
{
|
||||
switch (cpu)
|
||||
{
|
||||
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
|
||||
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
|
||||
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
|
||||
default: puts ("hppa-hitachi-hiuxwe2"); break;
|
||||
}
|
||||
}
|
||||
else if (CPU_IS_HP_MC68K (cpu))
|
||||
puts ("m68k-hitachi-hiuxwe2");
|
||||
else puts ("unknown-hitachi-hiuxwe2");
|
||||
exit (0);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo unknown-hitachi-hiuxwe2
|
||||
exit 0 ;;
|
||||
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
|
||||
echo hppa1.1-hp-bsd
|
||||
exit 0 ;;
|
||||
9000/8??:4.3bsd:*:*)
|
||||
echo hppa1.0-hp-bsd
|
||||
exit 0 ;;
|
||||
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
|
||||
echo hppa1.1-hp-osf
|
||||
exit 0 ;;
|
||||
hp8??:OSF1:*:*)
|
||||
echo hppa1.0-hp-osf
|
||||
exit 0 ;;
|
||||
i?86:OSF1:*:*)
|
||||
if [ -x /usr/sbin/sysversion ] ; then
|
||||
echo ${UNAME_MACHINE}-unknown-osf1mk
|
||||
else
|
||||
echo ${UNAME_MACHINE}-unknown-osf1
|
||||
fi
|
||||
exit 0 ;;
|
||||
parisc*:Lites*:*:*)
|
||||
echo hppa1.1-hp-lites
|
||||
exit 0 ;;
|
||||
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
|
||||
echo c1-convex-bsd
|
||||
exit 0 ;;
|
||||
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
|
||||
if getsysinfo -f scalar_acc
|
||||
then echo c32-convex-bsd
|
||||
else echo c2-convex-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
|
||||
echo c34-convex-bsd
|
||||
exit 0 ;;
|
||||
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
|
||||
echo c38-convex-bsd
|
||||
exit 0 ;;
|
||||
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
|
||||
echo c4-convex-bsd
|
||||
exit 0 ;;
|
||||
CRAY*X-MP:*:*:*)
|
||||
echo xmp-cray-unicos
|
||||
exit 0 ;;
|
||||
CRAY*Y-MP:*:*:*)
|
||||
echo ymp-cray-unicos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
CRAY*[A-Z]90:*:*:*)
|
||||
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
|
||||
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
|
||||
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
|
||||
exit 0 ;;
|
||||
CRAY*TS:*:*:*)
|
||||
echo t90-cray-unicos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
CRAY-2:*:*:*)
|
||||
echo cray2-cray-unicos
|
||||
exit 0 ;;
|
||||
F300:UNIX_System_V:*:*)
|
||||
FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
|
||||
echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit 0 ;;
|
||||
F301:UNIX_System_V:*:*)
|
||||
echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
|
||||
exit 0 ;;
|
||||
hp3[0-9][05]:NetBSD:*:*)
|
||||
echo m68k-hp-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
hp300:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
i?86:BSD/386:*:* | *:BSD/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:FreeBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
|
||||
exit 0 ;;
|
||||
*:NetBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
*:OpenBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo i386-pc-cygwin32
|
||||
exit 0 ;;
|
||||
i*:MINGW*:*)
|
||||
echo i386-pc-mingw32
|
||||
exit 0 ;;
|
||||
p*:CYGWIN*:*)
|
||||
echo powerpcle-unknown-cygwin32
|
||||
exit 0 ;;
|
||||
prep*:SunOS:5.*:*)
|
||||
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
*:GNU:*:*)
|
||||
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
|
||||
exit 0 ;;
|
||||
*:Linux:*:*)
|
||||
# The BFD linker knows what the default object file format is, so
|
||||
# first see if it will tell us.
|
||||
ld_help_string=`ld --help 2>&1`
|
||||
ld_supported_emulations=`echo $ld_help_string \
|
||||
| sed -ne '/supported emulations:/!d
|
||||
s/[ ][ ]*/ /g
|
||||
s/.*supported emulations: *//
|
||||
s/ .*//
|
||||
p'`
|
||||
case "$ld_supported_emulations" in
|
||||
i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;;
|
||||
i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;;
|
||||
sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
|
||||
m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
|
||||
elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;;
|
||||
esac
|
||||
|
||||
if test "${UNAME_MACHINE}" = "alpha" ; then
|
||||
sed 's/^ //' <<EOF >dummy.s
|
||||
.globl main
|
||||
.ent main
|
||||
main:
|
||||
.frame \$30,0,\$26,0
|
||||
.prologue 0
|
||||
.long 0x47e03d80 # implver $0
|
||||
lda \$2,259
|
||||
.long 0x47e20c21 # amask $2,$1
|
||||
srl \$1,8,\$2
|
||||
sll \$2,2,\$2
|
||||
sll \$0,3,\$0
|
||||
addl \$1,\$0,\$0
|
||||
addl \$2,\$0,\$0
|
||||
ret \$31,(\$26),1
|
||||
.end main
|
||||
EOF
|
||||
LIBC=""
|
||||
${CC-cc} dummy.s -o dummy 2>/dev/null
|
||||
if test "$?" = 0 ; then
|
||||
./dummy
|
||||
case "$?" in
|
||||
7)
|
||||
UNAME_MACHINE="alpha"
|
||||
;;
|
||||
15)
|
||||
UNAME_MACHINE="alphaev5"
|
||||
;;
|
||||
14)
|
||||
UNAME_MACHINE="alphaev56"
|
||||
;;
|
||||
10)
|
||||
UNAME_MACHINE="alphapca56"
|
||||
;;
|
||||
16)
|
||||
UNAME_MACHINE="alphaev6"
|
||||
;;
|
||||
esac
|
||||
|
||||
objdump --private-headers dummy | \
|
||||
grep ld.so.1 > /dev/null
|
||||
if test "$?" = 0 ; then
|
||||
LIBC="libc1"
|
||||
fi
|
||||
fi
|
||||
rm -f dummy.s dummy
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
|
||||
elif test "${UNAME_MACHINE}" = "mips" ; then
|
||||
cat >dummy.c <<EOF
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
#ifdef __MIPSEB__
|
||||
printf ("%s-unknown-linux-gnu\n", argv[1]);
|
||||
#endif
|
||||
#ifdef __MIPSEL__
|
||||
printf ("%sel-unknown-linux-gnu\n", argv[1]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
else
|
||||
# Either a pre-BFD a.out linker (linux-gnuoldld)
|
||||
# or one that does not give us useful --help.
|
||||
# GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
|
||||
# If ld does not provide *any* "supported emulations:"
|
||||
# that means it is gnuoldld.
|
||||
echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
|
||||
test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
|
||||
|
||||
case "${UNAME_MACHINE}" in
|
||||
i?86)
|
||||
VENDOR=pc;
|
||||
;;
|
||||
*)
|
||||
VENDOR=unknown;
|
||||
;;
|
||||
esac
|
||||
# Determine whether the default compiler is a.out or elf
|
||||
cat >dummy.c <<EOF
|
||||
#include <features.h>
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
#ifdef __ELF__
|
||||
# ifdef __GLIBC__
|
||||
# if __GLIBC__ >= 2
|
||||
printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
|
||||
# else
|
||||
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
|
||||
# endif
|
||||
# else
|
||||
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
|
||||
# endif
|
||||
#else
|
||||
printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
fi ;;
|
||||
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
|
||||
# are messed up and put the nodename in both sysname and nodename.
|
||||
i?86:DYNIX/ptx:4*:*)
|
||||
echo i386-sequent-sysv4
|
||||
exit 0 ;;
|
||||
i?86:UNIX_SV:4.2MP:2.*)
|
||||
# Unixware is an offshoot of SVR4, but it has its own version
|
||||
# number series starting with 2...
|
||||
# I am not positive that other SVR4 systems won't match this,
|
||||
# I just have to hope. -- rms.
|
||||
# Use sysv4.2uw... so that sysv4* matches it.
|
||||
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
|
||||
exit 0 ;;
|
||||
i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
|
||||
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
|
||||
echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
|
||||
else
|
||||
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
i?86:*:3.2:*)
|
||||
if test -f /usr/options/cb.name; then
|
||||
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
|
||||
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
|
||||
elif /bin/uname -X 2>/dev/null >/dev/null ; then
|
||||
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
|
||||
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
|
||||
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
|
||||
&& UNAME_MACHINE=i586
|
||||
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
|
||||
else
|
||||
echo ${UNAME_MACHINE}-pc-sysv32
|
||||
fi
|
||||
exit 0 ;;
|
||||
pc:*:*:*)
|
||||
# uname -m prints for DJGPP always 'pc', but it prints nothing about
|
||||
# the processor, so we play safe by assuming i386.
|
||||
echo i386-pc-msdosdjgpp
|
||||
exit 0 ;;
|
||||
Intel:Mach:3*:*)
|
||||
echo i386-pc-mach3
|
||||
exit 0 ;;
|
||||
paragon:*:*:*)
|
||||
echo i860-intel-osf1
|
||||
exit 0 ;;
|
||||
i860:*:4.*:*) # i860-SVR4
|
||||
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
|
||||
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
|
||||
else # Add other i860-SVR4 vendors below as they are discovered.
|
||||
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
|
||||
fi
|
||||
exit 0 ;;
|
||||
mini*:CTIX:SYS*5:*)
|
||||
# "miniframe"
|
||||
echo m68010-convergent-sysv
|
||||
exit 0 ;;
|
||||
M68*:*:R3V[567]*:*)
|
||||
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
|
||||
3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
|
||||
OS_REL=''
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& echo i486-ncr-sysv4.3${OS_REL} && exit 0
|
||||
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
|
||||
&& echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
|
||||
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& echo i486-ncr-sysv4 && exit 0 ;;
|
||||
m68*:LynxOS:2.*:*)
|
||||
echo m68k-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mc68030:UNIX_System_V:4.*:*)
|
||||
echo m68k-atari-sysv4
|
||||
exit 0 ;;
|
||||
i?86:LynxOS:2.*:*)
|
||||
echo i386-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
TSUNAMI:LynxOS:2.*:*)
|
||||
echo sparc-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
|
||||
echo rs6000-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
SM[BE]S:UNIX_SV:*:*)
|
||||
echo mips-dde-sysv${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
RM*:SINIX-*:*:*)
|
||||
echo mips-sni-sysv4
|
||||
exit 0 ;;
|
||||
*:SINIX-*:*:*)
|
||||
if uname -p 2>/dev/null >/dev/null ; then
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null`
|
||||
echo ${UNAME_MACHINE}-sni-sysv4
|
||||
else
|
||||
echo ns32k-sni-sysv
|
||||
fi
|
||||
exit 0 ;;
|
||||
PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
|
||||
# says <Richard.M.Bartel@ccMail.Census.GOV>
|
||||
echo i586-unisys-sysv4
|
||||
exit 0 ;;
|
||||
*:UNIX_System_V:4*:FTX*)
|
||||
# From Gerald Hewes <hewes@openmarket.com>.
|
||||
# How about differentiating between stratus architectures? -djm
|
||||
echo hppa1.1-stratus-sysv4
|
||||
exit 0 ;;
|
||||
*:*:*:FTX*)
|
||||
# From seanf@swdc.stratus.com.
|
||||
echo i860-stratus-sysv4
|
||||
exit 0 ;;
|
||||
mc68*:A/UX:*:*)
|
||||
echo m68k-apple-aux${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
news*:NEWS-OS:*:6*)
|
||||
echo mips-sony-newsos6
|
||||
exit 0 ;;
|
||||
R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*)
|
||||
if [ -d /usr/nec ]; then
|
||||
echo mips-nec-sysv${UNAME_RELEASE}
|
||||
else
|
||||
echo mips-unknown-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
|
||||
|
||||
cat >dummy.c <<EOF
|
||||
#ifdef _SEQUENT_
|
||||
# include <sys/types.h>
|
||||
# include <sys/utsname.h>
|
||||
#endif
|
||||
main ()
|
||||
{
|
||||
#if defined (sony)
|
||||
#if defined (MIPSEB)
|
||||
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
|
||||
I don't know.... */
|
||||
printf ("mips-sony-bsd\n"); exit (0);
|
||||
#else
|
||||
#include <sys/param.h>
|
||||
printf ("m68k-sony-newsos%s\n",
|
||||
#ifdef NEWSOS4
|
||||
"4"
|
||||
#else
|
||||
""
|
||||
#endif
|
||||
); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__arm) && defined (__acorn) && defined (__unix)
|
||||
printf ("arm-acorn-riscix"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (hp300) && !defined (hpux)
|
||||
printf ("m68k-hp-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (NeXT)
|
||||
#if !defined (__ARCHITECTURE__)
|
||||
#define __ARCHITECTURE__ "m68k"
|
||||
#endif
|
||||
int version;
|
||||
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
|
||||
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
|
||||
exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (MULTIMAX) || defined (n16)
|
||||
#if defined (UMAXV)
|
||||
printf ("ns32k-encore-sysv\n"); exit (0);
|
||||
#else
|
||||
#if defined (CMU)
|
||||
printf ("ns32k-encore-mach\n"); exit (0);
|
||||
#else
|
||||
printf ("ns32k-encore-bsd\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__386BSD__)
|
||||
printf ("i386-pc-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (sequent)
|
||||
#if defined (i386)
|
||||
printf ("i386-sequent-dynix\n"); exit (0);
|
||||
#endif
|
||||
#if defined (ns32000)
|
||||
printf ("ns32k-sequent-dynix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (_SEQUENT_)
|
||||
struct utsname un;
|
||||
|
||||
uname(&un);
|
||||
|
||||
if (strncmp(un.version, "V2", 2) == 0) {
|
||||
printf ("i386-sequent-ptx2\n"); exit (0);
|
||||
}
|
||||
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
|
||||
printf ("i386-sequent-ptx1\n"); exit (0);
|
||||
}
|
||||
printf ("i386-sequent-ptx\n"); exit (0);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (vax)
|
||||
#if !defined (ultrix)
|
||||
printf ("vax-dec-bsd\n"); exit (0);
|
||||
#else
|
||||
printf ("vax-dec-ultrix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (alliant) && defined (i860)
|
||||
printf ("i860-alliant-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
exit (1);
|
||||
}
|
||||
EOF
|
||||
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
|
||||
# Apollos put the system type in the environment.
|
||||
|
||||
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
|
||||
|
||||
# Convex versions that predate uname can use getsysinfo(1)
|
||||
|
||||
if [ -x /usr/convex/getsysinfo ]
|
||||
then
|
||||
case `getsysinfo -f cpu_type` in
|
||||
c1*)
|
||||
echo c1-convex-bsd
|
||||
exit 0 ;;
|
||||
c2*)
|
||||
if getsysinfo -f scalar_acc
|
||||
then echo c32-convex-bsd
|
||||
else echo c2-convex-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
c34*)
|
||||
echo c34-convex-bsd
|
||||
exit 0 ;;
|
||||
c38*)
|
||||
echo c38-convex-bsd
|
||||
exit 0 ;;
|
||||
c4*)
|
||||
echo c4-convex-bsd
|
||||
exit 0 ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#echo '(Unable to guess system type)' 1>&2
|
||||
|
||||
exit 1
|
954
glib/config.sub
vendored
Executable file
954
glib/config.sub
vendored
Executable file
@ -0,0 +1,954 @@
|
||||
#! /bin/sh
|
||||
# Configuration validation subroutine script, version 1.1.
|
||||
# Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
# can handle that machine. It does not imply ALL GNU software can.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Configuration subroutine to validate and canonicalize a configuration type.
|
||||
# Supply the specified configuration type as an argument.
|
||||
# If it is invalid, we print an error message on stderr and exit with code 1.
|
||||
# Otherwise, we print the canonical config type on stdout and succeed.
|
||||
|
||||
# This file is supposed to be the same for all GNU packages
|
||||
# and recognize all the CPU types, system types and aliases
|
||||
# that are meaningful with *any* GNU software.
|
||||
# Each package is responsible for reporting which valid configurations
|
||||
# it does not support. The user should be able to distinguish
|
||||
# a failure to support a valid configuration from a meaningless
|
||||
# configuration.
|
||||
|
||||
# The goal of this file is to map all the various variations of a given
|
||||
# machine specification into a single specification in the form:
|
||||
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
|
||||
# or in some cases, the newer four-part form:
|
||||
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
|
||||
# It is wrong to echo any other type of specification.
|
||||
|
||||
if [ x$1 = x ]
|
||||
then
|
||||
echo Configuration name missing. 1>&2
|
||||
echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
|
||||
echo "or $0 ALIAS" 1>&2
|
||||
echo where ALIAS is a recognized configuration type. 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# First pass through any local machine types.
|
||||
case $1 in
|
||||
*local*)
|
||||
echo $1
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
|
||||
# Here we must recognize all the valid KERNEL-OS combinations.
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
linux-gnu*)
|
||||
os=-$maybe_os
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
*)
|
||||
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
|
||||
if [ $basic_machine != $1 ]
|
||||
then os=`echo $1 | sed 's/.*-/-/'`
|
||||
else os=; fi
|
||||
;;
|
||||
esac
|
||||
|
||||
### Let's recognize common machines as not being operating systems so
|
||||
### that things like config.sub decstation-3100 work. We also
|
||||
### recognize some manufacturers as not being operating systems, so we
|
||||
### can provide default operating systems below.
|
||||
case $os in
|
||||
-sun*os*)
|
||||
# Prevent following clause from handling this invalid input.
|
||||
;;
|
||||
-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
|
||||
-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
|
||||
-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
|
||||
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
|
||||
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
|
||||
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
|
||||
-apple)
|
||||
os=
|
||||
basic_machine=$1
|
||||
;;
|
||||
-hiux*)
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
-sco5)
|
||||
os=sco3.2v5
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco4)
|
||||
os=-sco3.2v4
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco3.2.[4-9]*)
|
||||
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco3.2v[4-9]*)
|
||||
# Don't forget version if it is 3.2v4 or newer.
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco*)
|
||||
os=-sco3.2v2
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-isc)
|
||||
os=-isc2.2
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-clix*)
|
||||
basic_machine=clipper-intergraph
|
||||
;;
|
||||
-isc*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-lynx*)
|
||||
os=-lynxos
|
||||
;;
|
||||
-ptx*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
|
||||
;;
|
||||
-windowsnt*)
|
||||
os=`echo $os | sed -e 's/windowsnt/winnt/'`
|
||||
;;
|
||||
-psos*)
|
||||
os=-psos
|
||||
;;
|
||||
esac
|
||||
|
||||
# Decode aliases for certain CPU-COMPANY combinations.
|
||||
case $basic_machine in
|
||||
# Recognize the basic CPU types without company name.
|
||||
# Some are omitted here because they have special meanings below.
|
||||
tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
|
||||
| arme[lb] | pyramid | mn10200 | mn10300 \
|
||||
| tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
|
||||
| alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \
|
||||
| i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
|
||||
| mips64 | mipsel | mips64el | mips64orion | mips64orionel \
|
||||
| mipstx39 | mipstx39el \
|
||||
| sparc | sparclet | sparclite | sparc64 | v850)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
# We use `pc' rather than `unknown'
|
||||
# because (1) that's what they normally are, and
|
||||
# (2) the word "unknown" tends to confuse beginning users.
|
||||
i[3456]86)
|
||||
basic_machine=$basic_machine-pc
|
||||
;;
|
||||
# Object if more than one company name word.
|
||||
*-*-*)
|
||||
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
# Recognize the basic CPU types with company name.
|
||||
vax-* | tahoe-* | i[3456]86-* | i860-* | m32r-* | m68k-* | m68000-* \
|
||||
| m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
|
||||
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
|
||||
| power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
|
||||
| xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \
|
||||
| alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \
|
||||
| ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
|
||||
| sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
|
||||
| sparc64-* | mips64-* | mipsel-* \
|
||||
| mips64el-* | mips64orion-* | mips64orionel-* \
|
||||
| mipstx39-* | mipstx39el-* \
|
||||
| f301-*)
|
||||
;;
|
||||
# Recognize the various machine names and aliases which stand
|
||||
# for a CPU type and a company and sometimes even an OS.
|
||||
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
|
||||
basic_machine=m68000-att
|
||||
;;
|
||||
3b*)
|
||||
basic_machine=we32k-att
|
||||
;;
|
||||
alliant | fx80)
|
||||
basic_machine=fx80-alliant
|
||||
;;
|
||||
altos | altos3068)
|
||||
basic_machine=m68k-altos
|
||||
;;
|
||||
am29k)
|
||||
basic_machine=a29k-none
|
||||
os=-bsd
|
||||
;;
|
||||
amdahl)
|
||||
basic_machine=580-amdahl
|
||||
os=-sysv
|
||||
;;
|
||||
amiga | amiga-*)
|
||||
basic_machine=m68k-cbm
|
||||
;;
|
||||
amigaos | amigados)
|
||||
basic_machine=m68k-cbm
|
||||
os=-amigaos
|
||||
;;
|
||||
amigaunix | amix)
|
||||
basic_machine=m68k-cbm
|
||||
os=-sysv4
|
||||
;;
|
||||
apollo68)
|
||||
basic_machine=m68k-apollo
|
||||
os=-sysv
|
||||
;;
|
||||
aux)
|
||||
basic_machine=m68k-apple
|
||||
os=-aux
|
||||
;;
|
||||
balance)
|
||||
basic_machine=ns32k-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
convex-c1)
|
||||
basic_machine=c1-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c2)
|
||||
basic_machine=c2-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c32)
|
||||
basic_machine=c32-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c34)
|
||||
basic_machine=c34-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c38)
|
||||
basic_machine=c38-convex
|
||||
os=-bsd
|
||||
;;
|
||||
cray | ymp)
|
||||
basic_machine=ymp-cray
|
||||
os=-unicos
|
||||
;;
|
||||
cray2)
|
||||
basic_machine=cray2-cray
|
||||
os=-unicos
|
||||
;;
|
||||
[ctj]90-cray)
|
||||
basic_machine=c90-cray
|
||||
os=-unicos
|
||||
;;
|
||||
crds | unos)
|
||||
basic_machine=m68k-crds
|
||||
;;
|
||||
da30 | da30-*)
|
||||
basic_machine=m68k-da30
|
||||
;;
|
||||
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
|
||||
basic_machine=mips-dec
|
||||
;;
|
||||
delta | 3300 | motorola-3300 | motorola-delta \
|
||||
| 3300-motorola | delta-motorola)
|
||||
basic_machine=m68k-motorola
|
||||
;;
|
||||
delta88)
|
||||
basic_machine=m88k-motorola
|
||||
os=-sysv3
|
||||
;;
|
||||
dpx20 | dpx20-*)
|
||||
basic_machine=rs6000-bull
|
||||
os=-bosx
|
||||
;;
|
||||
dpx2* | dpx2*-bull)
|
||||
basic_machine=m68k-bull
|
||||
os=-sysv3
|
||||
;;
|
||||
ebmon29k)
|
||||
basic_machine=a29k-amd
|
||||
os=-ebmon
|
||||
;;
|
||||
elxsi)
|
||||
basic_machine=elxsi-elxsi
|
||||
os=-bsd
|
||||
;;
|
||||
encore | umax | mmax)
|
||||
basic_machine=ns32k-encore
|
||||
;;
|
||||
fx2800)
|
||||
basic_machine=i860-alliant
|
||||
;;
|
||||
genix)
|
||||
basic_machine=ns32k-ns
|
||||
;;
|
||||
gmicro)
|
||||
basic_machine=tron-gmicro
|
||||
os=-sysv
|
||||
;;
|
||||
h3050r* | hiux*)
|
||||
basic_machine=hppa1.1-hitachi
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
h8300hms)
|
||||
basic_machine=h8300-hitachi
|
||||
os=-hms
|
||||
;;
|
||||
harris)
|
||||
basic_machine=m88k-harris
|
||||
os=-sysv3
|
||||
;;
|
||||
hp300-*)
|
||||
basic_machine=m68k-hp
|
||||
;;
|
||||
hp300bsd)
|
||||
basic_machine=m68k-hp
|
||||
os=-bsd
|
||||
;;
|
||||
hp300hpux)
|
||||
basic_machine=m68k-hp
|
||||
os=-hpux
|
||||
;;
|
||||
hp9k2[0-9][0-9] | hp9k31[0-9])
|
||||
basic_machine=m68000-hp
|
||||
;;
|
||||
hp9k3[2-9][0-9])
|
||||
basic_machine=m68k-hp
|
||||
;;
|
||||
hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
|
||||
basic_machine=hppa1.1-hp
|
||||
;;
|
||||
hp9k8[0-9][0-9] | hp8[0-9][0-9])
|
||||
basic_machine=hppa1.0-hp
|
||||
;;
|
||||
hppa-next)
|
||||
os=-nextstep3
|
||||
;;
|
||||
i370-ibm* | ibm*)
|
||||
basic_machine=i370-ibm
|
||||
os=-mvs
|
||||
;;
|
||||
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
|
||||
i[3456]86v32)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv32
|
||||
;;
|
||||
i[3456]86v4*)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv4
|
||||
;;
|
||||
i[3456]86v)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv
|
||||
;;
|
||||
i[3456]86sol2)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-solaris2
|
||||
;;
|
||||
iris | iris4d)
|
||||
basic_machine=mips-sgi
|
||||
case $os in
|
||||
-irix*)
|
||||
;;
|
||||
*)
|
||||
os=-irix4
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
isi68 | isi)
|
||||
basic_machine=m68k-isi
|
||||
os=-sysv
|
||||
;;
|
||||
m88k-omron*)
|
||||
basic_machine=m88k-omron
|
||||
;;
|
||||
magnum | m3230)
|
||||
basic_machine=mips-mips
|
||||
os=-sysv
|
||||
;;
|
||||
merlin)
|
||||
basic_machine=ns32k-utek
|
||||
os=-sysv
|
||||
;;
|
||||
miniframe)
|
||||
basic_machine=m68000-convergent
|
||||
;;
|
||||
mipsel*-linux*)
|
||||
basic_machine=mipsel-unknown
|
||||
os=-linux-gnu
|
||||
;;
|
||||
mips*-linux*)
|
||||
basic_machine=mips-unknown
|
||||
os=-linux-gnu
|
||||
;;
|
||||
mips3*-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
|
||||
;;
|
||||
mips3*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
|
||||
;;
|
||||
ncr3000)
|
||||
basic_machine=i486-ncr
|
||||
os=-sysv4
|
||||
;;
|
||||
news | news700 | news800 | news900)
|
||||
basic_machine=m68k-sony
|
||||
os=-newsos
|
||||
;;
|
||||
news1000)
|
||||
basic_machine=m68030-sony
|
||||
os=-newsos
|
||||
;;
|
||||
news-3600 | risc-news)
|
||||
basic_machine=mips-sony
|
||||
os=-newsos
|
||||
;;
|
||||
next | m*-next )
|
||||
basic_machine=m68k-next
|
||||
case $os in
|
||||
-nextstep* )
|
||||
;;
|
||||
-ns2*)
|
||||
os=-nextstep2
|
||||
;;
|
||||
*)
|
||||
os=-nextstep3
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
nh3000)
|
||||
basic_machine=m68k-harris
|
||||
os=-cxux
|
||||
;;
|
||||
nh[45]000)
|
||||
basic_machine=m88k-harris
|
||||
os=-cxux
|
||||
;;
|
||||
nindy960)
|
||||
basic_machine=i960-intel
|
||||
os=-nindy
|
||||
;;
|
||||
np1)
|
||||
basic_machine=np1-gould
|
||||
;;
|
||||
pa-hitachi)
|
||||
basic_machine=hppa1.1-hitachi
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
paragon)
|
||||
basic_machine=i860-intel
|
||||
os=-osf
|
||||
;;
|
||||
pbd)
|
||||
basic_machine=sparc-tti
|
||||
;;
|
||||
pbb)
|
||||
basic_machine=m68k-tti
|
||||
;;
|
||||
pc532 | pc532-*)
|
||||
basic_machine=ns32k-pc532
|
||||
;;
|
||||
pentium | p5)
|
||||
basic_machine=i586-intel
|
||||
;;
|
||||
pentiumpro | p6)
|
||||
basic_machine=i686-intel
|
||||
;;
|
||||
pentium-* | p5-*)
|
||||
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentiumpro-* | p6-*)
|
||||
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
k5)
|
||||
# We don't have specific support for AMD's K5 yet, so just call it a Pentium
|
||||
basic_machine=i586-amd
|
||||
;;
|
||||
nexen)
|
||||
# We don't have specific support for Nexgen yet, so just call it a Pentium
|
||||
basic_machine=i586-nexgen
|
||||
;;
|
||||
pn)
|
||||
basic_machine=pn-gould
|
||||
;;
|
||||
power) basic_machine=rs6000-ibm
|
||||
;;
|
||||
ppc) basic_machine=powerpc-unknown
|
||||
;;
|
||||
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ppcle | powerpclittle | ppc-le | powerpc-little)
|
||||
basic_machine=powerpcle-unknown
|
||||
;;
|
||||
ppcle-* | powerpclittle-*)
|
||||
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ps2)
|
||||
basic_machine=i386-ibm
|
||||
;;
|
||||
rm[46]00)
|
||||
basic_machine=mips-siemens
|
||||
;;
|
||||
rtpc | rtpc-*)
|
||||
basic_machine=romp-ibm
|
||||
;;
|
||||
sequent)
|
||||
basic_machine=i386-sequent
|
||||
;;
|
||||
sh)
|
||||
basic_machine=sh-hitachi
|
||||
os=-hms
|
||||
;;
|
||||
sps7)
|
||||
basic_machine=m68k-bull
|
||||
os=-sysv2
|
||||
;;
|
||||
spur)
|
||||
basic_machine=spur-unknown
|
||||
;;
|
||||
sun2)
|
||||
basic_machine=m68000-sun
|
||||
;;
|
||||
sun2os3)
|
||||
basic_machine=m68000-sun
|
||||
os=-sunos3
|
||||
;;
|
||||
sun2os4)
|
||||
basic_machine=m68000-sun
|
||||
os=-sunos4
|
||||
;;
|
||||
sun3os3)
|
||||
basic_machine=m68k-sun
|
||||
os=-sunos3
|
||||
;;
|
||||
sun3os4)
|
||||
basic_machine=m68k-sun
|
||||
os=-sunos4
|
||||
;;
|
||||
sun4os3)
|
||||
basic_machine=sparc-sun
|
||||
os=-sunos3
|
||||
;;
|
||||
sun4os4)
|
||||
basic_machine=sparc-sun
|
||||
os=-sunos4
|
||||
;;
|
||||
sun4sol2)
|
||||
basic_machine=sparc-sun
|
||||
os=-solaris2
|
||||
;;
|
||||
sun3 | sun3-*)
|
||||
basic_machine=m68k-sun
|
||||
;;
|
||||
sun4)
|
||||
basic_machine=sparc-sun
|
||||
;;
|
||||
sun386 | sun386i | roadrunner)
|
||||
basic_machine=i386-sun
|
||||
;;
|
||||
symmetry)
|
||||
basic_machine=i386-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
tx39)
|
||||
basic_machine=mipstx39-unknown
|
||||
;;
|
||||
tx39el)
|
||||
basic_machine=mipstx39el-unknown
|
||||
;;
|
||||
tower | tower-32)
|
||||
basic_machine=m68k-ncr
|
||||
;;
|
||||
udi29k)
|
||||
basic_machine=a29k-amd
|
||||
os=-udi
|
||||
;;
|
||||
ultra3)
|
||||
basic_machine=a29k-nyu
|
||||
os=-sym1
|
||||
;;
|
||||
vaxv)
|
||||
basic_machine=vax-dec
|
||||
os=-sysv
|
||||
;;
|
||||
vms)
|
||||
basic_machine=vax-dec
|
||||
os=-vms
|
||||
;;
|
||||
vpp*|vx|vx-*)
|
||||
basic_machine=f301-fujitsu
|
||||
;;
|
||||
vxworks960)
|
||||
basic_machine=i960-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
vxworks68)
|
||||
basic_machine=m68k-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
vxworks29k)
|
||||
basic_machine=a29k-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
xmp)
|
||||
basic_machine=xmp-cray
|
||||
os=-unicos
|
||||
;;
|
||||
xps | xps100)
|
||||
basic_machine=xps100-honeywell
|
||||
;;
|
||||
none)
|
||||
basic_machine=none-none
|
||||
os=-none
|
||||
;;
|
||||
|
||||
# Here we handle the default manufacturer of certain CPU types. It is in
|
||||
# some cases the only manufacturer, in others, it is the most popular.
|
||||
mips)
|
||||
if [ x$os = x-linux-gnu ]; then
|
||||
basic_machine=mips-unknown
|
||||
else
|
||||
basic_machine=mips-mips
|
||||
fi
|
||||
;;
|
||||
romp)
|
||||
basic_machine=romp-ibm
|
||||
;;
|
||||
rs6000)
|
||||
basic_machine=rs6000-ibm
|
||||
;;
|
||||
vax)
|
||||
basic_machine=vax-dec
|
||||
;;
|
||||
pdp11)
|
||||
basic_machine=pdp11-dec
|
||||
;;
|
||||
we32k)
|
||||
basic_machine=we32k-att
|
||||
;;
|
||||
sparc)
|
||||
basic_machine=sparc-sun
|
||||
;;
|
||||
cydra)
|
||||
basic_machine=cydra-cydrome
|
||||
;;
|
||||
orion)
|
||||
basic_machine=orion-highlevel
|
||||
;;
|
||||
orion105)
|
||||
basic_machine=clipper-highlevel
|
||||
;;
|
||||
*)
|
||||
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Here we canonicalize certain aliases for manufacturers.
|
||||
case $basic_machine in
|
||||
*-digital*)
|
||||
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
|
||||
;;
|
||||
*-commodore*)
|
||||
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Decode manufacturer-specific aliases for certain operating systems.
|
||||
|
||||
if [ x"$os" != x"" ]
|
||||
then
|
||||
case $os in
|
||||
# First match some system type aliases
|
||||
# that might get confused with valid system types.
|
||||
# -solaris* is a basic system type, with this one exception.
|
||||
-solaris1 | -solaris1.*)
|
||||
os=`echo $os | sed -e 's|solaris1|sunos4|'`
|
||||
;;
|
||||
-solaris)
|
||||
os=-solaris2
|
||||
;;
|
||||
-svr4*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-unixware*)
|
||||
os=-sysv4.2uw
|
||||
;;
|
||||
-gnu/linux*)
|
||||
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
|
||||
;;
|
||||
# First accept the basic system types.
|
||||
# The portable systems comes first.
|
||||
# Each alternative MUST END IN A *, to match a version number.
|
||||
# -sysv* is not here because it comes later, after sysvr4.
|
||||
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
|
||||
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
|
||||
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
|
||||
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
|
||||
| -aos* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
|
||||
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
|
||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -linux-gnu* | -uxpv*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-linux*)
|
||||
os=`echo $os | sed -e 's|linux|linux-gnu|'`
|
||||
;;
|
||||
-sunos5*)
|
||||
os=`echo $os | sed -e 's|sunos5|solaris2|'`
|
||||
;;
|
||||
-sunos6*)
|
||||
os=`echo $os | sed -e 's|sunos6|solaris3|'`
|
||||
;;
|
||||
-osfrose*)
|
||||
os=-osfrose
|
||||
;;
|
||||
-osf*)
|
||||
os=-osf
|
||||
;;
|
||||
-utek*)
|
||||
os=-bsd
|
||||
;;
|
||||
-dynix*)
|
||||
os=-bsd
|
||||
;;
|
||||
-acis*)
|
||||
os=-aos
|
||||
;;
|
||||
-ctix* | -uts*)
|
||||
os=-sysv
|
||||
;;
|
||||
-ns2 )
|
||||
os=-nextstep2
|
||||
;;
|
||||
# Preserve the version number of sinix5.
|
||||
-sinix5.*)
|
||||
os=`echo $os | sed -e 's|sinix|sysv|'`
|
||||
;;
|
||||
-sinix*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-triton*)
|
||||
os=-sysv3
|
||||
;;
|
||||
-oss*)
|
||||
os=-sysv3
|
||||
;;
|
||||
-svr4)
|
||||
os=-sysv4
|
||||
;;
|
||||
-svr3)
|
||||
os=-sysv3
|
||||
;;
|
||||
-sysvr4)
|
||||
os=-sysv4
|
||||
;;
|
||||
# This must come after -sysvr4.
|
||||
-sysv*)
|
||||
;;
|
||||
-xenix)
|
||||
os=-xenix
|
||||
;;
|
||||
-none)
|
||||
;;
|
||||
*)
|
||||
# Get rid of the `-' at the beginning of $os.
|
||||
os=`echo $os | sed 's/[^-]*-//'`
|
||||
echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
|
||||
# Here we handle the default operating systems that come with various machines.
|
||||
# The value should be what the vendor currently ships out the door with their
|
||||
# machine or put another way, the most popular os provided with the machine.
|
||||
|
||||
# Note that if you're going to try to match "-MANUFACTURER" here (say,
|
||||
# "-sun"), then you have to tell the case statement up towards the top
|
||||
# that MANUFACTURER isn't an operating system. Otherwise, code above
|
||||
# will signal an error saying that MANUFACTURER isn't an operating
|
||||
# system, and we'll never get to this point.
|
||||
|
||||
case $basic_machine in
|
||||
*-acorn)
|
||||
os=-riscix1.2
|
||||
;;
|
||||
arm*-semi)
|
||||
os=-aout
|
||||
;;
|
||||
pdp11-*)
|
||||
os=-none
|
||||
;;
|
||||
*-dec | vax-*)
|
||||
os=-ultrix4.2
|
||||
;;
|
||||
m68*-apollo)
|
||||
os=-domain
|
||||
;;
|
||||
i386-sun)
|
||||
os=-sunos4.0.2
|
||||
;;
|
||||
m68000-sun)
|
||||
os=-sunos3
|
||||
# This also exists in the configure program, but was not the
|
||||
# default.
|
||||
# os=-sunos4
|
||||
;;
|
||||
*-tti) # must be before sparc entry or we get the wrong os.
|
||||
os=-sysv3
|
||||
;;
|
||||
sparc-* | *-sun)
|
||||
os=-sunos4.1.1
|
||||
;;
|
||||
*-ibm)
|
||||
os=-aix
|
||||
;;
|
||||
*-hp)
|
||||
os=-hpux
|
||||
;;
|
||||
*-hitachi)
|
||||
os=-hiux
|
||||
;;
|
||||
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
|
||||
os=-sysv
|
||||
;;
|
||||
*-cbm)
|
||||
os=-amigaos
|
||||
;;
|
||||
*-dg)
|
||||
os=-dgux
|
||||
;;
|
||||
*-dolphin)
|
||||
os=-sysv3
|
||||
;;
|
||||
m68k-ccur)
|
||||
os=-rtu
|
||||
;;
|
||||
m88k-omron*)
|
||||
os=-luna
|
||||
;;
|
||||
*-next )
|
||||
os=-nextstep
|
||||
;;
|
||||
*-sequent)
|
||||
os=-ptx
|
||||
;;
|
||||
*-crds)
|
||||
os=-unos
|
||||
;;
|
||||
*-ns)
|
||||
os=-genix
|
||||
;;
|
||||
i370-*)
|
||||
os=-mvs
|
||||
;;
|
||||
*-next)
|
||||
os=-nextstep3
|
||||
;;
|
||||
*-gould)
|
||||
os=-sysv
|
||||
;;
|
||||
*-highlevel)
|
||||
os=-bsd
|
||||
;;
|
||||
*-encore)
|
||||
os=-bsd
|
||||
;;
|
||||
*-sgi)
|
||||
os=-irix
|
||||
;;
|
||||
*-siemens)
|
||||
os=-sysv4
|
||||
;;
|
||||
*-masscomp)
|
||||
os=-rtu
|
||||
;;
|
||||
f301-fujitsu)
|
||||
os=-uxpv
|
||||
;;
|
||||
*)
|
||||
os=-none
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Here we handle the case where we know the os, and the CPU type, but not the
|
||||
# manufacturer. We pick the logical manufacturer.
|
||||
vendor=unknown
|
||||
case $basic_machine in
|
||||
*-unknown)
|
||||
case $os in
|
||||
-riscix*)
|
||||
vendor=acorn
|
||||
;;
|
||||
-sunos*)
|
||||
vendor=sun
|
||||
;;
|
||||
-aix*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-hpux*)
|
||||
vendor=hp
|
||||
;;
|
||||
-hiux*)
|
||||
vendor=hitachi
|
||||
;;
|
||||
-unos*)
|
||||
vendor=crds
|
||||
;;
|
||||
-dgux*)
|
||||
vendor=dg
|
||||
;;
|
||||
-luna*)
|
||||
vendor=omron
|
||||
;;
|
||||
-genix*)
|
||||
vendor=ns
|
||||
;;
|
||||
-mvs*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-ptx*)
|
||||
vendor=sequent
|
||||
;;
|
||||
-vxsim* | -vxworks*)
|
||||
vendor=wrs
|
||||
;;
|
||||
-aux*)
|
||||
vendor=apple
|
||||
;;
|
||||
esac
|
||||
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
|
||||
;;
|
||||
esac
|
||||
|
||||
echo $basic_machine$os
|
2921
glib/configure
vendored
Executable file
2921
glib/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
116
glib/configure.in
Normal file
116
glib/configure.in
Normal file
@ -0,0 +1,116 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(glib.h)
|
||||
|
||||
dnl Initialize automake stuff
|
||||
AM_INIT_AUTOMAKE(glib, 971109)
|
||||
|
||||
# Specify a configuration file
|
||||
AM_CONFIG_HEADER(glibconfig.h)
|
||||
|
||||
dnl Initialize libtool
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
dnl Initialize maintainer mode
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging [default=no]],
|
||||
if eval "test x$enable_debug = xyes"; then
|
||||
DEBUGFLAG="-g"
|
||||
fi)
|
||||
|
||||
AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]],
|
||||
, enable_ansi=no)
|
||||
|
||||
if test -n "$DEBUGFLAG"; then
|
||||
CFLAGS="$DEBUGFLAG"
|
||||
fi
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_STDC
|
||||
AC_PROG_INSTALL
|
||||
|
||||
if eval "test x$GCC = xyes"; then
|
||||
test `echo "$CFLAGS" | grep "\-Wall" > /dev/null 2> /dev/null`
|
||||
if test ! $?; then
|
||||
CFLAGS="$CFLAGS -Wall"
|
||||
fi
|
||||
|
||||
if eval "test x$enable_ansi = xyes"; then
|
||||
test `echo "$CFLAGS" | grep "\-ansi" > /dev/null 2> /dev/null`
|
||||
if test ! $?; then
|
||||
CFLAGS="$CFLAGS -ansi"
|
||||
fi
|
||||
|
||||
test `echo "$CFLAGS" | grep "\-pedantic" > /dev/null 2> /dev/null`
|
||||
if test ! $?; then
|
||||
CFLAGS="$CFLAGS -pedantic"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_VPRINTF
|
||||
|
||||
AC_CHECK_SIZEOF(char)
|
||||
AC_CHECK_SIZEOF(short)
|
||||
AC_CHECK_SIZEOF(long)
|
||||
AC_CHECK_SIZEOF(int)
|
||||
AC_CHECK_SIZEOF(void *)
|
||||
|
||||
AC_C_LONG_DOUBLE
|
||||
AC_C_CONST
|
||||
AC_C_INLINE
|
||||
|
||||
AC_CHECK_HEADERS(float.h, AC_DEFINE(HAVE_FLOAT_H))
|
||||
AC_CHECK_HEADERS(limits.h, AC_DEFINE(HAVE_LIMITS_H))
|
||||
AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H))
|
||||
|
||||
# Check for strerror and strsignal functions
|
||||
AC_CHECK_FUNCS(strerror strsignal)
|
||||
|
||||
# Check for sys_errlist
|
||||
AC_MSG_CHECKING(sys_errlist)
|
||||
AC_TRY_LINK(, [
|
||||
extern char *sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
sys_errlist[sys_nerr-1][0] = 0;
|
||||
], glib_ok=yes, glib_ok=no)
|
||||
AC_MSG_RESULT($glib_ok)
|
||||
if test $glib_ok = no; then
|
||||
AC_DEFINE(NO_SYS_ERRLIST)
|
||||
fi
|
||||
|
||||
# Check for sys_siglist
|
||||
AC_MSG_CHECKING(sys_siglist)
|
||||
AC_TRY_LINK(, [
|
||||
extern char *sys_siglist[];
|
||||
sys_siglist[1][0] = 0;
|
||||
], glib_ok=yes, glib_ok=no)
|
||||
AC_MSG_RESULT($glib_ok)
|
||||
if test $glib_ok = no; then
|
||||
AC_DEFINE(NO_SYS_SIGLIST)
|
||||
fi
|
||||
|
||||
# Check for sys/select.h
|
||||
|
||||
AC_MSG_CHECKING([fd_set and sys/select])
|
||||
AC_TRY_COMPILE([#include <sys/types.h>],
|
||||
[fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
|
||||
if test $gtk_ok = no; then
|
||||
AC_HEADER_EGREP(fd_mask, sys/select.h, gtk_ok=yes)
|
||||
if test $gtk_ok = yes; then
|
||||
AC_DEFINE(HAVE_SYS_SELECT_H)
|
||||
fi
|
||||
fi
|
||||
AC_MSG_RESULT($gtk_ok)
|
||||
if test $gtk_ok = no; then
|
||||
AC_DEFINE(NO_FD_SET)
|
||||
fi
|
||||
|
||||
AC_OUTPUT(Makefile)
|
142
glib/garray.c
Normal file
142
glib/garray.c
Normal file
@ -0,0 +1,142 @@
|
||||
/* GLIB - Library of useful routines for C programming
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "glib.h"
|
||||
|
||||
|
||||
#define MIN_ARRAY_SIZE 16
|
||||
|
||||
|
||||
typedef struct _GRealArray GRealArray;
|
||||
|
||||
struct _GRealArray
|
||||
{
|
||||
guint8 *data;
|
||||
guint len;
|
||||
guint alloc;
|
||||
guint zero_terminated;
|
||||
};
|
||||
|
||||
|
||||
static gint g_nearest_pow (gint num);
|
||||
static void g_array_maybe_expand (GRealArray *array,
|
||||
gint len);
|
||||
|
||||
|
||||
static GMemChunk *array_mem_chunk = NULL;
|
||||
|
||||
|
||||
GArray*
|
||||
g_array_new (zero_terminated)
|
||||
{
|
||||
GRealArray *array;
|
||||
|
||||
if (!array_mem_chunk)
|
||||
array_mem_chunk = g_mem_chunk_new ("array mem chunk",
|
||||
sizeof (GRealArray),
|
||||
1024, G_ALLOC_AND_FREE);
|
||||
|
||||
array = g_chunk_new (GRealArray, array_mem_chunk);
|
||||
|
||||
array->data = NULL;
|
||||
array->len = 0;
|
||||
array->alloc = 0;
|
||||
array->zero_terminated = (zero_terminated ? 1 : 0);
|
||||
|
||||
return (GArray*) array;
|
||||
}
|
||||
|
||||
void
|
||||
g_array_free (GArray *array,
|
||||
gint free_segment)
|
||||
{
|
||||
if (free_segment)
|
||||
g_free (array->data);
|
||||
|
||||
g_mem_chunk_free (array_mem_chunk, array);
|
||||
}
|
||||
|
||||
GArray*
|
||||
g_rarray_append (GArray *array,
|
||||
gpointer data,
|
||||
gint size)
|
||||
{
|
||||
g_array_maybe_expand ((GRealArray*) array, size);
|
||||
|
||||
memcpy (array->data + array->len, data, size);
|
||||
|
||||
array->len += size;
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
GArray*
|
||||
g_rarray_prepend (GArray *array,
|
||||
gpointer data,
|
||||
gint size)
|
||||
{
|
||||
g_array_maybe_expand ((GRealArray*) array, size);
|
||||
|
||||
memmove (array->data + size, array->data, array->len);
|
||||
memcpy (array->data, data, size);
|
||||
|
||||
array->len += size;
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
GArray*
|
||||
g_rarray_truncate (GArray *array,
|
||||
gint length,
|
||||
gint size)
|
||||
{
|
||||
if (array->data)
|
||||
memset (array->data + length * size, 0, size);
|
||||
array->len = length;
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
static gint
|
||||
g_nearest_pow (gint num)
|
||||
{
|
||||
gint n = 1;
|
||||
|
||||
while (n < num)
|
||||
n <<= 1;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static void
|
||||
g_array_maybe_expand (GRealArray *array,
|
||||
gint len)
|
||||
{
|
||||
guint old_alloc;
|
||||
|
||||
if ((array->len + len) > array->alloc)
|
||||
{
|
||||
old_alloc = array->alloc;
|
||||
|
||||
array->alloc = g_nearest_pow (array->len + array->zero_terminated + len);
|
||||
array->alloc = MAX (array->alloc, MIN_ARRAY_SIZE);
|
||||
array->data = g_realloc (array->data, array->alloc);
|
||||
|
||||
memset (array->data + old_alloc, 0, array->alloc - old_alloc);
|
||||
}
|
||||
}
|
211
glib/gcache.c
Normal file
211
glib/gcache.c
Normal file
@ -0,0 +1,211 @@
|
||||
/* GLIB - Library of useful routines for C programming
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include "glib.h"
|
||||
|
||||
|
||||
typedef struct _GCacheNode GCacheNode;
|
||||
typedef struct _GRealCache GRealCache;
|
||||
|
||||
struct _GCacheNode
|
||||
{
|
||||
/* A reference counted node */
|
||||
gpointer value;
|
||||
gint ref_count;
|
||||
};
|
||||
|
||||
struct _GRealCache
|
||||
{
|
||||
/* Called to create a value from a key */
|
||||
GCacheNewFunc value_new_func;
|
||||
|
||||
/* Called to destroy a value */
|
||||
GCacheDestroyFunc value_destroy_func;
|
||||
|
||||
/* Called to duplicate a key */
|
||||
GCacheDupFunc key_dup_func;
|
||||
|
||||
/* Called to destroy a key */
|
||||
GCacheDestroyFunc key_destroy_func;
|
||||
|
||||
/* Associates keys with nodes */
|
||||
GHashTable *key_table;
|
||||
|
||||
/* Associates nodes with keys */
|
||||
GHashTable *value_table;
|
||||
};
|
||||
|
||||
|
||||
static GCacheNode* g_cache_node_new (gpointer value);
|
||||
static void g_cache_node_destroy (GCacheNode *node);
|
||||
|
||||
|
||||
static GMemChunk *node_mem_chunk = NULL;
|
||||
|
||||
|
||||
GCache*
|
||||
g_cache_new (GCacheNewFunc value_new_func,
|
||||
GCacheDestroyFunc value_destroy_func,
|
||||
GCacheDupFunc key_dup_func,
|
||||
GCacheDestroyFunc key_destroy_func,
|
||||
GHashFunc hash_key_func,
|
||||
GHashFunc hash_value_func,
|
||||
GCompareFunc key_compare_func)
|
||||
{
|
||||
GRealCache *cache;
|
||||
|
||||
g_return_val_if_fail (value_new_func != NULL, NULL);
|
||||
g_return_val_if_fail (value_destroy_func != NULL, NULL);
|
||||
g_return_val_if_fail (key_dup_func != NULL, NULL);
|
||||
g_return_val_if_fail (key_destroy_func != NULL, NULL);
|
||||
g_return_val_if_fail (hash_key_func != NULL, NULL);
|
||||
g_return_val_if_fail (hash_value_func != NULL, NULL);
|
||||
g_return_val_if_fail (key_compare_func != NULL, NULL);
|
||||
|
||||
cache = g_new (GRealCache, 1);
|
||||
cache->value_new_func = value_new_func;
|
||||
cache->value_destroy_func = value_destroy_func;
|
||||
cache->key_dup_func = key_dup_func;
|
||||
cache->key_destroy_func = key_destroy_func;
|
||||
cache->key_table = g_hash_table_new (hash_key_func, key_compare_func);
|
||||
cache->value_table = g_hash_table_new (hash_value_func, NULL);
|
||||
|
||||
return (GCache*) cache;
|
||||
}
|
||||
|
||||
void
|
||||
g_cache_destroy (GCache *cache)
|
||||
{
|
||||
GRealCache *rcache;
|
||||
|
||||
g_return_if_fail (cache != NULL);
|
||||
|
||||
rcache = (GRealCache*) cache;
|
||||
g_hash_table_destroy (rcache->key_table);
|
||||
g_hash_table_destroy (rcache->value_table);
|
||||
g_free (rcache);
|
||||
}
|
||||
|
||||
gpointer
|
||||
g_cache_insert (GCache *cache,
|
||||
gpointer key)
|
||||
{
|
||||
GRealCache *rcache;
|
||||
GCacheNode *node;
|
||||
gpointer value;
|
||||
|
||||
g_return_val_if_fail (cache != NULL, NULL);
|
||||
|
||||
rcache = (GRealCache*) cache;
|
||||
|
||||
node = g_hash_table_lookup (rcache->key_table, key);
|
||||
if (node)
|
||||
{
|
||||
node->ref_count += 1;
|
||||
return node->value;
|
||||
}
|
||||
|
||||
key = (* rcache->key_dup_func) (key);
|
||||
value = (* rcache->value_new_func) (key);
|
||||
node = g_cache_node_new (value);
|
||||
|
||||
g_hash_table_insert (rcache->key_table, key, node);
|
||||
g_hash_table_insert (rcache->value_table, value, key);
|
||||
|
||||
return node->value;
|
||||
}
|
||||
|
||||
void
|
||||
g_cache_remove (GCache *cache,
|
||||
gpointer value)
|
||||
{
|
||||
GRealCache *rcache;
|
||||
GCacheNode *node;
|
||||
gpointer key;
|
||||
|
||||
g_return_if_fail (cache != NULL);
|
||||
|
||||
rcache = (GRealCache*) cache;
|
||||
|
||||
key = g_hash_table_lookup (rcache->value_table, value);
|
||||
node = g_hash_table_lookup (rcache->key_table, key);
|
||||
|
||||
node->ref_count -= 1;
|
||||
if (node->ref_count == 0)
|
||||
{
|
||||
g_hash_table_remove (rcache->value_table, value);
|
||||
g_hash_table_remove (rcache->key_table, key);
|
||||
|
||||
(* rcache->key_destroy_func) (key);
|
||||
(* rcache->value_destroy_func) (node->value);
|
||||
g_cache_node_destroy (node);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
g_cache_key_foreach (GCache *cache,
|
||||
GHFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GRealCache *rcache;
|
||||
|
||||
g_return_if_fail (cache != NULL);
|
||||
g_return_if_fail (func != NULL);
|
||||
|
||||
rcache = (GRealCache*) cache;
|
||||
|
||||
g_hash_table_foreach (rcache->value_table, func, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
g_cache_value_foreach (GCache *cache,
|
||||
GHFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GRealCache *rcache;
|
||||
|
||||
g_return_if_fail (cache != NULL);
|
||||
g_return_if_fail (func != NULL);
|
||||
|
||||
rcache = (GRealCache*) cache;
|
||||
|
||||
g_hash_table_foreach (rcache->key_table, func, user_data);
|
||||
}
|
||||
|
||||
|
||||
static GCacheNode*
|
||||
g_cache_node_new (gpointer value)
|
||||
{
|
||||
GCacheNode *node;
|
||||
|
||||
if (!node_mem_chunk)
|
||||
node_mem_chunk = g_mem_chunk_new ("cache node mem chunk", sizeof (GCacheNode),
|
||||
1024, G_ALLOC_AND_FREE);
|
||||
|
||||
node = g_chunk_new (GCacheNode, node_mem_chunk);
|
||||
|
||||
node->value = value;
|
||||
node->ref_count = 1;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static void
|
||||
g_cache_node_destroy (GCacheNode *node)
|
||||
{
|
||||
g_mem_chunk_free (node_mem_chunk, node);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user