summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
Diffstat (limited to 'gdk')
-rw-r--r--gdk/COPYING504
-rw-r--r--gdk/Makefile.am121
-rw-r--r--gdk/gdk.c74
-rw-r--r--gdk/gdk.h121
-rw-r--r--gdk/gdkcc.c50
-rw-r--r--gdk/gdkcolor.c207
-rw-r--r--gdk/gdkdnd.c76
-rw-r--r--gdk/gdkdraw.c12
-rw-r--r--gdk/gdkevents.c197
-rw-r--r--gdk/gdkfont.c107
-rw-r--r--gdk/gdkgc.c1
-rw-r--r--gdk/gdkglobals.c2
-rw-r--r--gdk/gdkim.c30
-rw-r--r--gdk/gdkimage.c24
-rw-r--r--gdk/gdkpixmap.c5
-rw-r--r--gdk/gdkprivate.h2
-rw-r--r--gdk/gdkproperty.c15
-rw-r--r--gdk/gdkrgb.c15
-rw-r--r--gdk/gdkselection.c10
-rw-r--r--gdk/gdkwindow.c61
-rw-r--r--gdk/x11/gdkcc-x11.c50
-rw-r--r--gdk/x11/gdkcolor-x11.c207
-rw-r--r--gdk/x11/gdkdnd-x11.c76
-rw-r--r--gdk/x11/gdkevents-x11.c197
-rw-r--r--gdk/x11/gdkfont-x11.c107
-rw-r--r--gdk/x11/gdkglobals-x11.c2
-rw-r--r--gdk/x11/gdkim-x11.c30
-rw-r--r--gdk/x11/gdkimage-x11.c24
-rw-r--r--gdk/x11/gdkmain-x11.c74
-rw-r--r--gdk/x11/gdkpixmap-x11.c5
-rw-r--r--gdk/x11/gdkproperty-x11.c15
-rw-r--r--gdk/x11/gdkselection-x11.c10
-rw-r--r--gdk/x11/gdkwindow-x11.c61
33 files changed, 1646 insertions, 846 deletions
diff --git a/gdk/COPYING b/gdk/COPYING
new file mode 100644
index 0000000000..223ede7de3
--- /dev/null
+++ b/gdk/COPYING
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <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 Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+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!
+
+
diff --git a/gdk/Makefile.am b/gdk/Makefile.am
index 6bb478351d..39f07bbfaa 100644
--- a/gdk/Makefile.am
+++ b/gdk/Makefile.am
@@ -1,21 +1,47 @@
-## Process this file with automake to produce Makefile.in
+## Makefile.am for gtk+/gdk
-gdkincludedir = $(includedir)/gdk
-
-
-
-lib_LTLIBRARIES = libgdk.la
-
-INCLUDES = \
+INCLUDES = @STRIP_BEGIN@ \
-DG_LOG_DOMAIN=\"Gdk\" \
-I$(top_srcdir) \
@GTK_DEBUG_FLAGS@ \
@GTK_XIM_FLAGS@ \
@GTK_LOCALE_FLAGS@ \
@GLIB_CFLAGS@ \
- @x_cflags@
+ @x_cflags@ \
+@STRIP_END@
+
+#
+# libraries to compile and install
+#
+lib_LTLIBRARIES = libgdk.la
-libgdk_la_SOURCES = \
+# libtool stuff: set version and export symbols for resolving
+libgdkincludedir = $(includedir)/gdk
+libgdk_la_LDFLAGS = @STRIP_BEGIN@ \
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+ -release $(LT_RELEASE) \
+ -export-dynamic \
+ @GLIB_DEPLIBS@ \
+ @x_ldflags@ \
+ @x_libs@ \
+ -lm \
+@STRIP_END@
+
+#
+# setup source file variables
+#
+# GDK header files for public installation (non-generated)
+gdk_public_h_sources = @STRIP_BEGIN@ \
+ gdk.h \
+ gdkcursors.h \
+ gdkrgb.h \
+ gdki18n.h \
+ gdkkeysyms.h \
+ gdkprivate.h \
+ gdktypes.h \
+ gdkx.h \
+@STRIP_END@
+gdk_c_sources = @STRIP_BEGIN@ \
gdk.c \
gdkcc.c \
gdkcolor.c \
@@ -46,34 +72,35 @@ libgdk_la_SOURCES = \
MwmUtil.h \
gxid_lib.h \
gxid_proto.h \
- 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 \
- gdkrgb.h \
- gdki18n.h \
- gdkkeysyms.h \
- gdkprivate.h \
- gdktypes.h \
- gdkx.h
-
-LDADDS = \
- @x_ldflags@ \
- @x_libs@ \
- @GLIB_LIBS@ \
- -lm
-
-libgdk_la_LDFLAGS = \
- -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -release $(LT_RELEASE) \
- @GLIB_DEPLIBS@ \
- @x_ldflags@ \
- @x_libs@ \
- -lm
+ gxid_lib.c \
+@STRIP_END@
+
+#
+# setup GDK sources and their dependancies
+#
+libgdkinclude_HEADERS = $(gdk_public_h_sources)
+libgdk_la_SOURCES = $(gdk_c_sources)
+MAINTAINERCLEANFILES +=
+EXTRA_HEADERS +=
+EXTRA_DIST +=
+EXTRA_DIST +=
+
+#
+# rules to generate built sources
+#
+# we only need to remake these headers once a new X version is released
+X-derived-headers:
+ sed -e 's/^#define[ ]*XC\([^ ]*\)[ ]*\([^ ]*\)[ ]*.*$$/GDK\1 = \2,/' \
+ -e 'tb' -e 'd' -e ':b' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
+ < @x_includes@/X11/cursorfont.h > gdkcursors.h ; \
+ sed -e 's/^#define[ ]*XK\([^ ]*\)[ ]*\([^ ]*\)[ ]*.*$$/#define GDK\1 \2/' \
+ -e 'tb' -e 'd' -e ':b' -e 's/ 0X/ 0x/' \
+ < @x_includes@/X11/keysymdef.h > gdkkeysyms.h
+#
+# Rule to install gdkconfig.h header file
+#
configexecincludedir = $(pkglibdir)/include
#configexecinclude_DATA = gdkconfig.h
install-exec-local: gdkconfig.h
@@ -90,22 +117,20 @@ stamp-gc-h: ../config.status
cd .. && CONFIG_FILES= CONFIG_HEADERS= CONFIG_OTHER=gdk/gdkconfig.h ./config.status
echo timestamp > stamp-gc-h
+#
+# extra programs
+#
EXTRA_PROGRAMS = gxid
-
bin_PROGRAMS = @xinput_progs@
-
+LDADDS = @STRIP_BEGIN@ \
+ @x_ldflags@ \
+ @x_libs@ \
+ @GLIB_LIBS@ \
+ -lm \
+@STRIP_END@
gxid_SOURCES = gxid.c
-
gxid_LDADD = $(LDADDS)
-X-derived-headers:
- sed -e 's/^#define[ ]*XC\([^ ]*\)[ ]*\([^ ]*\)[ ]*.*$$/GDK\1 = \2,/' \
- -e 'tb' -e 'd' -e ':b' \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
- < @x_includes@/X11/cursorfont.h > gdkcursors.h ; \
- sed -e 's/^#define[ ]*XK\([^ ]*\)[ ]*\([^ ]*\)[ ]*.*$$/#define GDK\1 \2/' \
- -e 'tb' -e 'd' -e ':b' -e 's/ 0X/ 0x/' \
- < @x_includes@/X11/keysymdef.h > gdkkeysyms.h
.PHONY: files
diff --git a/gdk/gdk.c b/gdk/gdk.c
index e907f04adb..de1d55ea8c 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
+#include <errno.h>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
@@ -48,6 +49,7 @@
#include "gdkinput.h"
#include "gdkx.h"
#include "gdki18n.h"
+#include "gdkkeysyms.h"
#ifndef X_GETTIMEOFDAY
#define X_GETTIMEOFDAY(tv) gettimeofday (tv, NULL)
@@ -333,6 +335,7 @@ gdk_init_check (int *argc,
gdk_im_set_best_style (GDK_IM_PREEDIT_POSITION);
else if (strcmp ("callbacks", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
+ (*argv)[i] = NULL;
}
}
else if (strcmp ("--xim-status", (*argv)[i]) == 0)
@@ -348,6 +351,7 @@ gdk_init_check (int *argc,
gdk_im_set_best_style (GDK_IM_STATUS_AREA);
else if (strcmp ("callbacks", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
+ (*argv)[i] = NULL;
}
}
#endif
@@ -406,9 +410,9 @@ gdk_init_check (int *argc,
g_free(argv_orig[i]);
g_free(argv_orig);
- gdk_wm_delete_window = XInternAtom (gdk_display, "WM_DELETE_WINDOW", True);
- gdk_wm_take_focus = XInternAtom (gdk_display, "WM_TAKE_FOCUS", True);
- gdk_wm_protocols = XInternAtom (gdk_display, "WM_PROTOCOLS", True);
+ gdk_wm_delete_window = XInternAtom (gdk_display, "WM_DELETE_WINDOW", False);
+ gdk_wm_take_focus = XInternAtom (gdk_display, "WM_TAKE_FOCUS", False);
+ gdk_wm_protocols = XInternAtom (gdk_display, "WM_PROTOCOLS", False);
gdk_wm_window_protocols[0] = gdk_wm_delete_window;
gdk_wm_window_protocols[1] = gdk_wm_take_focus;
gdk_selection_property = XInternAtom (gdk_display, "GDK_SELECTION", False);
@@ -1032,20 +1036,35 @@ static int
gdk_x_error (Display *display,
XErrorEvent *error)
{
- char buf[64];
-
- if (gdk_error_warnings)
+ if (error->error_code)
{
- XGetErrorText (display, error->error_code, buf, 63);
- g_error ("%s\n serial %ld error_code %d request_code %d minor_code %d\n",
- buf,
- error->serial,
- error->error_code,
- error->request_code,
- error->minor_code);
+ if (gdk_error_warnings)
+ {
+ char buf[64];
+
+ XGetErrorText (display, error->error_code, buf, 63);
+
+#ifdef G_ENABLE_DEBUG
+ g_error ("%s\n serial %ld error_code %d request_code %d minor_code %d\n",
+ buf,
+ error->serial,
+ error->error_code,
+ error->request_code,
+ error->minor_code);
+#else /* !G_ENABLE_DEBUG */
+ fprintf (stderr, "Gdk-ERROR **: %s\n serial %ld error_code %d request_code %d minor_code %d\n",
+ buf,
+ error->serial,
+ error->error_code,
+ error->request_code,
+ error->minor_code);
+
+ exit(1);
+#endif /* G_ENABLE_DEBUG */
+ }
+ gdk_error_code = error->error_code;
}
- gdk_error_code = -1;
return 0;
}
@@ -1071,8 +1090,27 @@ gdk_x_error (Display *display,
static int
gdk_x_io_error (Display *display)
{
- g_error ("an x io error occurred");
- return 0;
+ /* This is basically modelled after the code in XLib. We need
+ * an explicit error handler here, so we can disable our atexit()
+ * which would otherwise cause a nice segfault.
+ * We fprintf(stderr, instead of g_warning() because g_warning()
+ * could possibly be redirected to a dialog
+ */
+ if (errno == EPIPE)
+ {
+ fprintf (stderr, "Gdk-ERROR **: X connection to %s broken (explicit kill or server shutdown).\n", gdk_display ? DisplayString (gdk_display) : gdk_get_display());
+ }
+ else
+ {
+ fprintf (stderr, "Gdk-ERROR **: Fatal IO error %d (%s) on X server %s.\n",
+ errno, g_strerror (errno),
+ gdk_display ? DisplayString (gdk_display) : gdk_get_display());
+ }
+
+ /* Disable the atexit shutdown for GDK */
+ gdk_initialized = 0;
+
+ exit(1);
}
gchar *
@@ -1104,7 +1142,7 @@ gdk_error_trap_push (void)
}
else
{
- node = g_slist_alloc();
+ node = g_slist_alloc ();
node->data = g_new (GdkErrorTrap, 1);
}
@@ -1166,7 +1204,7 @@ gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
XSync (gdk_display, False);
gdk_error_warnings = old_warnings;
- return result && (gdk_error_code != -1);
+ return result && !gdk_error_code;
}
#ifndef HAVE_XCONVERTCASE
diff --git a/gdk/gdk.h b/gdk/gdk.h
index 9b7e20d72b..5b6ae8a62e 100644
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -488,8 +488,8 @@ GdkPixmap* gdk_pixmap_create_from_xpm (GdkWindow *window,
GdkBitmap **mask,
GdkColor *transparent_color,
const gchar *filename);
-GdkPixmap* gdk_pixmap_colormap_create_from_xpm
- (GdkWindow *window,
+GdkPixmap* gdk_pixmap_colormap_create_from_xpm (
+ GdkWindow *window,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
@@ -498,8 +498,8 @@ GdkPixmap* gdk_pixmap_create_from_xpm_d (GdkWindow *window,
GdkBitmap **mask,
GdkColor *transparent_color,
gchar **data);
-GdkPixmap* gdk_pixmap_colormap_create_from_xpm_d
- (GdkWindow *window,
+GdkPixmap* gdk_pixmap_colormap_create_from_xpm_d (
+ GdkWindow *window,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
@@ -544,66 +544,65 @@ void gdk_image_destroy (GdkImage *image);
/* Color
*/
-GdkColormap* gdk_colormap_new (GdkVisual *visual,
- gint allocate);
-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);
-
-
-gint gdk_colormap_alloc_colors (GdkColormap *colormap,
- GdkColor *colors,
- gint ncolors,
- gboolean writeable,
- gboolean best_match,
- gboolean *success);
-gboolean gdk_colormap_alloc_color (GdkColormap *colormap,
- GdkColor *color,
- gboolean writeable,
- gboolean best_match);
-void gdk_colormap_free_colors (GdkColormap *colormap,
- GdkColor *colors,
- gint ncolors);
-
-GdkVisual *gdk_colormap_get_visual (GdkColormap *colormap);
-
-GdkColor *gdk_color_copy (GdkColor *color);
-void gdk_color_free (GdkColor *color);
-
-gint gdk_color_parse (const gchar *spec,
- GdkColor *color);
-guint gdk_color_hash (const GdkColor *colora);
-gint gdk_color_equal (const GdkColor *colora,
- const GdkColor *colorb);
+GdkColormap* gdk_colormap_new (GdkVisual *visual,
+ gint allocate);
+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);
+
+gint gdk_colormap_alloc_colors (GdkColormap *colormap,
+ GdkColor *colors,
+ gint ncolors,
+ gboolean writeable,
+ gboolean best_match,
+ gboolean *success);
+gboolean gdk_colormap_alloc_color (GdkColormap *colormap,
+ GdkColor *color,
+ gboolean writeable,
+ gboolean best_match);
+void gdk_colormap_free_colors (GdkColormap *colormap,
+ GdkColor *colors,
+ gint ncolors);
+
+GdkVisual* gdk_colormap_get_visual (GdkColormap *colormap);
+
+GdkColor* gdk_color_copy (GdkColor *color);
+void gdk_color_free (GdkColor *color);
+
+gboolean gdk_color_parse (const gchar *spec,
+ GdkColor *color);
+guint gdk_color_hash (const GdkColor *colora);
+gint gdk_color_equal (const GdkColor *colora,
+ const GdkColor *colorb);
/* The following functions are deprecated */
-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_alloc (GdkColormap *colormap,
- GdkColor *color);
-gint gdk_color_change (GdkColormap *colormap,
- GdkColor *color);
+void gdk_colors_store (GdkColormap *colormap,
+ GdkColor *colors,
+ gint ncolors);
+gboolean 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);
+gboolean gdk_color_white (GdkColormap *colormap,
+ GdkColor *color);
+gboolean gdk_color_black (GdkColormap *colormap,
+ GdkColor *color);
+gboolean gdk_color_alloc (GdkColormap *colormap,
+ GdkColor *color);
+gboolean gdk_color_change (GdkColormap *colormap,
+ GdkColor *color);
/* Fonts
diff --git a/gdk/gdkcc.c b/gdk/gdkcc.c
index 573b2efa15..d1d1e754f7 100644
--- a/gdk/gdkcc.c
+++ b/gdk/gdkcc.c
@@ -491,10 +491,11 @@ init_palette (GdkColorContext *cc)
if (cc->color_hash)
{
- /* XXX: quick-and-dirty way to remove everything */
-
+ g_hash_table_foreach (cc->color_hash,
+ free_hash_entry,
+ NULL);
g_hash_table_destroy (cc->color_hash);
- cc->color_hash = g_hash_table_new (hash_color, compare_colors);
+ cc->color_hash = NULL;
}
cc->palette = NULL;
@@ -618,11 +619,6 @@ gdk_color_context_new (GdkVisual *visual,
g_message ("gdk_color_context_new: screen depth is %i, no. of colors is %i\n",
cc->visual->depth, cc->num_colors));
- /* check if we need to initialize a hash table */
-
- if ((cc->mode == GDK_CC_MODE_STD_CMAP) || (cc->mode == GDK_CC_MODE_UNDEFINED))
- cc->color_hash = g_hash_table_new (hash_color, compare_colors);
-
return (GdkColorContext *) cc;
}
@@ -677,17 +673,9 @@ gdk_color_context_free (GdkColorContext *cc)
gdk_colormap_unref (cc->colormap);
/* free any palette that has been associated with this GdkColorContext */
-
+
init_palette (cc);
- if (cc->color_hash)
- {
- g_hash_table_foreach (cc->color_hash,
- free_hash_entry,
- NULL);
- g_hash_table_destroy (cc->color_hash);
- }
-
g_free (cc);
}
@@ -780,13 +768,14 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
default:
{
GdkColor color;
- GdkColor *result;
+ GdkColor *result = NULL;
color.red = red;
color.green = green;
color.blue = blue;
-
- result = g_hash_table_lookup (cc->color_hash, &color);
+
+ if (cc->color_hash)
+ result = g_hash_table_lookup (cc->color_hash, &color);
if (!result)
{
@@ -831,6 +820,9 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
cnew = g_new (GdkColor, 1);
*cnew = color;
+
+ if (!cc->color_hash)
+ cc->color_hash = g_hash_table_new (hash_color, compare_colors);
g_hash_table_insert (cc->color_hash, cnew, cnew);
cc->clut[cc->num_allocated] = color.pixel;
@@ -1489,20 +1481,7 @@ gdk_color_context_add_palette (GdkColorContext *cc,
/* restore previous mode if we aren't adding a new palette */
if (num_palette == 0)
- {
- /* GDK_CC_MODE_STD_CMAP uses a hash table, so we'd better initialize one */
-
- /* XXX: here, the hash table is already initialized */
-
- return 0;
- }
-
- /* Initialize a hash table for this palette (we need one for allocating
- * the pixels in the palette using the current settings)
- */
-
- if (cc->color_hash == NULL)
- cc->color_hash = g_hash_table_new (hash_color, compare_colors);
+ return 0;
/* copy incoming palette */
@@ -1549,6 +1528,9 @@ gdk_color_context_add_palette (GdkColorContext *cc,
if (cc->color_hash)
{
+ g_hash_table_foreach (cc->color_hash,
+ free_hash_entry,
+ NULL);
g_hash_table_destroy (cc->color_hash);
cc->color_hash = NULL;
}
diff --git a/gdk/gdkcolor.c b/gdk/gdkcolor.c
index bd48087543..2baa200ee0 100644
--- a/gdk/gdkcolor.c
+++ b/gdk/gdkcolor.c
@@ -70,13 +70,14 @@ gdk_colormap_new (GdkVisual *visual,
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
colormap->size = visual->colormap_size;
- colormap->colors = g_new (GdkColor, colormap->size);
+ colormap->colors = NULL;
switch (visual->type)
{
case GDK_VISUAL_GRAYSCALE:
case GDK_VISUAL_PSEUDO_COLOR:
private->info = g_new0 (GdkColorInfo, colormap->size);
+ colormap->colors = g_new (GdkColor, colormap->size);
private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
(GCompareFunc) gdk_color_equal);
@@ -116,6 +117,7 @@ gdk_colormap_new (GdkVisual *visual,
private->private_val = TRUE;
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
xvisual, AllocAll);
+ colormap->colors = g_new (GdkColor, colormap->size);
size = 1 << visual->red_prec;
for (i = 0; i < size; i++)
@@ -428,56 +430,7 @@ gdk_colors_alloc (GdkColormap *colormap,
}
}
- return return_val;
-}
-
-/* This is almost identical to gdk_colormap_free_colors.
- * Keep them in sync!
- */
-void
-gdk_colors_free (GdkColormap *colormap,
- gulong *in_pixels,
- gint in_npixels,
- gulong planes)
-{
- GdkColormapPrivate *private;
- gulong *pixels;
- gint npixels = 0;
- gint i;
-
- g_return_if_fail (colormap != NULL);
- g_return_if_fail (in_pixels != NULL);
-
- private = (GdkColormapPrivate*) colormap;
-
- if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
- (private->visual->type != GDK_VISUAL_GRAYSCALE))
- return;
-
- pixels = g_new (gulong, in_npixels);
-
- for (i=0; i<in_npixels; i++)
- {
- gulong pixel = in_pixels[i];
-
- if (private->info[pixel].ref_count)
- {
- private->info[pixel].ref_count--;
-
- if (private->info[pixel].ref_count == 0)
- {
- pixels[npixels++] = pixel;
- if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
- g_hash_table_remove (private->hash, &colormap->colors[in_pixels[i]]);
- private->info[pixel].flags = 0;
- }
- }
- }
-
- if (npixels)
- XFreeColors (private->xdisplay, private->xcolormap,
- pixels, npixels, planes);
- g_free (pixels);
+ return return_val != 0;
}
/*
@@ -536,7 +489,7 @@ gdk_color_free (GdkColor *color)
g_mem_chunk_free (color_chunk, color);
}
-gint
+gboolean
gdk_color_white (GdkColormap *colormap,
GdkColor *color)
{
@@ -559,7 +512,7 @@ gdk_color_white (GdkColormap *colormap,
return return_val;
}
-gint
+gboolean
gdk_color_black (GdkColormap *colormap,
GdkColor *color)
{
@@ -608,6 +561,104 @@ gdk_color_parse (const gchar *spec,
return return_val;
}
+/* This is almost identical to gdk_colormap_free_colors.
+ * Keep them in sync!
+ */
+void
+gdk_colors_free (GdkColormap *colormap,
+ gulong *in_pixels,
+ gint in_npixels,
+ gulong planes)
+{
+ GdkColormapPrivate *private;
+ gulong *pixels;
+ gint npixels = 0;
+ gint i;
+
+ g_return_if_fail (colormap != NULL);
+ g_return_if_fail (in_pixels != NULL);
+
+ private = (GdkColormapPrivate*) colormap;
+
+ if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
+ (private->visual->type != GDK_VISUAL_GRAYSCALE))
+ return;
+
+ pixels = g_new (gulong, in_npixels);
+
+ for (i=0; i<in_npixels; i++)
+ {
+ gulong pixel = in_pixels[i];
+
+ if (private->info[pixel].ref_count)
+ {
+ private->info[pixel].ref_count--;
+
+ if (private->info[pixel].ref_count == 0)
+ {
+ pixels[npixels++] = pixel;
+ if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
+ g_hash_table_remove (private->hash, &colormap->colors[pixel]);
+ private->info[pixel].flags = 0;
+ }
+ }
+ }
+
+ if (npixels)
+ XFreeColors (private->xdisplay, private->xcolormap,
+ pixels, npixels, planes);
+ g_free (pixels);
+}
+
+/* This is almost identical to gdk_colors_free.
+ * Keep them in sync!
+ */
+void
+gdk_colormap_free_colors (GdkColormap *colormap,
+ GdkColor *colors,
+ gint ncolors)
+{
+ GdkColormapPrivate *private;
+ gulong *pixels;
+ gint npixels = 0;
+ gint i;
+
+ g_return_if_fail (colormap != NULL);
+ g_return_if_fail (colors != NULL);
+
+ private = (GdkColormapPrivate*) colormap;
+
+ if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
+ (private->visual->type != GDK_VISUAL_GRAYSCALE))
+ return;
+
+ pixels = g_new (gulong, ncolors);
+
+ for (i=0; i<ncolors; i++)
+ {
+ gulong pixel = colors[i].pixel;
+
+ if (private->info[pixel].ref_count)
+ {
+ private->info[pixel].ref_count--;
+
+ if (private->info[pixel].ref_count == 0)
+ {
+ pixels[npixels++] = pixel;
+ if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
+ g_hash_table_remove (private->hash, &colormap->colors[pixel]);
+ private->info[pixel].flags = 0;
+ }
+ }
+ }
+
+ if (npixels)
+ XFreeColors (private->xdisplay, private->xcolormap,
+ pixels, npixels, 0);
+
+ g_free (pixels);
+}
+
/********************
* Color allocation *
********************/
@@ -648,6 +699,7 @@ gdk_colormap_alloc1 (GdkColormap *colormap,
else
{
colormap->colors[ret->pixel] = *color;
+ colormap->colors[ret->pixel].pixel = ret->pixel;
private->info[ret->pixel].ref_count = 1;
g_hash_table_insert (private->hash,
@@ -1025,55 +1077,6 @@ gdk_colormap_alloc_color (GdkColormap *colormap,
return success;
}
-/* This is almost identical to gdk_colors_free.
- * Keep them in sync!
- */
-void
-gdk_colormap_free_colors (GdkColormap *colormap,
- GdkColor *colors,
- gint ncolors)
-{
- GdkColormapPrivate *private;
- gulong *pixels;
- gint npixels = 0;
- gint i;
-
- g_return_if_fail (colormap != NULL);
- g_return_if_fail (colors != NULL);
-
- private = (GdkColormapPrivate*) colormap;
-
- if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
- (private->visual->type != GDK_VISUAL_GRAYSCALE))
- return;
-
- pixels = g_new (gulong, ncolors);
-
- for (i=0; i<ncolors; i++)
- {
- gulong pixel = colors[i].pixel;
-
- if (private->info[pixel].ref_count)
- {
- private->info[pixel].ref_count--;
-
- if (private->info[pixel].ref_count == 0)
- {
- pixels[npixels++] = pixel;
- if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
- g_hash_table_remove (private->hash, &colors[i]);
- private->info[pixel].flags = 0;
- }
- }
- }
-
- if (npixels)
- XFreeColors (private->xdisplay, private->xcolormap,
- pixels, npixels, 0);
-
- g_free (pixels);
-}
-
gboolean
gdk_color_alloc (GdkColormap *colormap,
GdkColor *color)
diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c
index 3b8f05d8fd..a2be5e160c 100644
--- a/gdk/gdkdnd.c
+++ b/gdk/gdkdnd.c
@@ -31,8 +31,6 @@
#include "gdk/gdkprivate.h"
#include "gdk.h"
-#define NEW_DRAGS
-
typedef struct _GdkDragContextPrivate GdkDragContextPrivate;
typedef enum {
@@ -70,7 +68,8 @@ struct _GdkDragContextPrivate {
GdkDragAction old_actions; /* The last actions we sent to the source */
GdkDragAction xdnd_actions; /* What is currently set in XdndActionList */
- Window dest_xid;
+ Window dest_xid; /* The last window we looked up */
+ Window drop_xid; /* The (non-proxied) window that is receiving drops */
guint xdnd_targets_set : 1; /* Whether we've already set XdndTypeList */
guint xdnd_actions_set : 1; /* Whether we've already set XdndActionList */
guint xdnd_have_actions : 1; /* Whether an XdndActionList was provided */
@@ -151,6 +150,7 @@ gdk_drag_context_unref (GdkDragContext *context)
GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
g_return_if_fail (context != NULL);
+ g_return_if_fail (private->ref_count > 0);
private->ref_count--;
@@ -196,8 +196,8 @@ gdk_drag_context_find (gboolean is_source,
private = (GdkDragContextPrivate *)context;
context_dest_xid = context->dest_window ?
- (private->dest_xid ?
- private->dest_xid :
+ (private->drop_xid ?
+ private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window)) :
None;
@@ -387,7 +387,7 @@ gdk_window_cache_new (void)
xwa.x, xwa.y, xwa.width, xwa.height,
xwa.map_state != IsUnmapped);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
gdk_error_code = 0;
else
{
@@ -441,9 +441,10 @@ get_client_window_at_coords_recurse (Window win,
wm_state_atom, 0, 0, False, AnyPropertyType,
&type, &format, &nitems, &after, &data);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
{
gdk_error_code = 0;
+
return None;
}
@@ -458,9 +459,10 @@ get_client_window_at_coords_recurse (Window win,
XTranslateCoordinates (gdk_display, gdk_root_window, win,
x_root, y_root, &dest_x, &dest_y, &child);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
{
gdk_error_code = 0;
+
return None;
}
@@ -469,7 +471,7 @@ get_client_window_at_coords_recurse (Window win,
&root, &tmp_parent, &children, &nchildren) == 0)
return 0;
- if (gdk_error_code == 0)
+ if (!gdk_error_code)
{
for (i = nchildren - 1; (i >= 0) && (child == None); i--)
{
@@ -477,7 +479,7 @@ get_client_window_at_coords_recurse (Window win,
XGetWindowAttributes (gdk_display, children[i], &xwa);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
gdk_error_code = 0;
else if ((xwa.map_state == IsViewable) && (xwa.class == InputOutput) &&
(x >= xwa.x) && (x < xwa.x + (gint)xwa.width) &&
@@ -566,9 +568,10 @@ get_client_window_at_coords_recurse (Window win,
wm_state_atom, 0, 0, False, AnyPropertyType,
&type, &format, &nitems, &after, &data);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
{
gdk_error_code = 0;
+
return None;
}
@@ -581,9 +584,10 @@ get_client_window_at_coords_recurse (Window win,
XTranslateCoordinates (gdk_display, gdk_root_window, win,
x_root, y_root, &dest_x, &dest_y, &child);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
{
gdk_error_code = 0;
+
return None;
}
@@ -620,7 +624,7 @@ get_client_window_at_coords (Window ignore,
XGetWindowAttributes (gdk_display, children[i], &xwa);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
gdk_error_code = 0;
else if ((xwa.map_state == IsViewable) &&
(x_root >= xwa.x) && (x_root < xwa.x + (gint)xwa.width) &&
@@ -869,7 +873,7 @@ motif_find_drag_window (gboolean create)
Display *display;
XSetWindowAttributes attr;
- display = XOpenDisplay (NULL);
+ display = XOpenDisplay (gdk_display_name);
XSetCloseDownMode (display, RetainPermanent);
XGrabServer (display);
@@ -2027,6 +2031,8 @@ xdnd_set_targets (GdkDragContext *context)
XA_ATOM, 32, PropModeReplace,
(guchar *)atomlist, n_atoms);
+ g_free (atomlist);
+
private->xdnd_targets_set = 1;
}
@@ -2073,6 +2079,8 @@ xdnd_set_actions (GdkDragContext *context)
XA_ATOM, 32, PropModeReplace,
(guchar *)atomlist, n_atoms);
+ g_free (atomlist);
+
private->xdnd_actions_set = 1;
private->xdnd_actions = context->actions;
}
@@ -2106,13 +2114,9 @@ xdnd_send_enter (GdkDragContext *context)
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("XdndEnter", FALSE);
xev.xclient.format = 32;
-#ifdef NEW_DRAGS
- xev.xclient.window = private->dest_xid ?
- private->dest_xid :
+ xev.xclient.window = private->drop_xid ?
+ private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window);
-#else
- xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
-#endif
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
xev.xclient.data.l[1] = (3 << 24); /* version */
xev.xclient.data.l[2] = 0;
@@ -2162,13 +2166,9 @@ xdnd_send_leave (GdkDragContext *context)
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("XdndLeave", FALSE);
xev.xclient.format = 32;
-#ifdef NEW_DRAGS
- xev.xclient.window = private->dest_xid ?
- private->dest_xid :
+ xev.xclient.window = private->drop_xid ?
+ private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window);
-#else
- xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
-#endif
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = 0;
@@ -2195,13 +2195,9 @@ xdnd_send_drop (GdkDragContext *context, guint32 time)
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("XdndDrop", FALSE);
xev.xclient.format = 32;
-#ifdef NEW_DRAGS
- xev.xclient.window = private->dest_xid ?
- private->dest_xid :
+ xev.xclient.window = private->drop_xid ?
+ private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window);
-#else
- xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
-#endif
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = time;
@@ -2232,13 +2228,9 @@ xdnd_send_motion (GdkDragContext *context,
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("XdndPosition", FALSE);
xev.xclient.format = 32;
-#ifdef NEW_DRAGS
- xev.xclient.window = private->dest_xid ?
- private->dest_xid :
+ xev.xclient.window = private->drop_xid ?
+ private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window);
-#else
- xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
-#endif
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = (x_root << 16) | y_root;
@@ -2859,6 +2851,12 @@ gdk_drag_find_window (GdkDragContext *context,
/* Check if new destination accepts drags, and which protocol */
+ /* There is some ugliness here. We actually need to pass
+ * _three_ pieces of information to drag_motion - dest_window,
+ * protocol, and the XID of the unproxied window. The first
+ * two are passed explicitely, the third implicitly through
+ * protocol->dest_xid.
+ */
if ((recipient = gdk_drag_get_protocol (dest, protocol)))
{
*dest_window = gdk_window_lookup (recipient);
@@ -2917,6 +2915,7 @@ gdk_drag_motion (GdkDragContext *context,
if (dest_window)
{
context->dest_window = dest_window;
+ private->drop_xid = private->dest_xid;
gdk_window_ref (context->dest_window);
context->protocol = protocol;
@@ -2941,6 +2940,7 @@ gdk_drag_motion (GdkDragContext *context,
else
{
context->dest_window = NULL;
+ private->drop_xid = None;
context->action = 0;
}
diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c
index cb4f96e78c..8ae417e4aa 100644
--- a/gdk/gdkdraw.c
+++ b/gdk/gdkdraw.c
@@ -501,12 +501,14 @@ gdk_draw_lines (GdkDrawable *drawable,
g_return_if_fail (gc != NULL);
drawable_private = (GdkWindowPrivate*) drawable;
+ if (drawable_private->destroyed)
+ return;
gc_private = (GdkGCPrivate*) gc;
XDrawLines (drawable_private->xdisplay,
- drawable_private->xwindow,
- gc_private->xgc,
- (XPoint *) points,
- npoints,
- CoordModeOrigin);
+ drawable_private->xwindow,
+ gc_private->xgc,
+ (XPoint *) points,
+ npoints,
+ CoordModeOrigin);
}
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 159e0ee9e5..4f6f577f29 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -27,7 +27,6 @@
#include "gdk.h"
#include "gdkx.h"
#include "gdkprivate.h"
-#include "gdkinput.h"
#include "gdkkeysyms.h"
#if HAVE_CONFIG_H
@@ -37,6 +36,7 @@
# endif
#endif
+#include "gdkinput.h"
typedef struct _GdkIOClosure GdkIOClosure;
typedef struct _GdkEventPrivate GdkEventPrivate;
@@ -88,9 +88,11 @@ static GdkEvent* gdk_event_unqueue (void);
static gboolean gdk_event_prepare (gpointer source_data,
GTimeVal *current_time,
- gint *timeout);
+ gint *timeout,
+ gpointer user_data);
static gboolean gdk_event_check (gpointer source_data,
- GTimeVal *current_time);
+ GTimeVal *current_time,
+ gpointer user_data);
static gboolean gdk_event_dispatch (gpointer source_data,
GTimeVal *current_time,
gpointer user_data);
@@ -434,6 +436,10 @@ gdk_compress_exposures (XEvent *xevent,
rect1.width = xevent->xexpose.width;
rect1.height = xevent->xexpose.height;
+ event.any.type = GDK_EXPOSE;
+ event.any.window = None;
+ event.any.send_event = FALSE;
+
while (1)
{
if (count == 0)
@@ -449,6 +455,8 @@ gdk_compress_exposures (XEvent *xevent,
&tmp_event,
expose_predicate,
(XPointer)&info);
+
+ event.any.window = window;
/* We apply filters here, and if it was filtered, completely
* ignore the return
@@ -849,6 +857,12 @@ gdk_io_destroy (gpointer data)
g_free (closure);
}
+/* What do we do with G_IO_NVAL?
+ */
+#define READ_CONDITION (G_IO_IN | G_IO_HUP | G_IO_ERR)
+#define WRITE_CONDITION (G_IO_OUT | G_IO_ERR)
+#define EXCEPTION_CONDITION (G_IO_PRI)
+
static gboolean
gdk_io_invoke (GIOChannel *source,
GIOCondition condition,
@@ -857,11 +871,11 @@ gdk_io_invoke (GIOChannel *source,
GdkIOClosure *closure = data;
GdkInputCondition gdk_cond = 0;
- if (condition & (G_IO_IN | G_IO_PRI))
+ if (condition & READ_CONDITION)
gdk_cond |= GDK_INPUT_READ;
- if (condition & G_IO_OUT)
+ if (condition & WRITE_CONDITION)
gdk_cond |= GDK_INPUT_WRITE;
- if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
+ if (condition & EXCEPTION_CONDITION)
gdk_cond |= GDK_INPUT_EXCEPTION;
if (closure->condition & gdk_cond)
@@ -888,11 +902,11 @@ gdk_input_add_full (gint source,
closure->data = data;
if (condition & GDK_INPUT_READ)
- cond |= (G_IO_IN | G_IO_PRI);
+ cond |= READ_CONDITION;
if (condition & GDK_INPUT_WRITE)
- cond |= G_IO_OUT;
+ cond |= WRITE_CONDITION;
if (condition & GDK_INPUT_EXCEPTION)
- cond |= G_IO_ERR|G_IO_HUP|G_IO_NVAL;
+ cond |= EXCEPTION_CONDITION;
channel = g_io_channel_unix_new (source);
result = g_io_add_watch_full (channel, G_PRIORITY_DEFAULT, cond,
@@ -923,7 +937,6 @@ gdk_event_apply_filters (XEvent *xevent,
GdkEvent *event,
GList *filters)
{
- GdkEventFilter *filter;
GList *tmp_list;
GdkFilterReturn result;
@@ -931,13 +944,12 @@ gdk_event_apply_filters (XEvent *xevent,
while (tmp_list)
{
- filter = (GdkEventFilter*) tmp_list->data;
+ GdkEventFilter *filter = (GdkEventFilter*) tmp_list->data;
- result = (*filter->function) (xevent, event, filter->data);
+ tmp_list = tmp_list->next;
+ result = filter->function (xevent, event, filter->data);
if (result != GDK_FILTER_CONTINUE)
return result;
-
- tmp_list = tmp_list->next;
}
return GDK_FILTER_CONTINUE;
@@ -1002,7 +1014,7 @@ gdk_event_translate (GdkEvent *event,
gdk_window_ref (window);
event->any.window = window;
- event->any.send_event = xevent->xany.send_event;
+ event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
if (window_private && window_private->destroyed)
{
@@ -1057,9 +1069,6 @@ gdk_event_translate (GdkEvent *event,
}
#endif
- if (window == NULL)
- g_message ("Got event for unknown window: %#lx\n", xevent->xany.window);
-
/* We do a "manual" conversion of the XEvent to a
* GdkEvent. The structures are mostly the same so
* the conversion is fairly straightforward. We also
@@ -1513,10 +1522,11 @@ gdk_event_translate (GdkEvent *event,
/* Print debugging info.
*/
GDK_NOTE (EVENTS,
- g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d",
+ g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d%s",
xevent->xexpose.window, xevent->xexpose.count,
xevent->xexpose.x, xevent->xexpose.y,
- xevent->xexpose.width, xevent->xexpose.height));
+ xevent->xexpose.width, xevent->xexpose.height,
+ event->any.send_event ? " (send)" : ""));
gdk_compress_exposures (xevent, window);
event->expose.type = GDK_EXPOSE;
@@ -1601,7 +1611,17 @@ gdk_event_translate (GdkEvent *event,
break;
case CreateNotify:
- /* Not currently handled */
+ GDK_NOTE (EVENTS,
+ g_message ("create notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d parent: %ld ovr: %d",
+ xevent->xcreatewindow.window,
+ xevent->xcreatewindow.x,
+ xevent->xcreatewindow.y,
+ xevent->xcreatewindow.width,
+ xevent->xcreatewindow.height,
+ xevent->xcreatewindow.border_width,
+ xevent->xcreatewindow.parent,
+ xevent->xcreatewindow.override_redirect));
+ /* not really handled */
break;
case DestroyNotify:
@@ -1616,7 +1636,7 @@ gdk_event_translate (GdkEvent *event,
return_val = window_private && !window_private->destroyed;
- if(window && window_private->xwindow != GDK_ROOT_WINDOW())
+ if (window && window_private->xwindow != GDK_ROOT_WINDOW())
gdk_window_destroy_notify (window);
break;
@@ -1651,8 +1671,12 @@ gdk_event_translate (GdkEvent *event,
/* Print debugging info.
*/
GDK_NOTE (EVENTS,
- g_message ("reparent notify:\twindow: %ld",
- xevent->xreparent.window));
+ g_message ("reparent notify:\twindow: %ld x,y: %d %d parent: %ld ovr: %d",
+ xevent->xreparent.window,
+ xevent->xreparent.x,
+ xevent->xreparent.y,
+ xevent->xreparent.parent,
+ xevent->xreparent.override_redirect));
/* Not currently handled */
return_val = FALSE;
@@ -1661,36 +1685,8 @@ gdk_event_translate (GdkEvent *event,
case ConfigureNotify:
/* Print debugging info.
*/
- while ((XPending (gdk_display) > 0) &&
- XCheckTypedWindowEvent(gdk_display, xevent->xany.window,
- ConfigureNotify, xevent))
- {
- GdkFilterReturn result;
-
- GDK_NOTE (EVENTS,
- g_message ("configure notify discarded:\twindow: %ld",
- xevent->xconfigure.window));
-
- result = gdk_event_apply_filters (xevent, event,
- window_private
- ?window_private->filters
- :gdk_default_filters);
-
- /* If the result is GDK_FILTER_REMOVE, there will be
- * trouble, but anybody who filtering the Configure events
- * better know what they are doing
- */
- if (result != GDK_FILTER_CONTINUE)
- {
- return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
- }
-
- /*XSync (gdk_display, 0);*/
- }
-
-
GDK_NOTE (EVENTS,
- g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d",
+ g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d%s",
xevent->xconfigure.window,
xevent->xconfigure.x,
xevent->xconfigure.y,
@@ -1698,14 +1694,19 @@ gdk_event_translate (GdkEvent *event,
xevent->xconfigure.height,
xevent->xconfigure.border_width,
xevent->xconfigure.above,
- xevent->xconfigure.override_redirect));
-
- if (!window_private->destroyed &&
+ xevent->xconfigure.override_redirect,
+ !window
+ ? " (discarding)"
+ : window_private->window_type == GDK_WINDOW_CHILD
+ ? " (discarding child)"
+ : ""));
+ if (window &&
+ !window_private->destroyed &&
(window_private->extension_events != 0) &&
gdk_input_vtable.configure_event)
gdk_input_vtable.configure_event (&xevent->xconfigure, window);
- if (window_private->window_type == GDK_WINDOW_CHILD)
+ if (!window || window_private->window_type == GDK_WINDOW_CHILD)
return_val = FALSE;
else
{
@@ -1721,17 +1722,23 @@ gdk_event_translate (GdkEvent *event,
gint tx = 0;
gint ty = 0;
Window child_window = 0;
-
- if (!XTranslateCoordinates (window_private->xdisplay,
- window_private->xwindow,
- gdk_root_window,
- 0, 0,
- &tx, &ty,
- &child_window))
- g_warning ("GdkWindow %ld doesn't share root windows display?",
- window_private->xwindow);
- event->configure.x = tx;
- event->configure.y = ty;
+
+ gdk_error_trap_push ();
+ if (XTranslateCoordinates (window_private->xdisplay,
+ window_private->xwindow,
+ gdk_root_window,
+ 0, 0,
+ &tx, &ty,
+ &child_window))
+ {
+ if (!gdk_error_trap_pop ())
+ {
+ event->configure.x = tx;
+ event->configure.y = ty;
+ }
+ }
+ else
+ gdk_error_trap_pop ();
}
else
{
@@ -1751,8 +1758,15 @@ gdk_event_translate (GdkEvent *event,
/* Print debugging info.
*/
GDK_NOTE (EVENTS,
- g_message ("property notify:\twindow: %ld",
- xevent->xproperty.window));
+ gchar *atom = gdk_atom_name (xevent->xproperty.atom);
+ g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s",
+ xevent->xproperty.window,
+ xevent->xproperty.atom,
+ atom ? "\"" : "",
+ atom ? atom : "unknown",
+ atom ? "\"" : "");
+ g_free (atom);
+ );
event->property.type = GDK_PROPERTY_NOTIFY;
event->property.window = window;
@@ -1910,8 +1924,8 @@ gdk_event_translate (GdkEvent *event,
GdkFilterReturn
gdk_wm_protocols_filter (GdkXEvent *xev,
- GdkEvent *event,
- gpointer data)
+ GdkEvent *event,
+ gpointer data)
{
XEvent *xevent = (XEvent *)xev;
@@ -1993,8 +2007,7 @@ gdk_events_queue (void)
event->any.type = GDK_NOTHING;
event->any.window = NULL;
- event->any.send_event = FALSE;
- event->any.send_event = xevent.xany.send_event;
+ event->any.send_event = xevent.xany.send_event ? TRUE : FALSE;
((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
@@ -2017,7 +2030,8 @@ gdk_events_queue (void)
static gboolean
gdk_event_prepare (gpointer source_data,
GTimeVal *current_time,
- gint *timeout)
+ gint *timeout,
+ gpointer user_data)
{
gboolean retval;
@@ -2034,7 +2048,8 @@ gdk_event_prepare (gpointer source_data,
static gboolean
gdk_event_check (gpointer source_data,
- GTimeVal *current_time)
+ GTimeVal *current_time,
+ gpointer user_data)
{
gboolean retval;
@@ -2133,29 +2148,29 @@ gdk_event_send_client_message_to_all_recurse (XEvent *xev,
guint level)
{
static GdkAtom wm_state_atom = GDK_NONE;
-
Atom type = None;
int format;
unsigned long nitems, after;
unsigned char *data;
-
Window *ret_children, ret_root, ret_parent;
unsigned int ret_nchildren;
- int i;
-
+ gint old_warnings = gdk_error_warnings;
gboolean send = FALSE;
gboolean found = FALSE;
+ int i;
if (!wm_state_atom)
wm_state_atom = gdk_atom_intern ("WM_STATE", FALSE);
+ gdk_error_warnings = FALSE;
gdk_error_code = 0;
XGetWindowProperty (gdk_display, xid, wm_state_atom, 0, 0, False, AnyPropertyType,
&type, &format, &nitems, &after, &data);
if (gdk_error_code)
{
- gdk_error_code = 0;
+ gdk_error_warnings = old_warnings;
+
return FALSE;
}
@@ -2167,18 +2182,20 @@ gdk_event_send_client_message_to_all_recurse (XEvent *xev,
else
{
/* OK, we're all set, now let's find some windows to send this to */
- if (XQueryTree(gdk_display, xid, &ret_root, &ret_parent,
- &ret_children, &ret_nchildren) != True)
- return FALSE;
-
- if (gdk_error_code)
- return FALSE;
+ if (XQueryTree (gdk_display, xid, &ret_root, &ret_parent,
+ &ret_children, &ret_nchildren) != True ||
+ gdk_error_code)
+ {
+ gdk_error_warnings = old_warnings;
+
+ return FALSE;
+ }
for(i = 0; i < ret_nchildren; i++)
- if (gdk_event_send_client_message_to_all_recurse(xev, ret_children[i], level + 1))
+ if (gdk_event_send_client_message_to_all_recurse (xev, ret_children[i], level + 1))
found = TRUE;
- XFree(ret_children);
+ XFree (ret_children);
}
if (send || (!found && (level == 1)))
@@ -2187,6 +2204,8 @@ gdk_event_send_client_message_to_all_recurse (XEvent *xev,
gdk_send_xevent (xid, False, NoEventMask, xev);
}
+ gdk_error_warnings = old_warnings;
+
return (send || found);
}
diff --git a/gdk/gdkfont.c b/gdk/gdkfont.c
index d1f779a064..096cf8a537 100644
--- a/gdk/gdkfont.c
+++ b/gdk/gdkfont.c
@@ -29,6 +29,63 @@
#include "gdk.h"
#include "gdkprivate.h"
+static GHashTable *font_name_hash = NULL;
+static GHashTable *fontset_name_hash = NULL;
+
+static void
+gdk_font_hash_insert (GdkFontType type, GdkFont *font, const gchar *font_name)
+{
+ GdkFontPrivate *private = (GdkFontPrivate *)font;
+ GHashTable **hashp = (type == GDK_FONT_FONT) ?
+ &font_name_hash : &fontset_name_hash;
+
+ if (!*hashp)
+ *hashp = g_hash_table_new (g_str_hash, g_str_equal);
+
+ private->names = g_slist_prepend (private->names, g_strdup (font_name));
+ g_hash_table_insert (*hashp, private->names->data, font);
+}
+
+static void
+gdk_font_hash_remove (GdkFontType type, GdkFont *font)
+{
+ GdkFontPrivate *private = (GdkFontPrivate *)font;
+ GSList *tmp_list;
+ GHashTable *hash = (type == GDK_FONT_FONT) ?
+ font_name_hash : fontset_name_hash;
+
+ tmp_list = private->names;
+ while (tmp_list)
+ {
+ g_hash_table_remove (hash, tmp_list->data);
+ g_free (tmp_list->data);
+
+ tmp_list = tmp_list->next;
+ }
+
+ g_slist_free (private->names);
+ private->names = NULL;
+}
+
+static GdkFont *
+gdk_font_hash_lookup (GdkFontType type, const gchar *font_name)
+{
+ GdkFont *result;
+ GHashTable *hash = (type == GDK_FONT_FONT) ?
+ font_name_hash : fontset_name_hash;
+
+ if (!hash)
+ return NULL;
+ else
+ {
+ result = g_hash_table_lookup (hash, font_name);
+ if (result)
+ gdk_font_ref (result);
+
+ return result;
+ }
+}
+
GdkFont*
gdk_font_load (const gchar *font_name)
{
@@ -38,6 +95,10 @@ gdk_font_load (const gchar *font_name)
g_return_val_if_fail (font_name != NULL, NULL);
+ font = gdk_font_hash_lookup (GDK_FONT_FONT, font_name);
+ if (font)
+ return font;
+
xfont = XLoadQueryFont (gdk_display, font_name);
if (xfont == NULL)
return NULL;
@@ -57,7 +118,8 @@ gdk_font_load (const gchar *font_name)
private->xdisplay = gdk_display;
private->xfont = xfont;
private->ref_count = 1;
-
+ private->names = NULL;
+
font = (GdkFont*) private;
font->type = GDK_FONT_FONT;
font->ascent = xfont->ascent;
@@ -66,6 +128,8 @@ gdk_font_load (const gchar *font_name)
gdk_xid_table_insert (&xfont->fid, font);
}
+ gdk_font_hash_insert (GDK_FONT_FONT, font, font_name);
+
return font;
}
@@ -79,6 +143,10 @@ gdk_fontset_load (gchar *fontset_name)
gchar **missing_charset_list;
gchar *def_string;
+ font = gdk_font_hash_lookup (GDK_FONT_FONTSET, fontset_name);
+ if (font)
+ return font;
+
private = g_new (GdkFontPrivate, 1);
font = (GdkFont*) private;
@@ -121,8 +189,12 @@ gdk_fontset_load (gchar *fontset_name)
font->ascent = MAX (font->ascent, font_structs[i]->ascent);
font->descent = MAX (font->descent, font_structs[i]->descent);
}
+
+ private->names = NULL;
+ gdk_font_hash_insert (GDK_FONT_FONTSET, font, fontset_name);
+
+ return font;
}
- return font;
}
GdkFont*
@@ -141,14 +213,16 @@ void
gdk_font_unref (GdkFont *font)
{
GdkFontPrivate *private;
+ private = (GdkFontPrivate*) font;
g_return_if_fail (font != NULL);
-
- private = (GdkFontPrivate*) font;
+ g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)
{
+ gdk_font_hash_remove (font->type, font);
+
switch (font->type)
{
case GDK_FONT_FONT:
@@ -205,8 +279,12 @@ gdk_font_equal (const GdkFont *fonta,
}
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));
+ gchar *namea, *nameb;
+
+ namea = XBaseFontNameListOfFontSet((XFontSet) privatea->xfont);
+ nameb = XBaseFontNameListOfFontSet((XFontSet) privateb->xfont);
+
+ return (strcmp(namea, nameb) == 0);
}
else
/* fontset != font */
@@ -578,7 +656,20 @@ gdk_text_extents_wc (GdkFont *font,
}
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
- XwcTextExtents (fontset, text, text_length, &ink, &logical);
+
+ if (sizeof(GdkWChar) == sizeof(wchar_t))
+ XwcTextExtents (fontset, (wchar_t *)text, text_length, &ink, &logical);
+ else
+ {
+ wchar_t *text_wchar;
+ gint i;
+
+ text_wchar = g_new (wchar_t, text_length);
+ for (i = 0; i < text_length; i++)
+ text_wchar[i] = text[i];
+ XwcTextExtents (fontset, text_wchar, text_length, &ink, &logical);
+ g_free (text_wchar);
+ }
if (lbearing)
*lbearing = ink.x;
if (rbearing)
@@ -652,7 +743,7 @@ gdk_text_measure (GdkFont *font,
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
XmbTextExtents (fontset, text, text_length, &ink, &log);
- width = log.width;
+ width = ink.x + ink.width;
break;
default:
width = 0;
diff --git a/gdk/gdkgc.c b/gdk/gdkgc.c
index 470c358675..8b6e4fd0ed 100644
--- a/gdk/gdkgc.c
+++ b/gdk/gdkgc.c
@@ -286,6 +286,7 @@ gdk_gc_unref (GdkGC *gc)
GdkGCPrivate *private = (GdkGCPrivate*) gc;
g_return_if_fail (gc != NULL);
+ g_return_if_fail (private->ref_count > 0);
if (private->ref_count > 1)
private->ref_count -= 1;
diff --git a/gdk/gdkglobals.c b/gdk/gdkglobals.c
index 7a9307b2af..ae6c066f96 100644
--- a/gdk/gdkglobals.c
+++ b/gdk/gdkglobals.c
@@ -57,7 +57,7 @@ GdkDndGlobals gdk_dnd = {None,None,None,
{0,0}, {0,0},
{0,0,0,0}, NULL, None, 0};
gchar *gdk_progclass = NULL;
-gint gdk_error_code;
+gint gdk_error_code = 0;
gint gdk_error_warnings = TRUE;
gint gdk_null_window_warnings = TRUE;
GList *gdk_default_filters = NULL;
diff --git a/gdk/gdkim.c b/gdk/gdkim.c
index c06afc0577..e453925093 100644
--- a/gdk/gdkim.c
+++ b/gdk/gdkim.c
@@ -386,7 +386,7 @@ gdk_im_real_open (void)
destroy_cb.callback = gdk_im_destroy_cb;
destroy_cb.client_data = NULL;
- if (NULL != XSetIMValues (xim_im, XNDestroyCallback, &destroy_cb, NULL))
+ if (NULL != (void *) XSetIMValues (xim_im, XNDestroyCallback, &destroy_cb, NULL))
GDK_NOTE (XIM, g_warning ("Could not set destroy callback to IM. Be careful to not destroy your input method."));
#endif
@@ -469,7 +469,7 @@ gdk_ic_real_new (GdkIC *ic)
mask |= GDK_IC_PREEDIT_AREA_REQ;
preedit_area.x = attr->preedit_area.x;
- preedit_area.y = attr->preedit_area.x;
+ preedit_area.y = attr->preedit_area.y;
preedit_area.width = attr->preedit_area.width;
preedit_area.height = attr->preedit_area.height;
@@ -484,7 +484,7 @@ gdk_ic_real_new (GdkIC *ic)
mask |= GDK_IC_PREEDIT_POSITION_REQ;
preedit_area.x = attr->preedit_area.x;
- preedit_area.y = attr->preedit_area.x;
+ preedit_area.y = attr->preedit_area.y;
preedit_area.width = attr->preedit_area.width;
preedit_area.height = attr->preedit_area.height;
@@ -506,7 +506,7 @@ gdk_ic_real_new (GdkIC *ic)
mask |= GDK_IC_STATUS_AREA_REQ;
status_area.x = attr->status_area.x;
- status_area.y = attr->status_area.x;
+ status_area.y = attr->status_area.y;
status_area.width = attr->status_area.width;
status_area.height = attr->status_area.height;
@@ -518,6 +518,12 @@ gdk_ic_real_new (GdkIC *ic)
break;
}
+ /* We have to ensure that the client window is actually created on
+ * the X server, or XCreateIC fails because the XIM server can't get
+ * information about the client window.
+ */
+ gdk_flush();
+
if (preedit_attr != NULL && status_attr != NULL)
private->xic = XCreateIC (xim_im,
XNInputStyle,
@@ -871,7 +877,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNFontSet;
arg->value = (gpointer) GDK_FONT_XFONT(attr->status_fontset);
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_FONTSET;
}
@@ -887,7 +893,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNArea;
arg->value = (gpointer) &rect;
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_AREA;
}
@@ -903,7 +909,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNArea;
arg->value = (gpointer) &rect;
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_AREA_NEEDED;
else
private->mask &= ~GDK_IC_STATUS_AREA_NEEDED;
@@ -914,7 +920,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNForeground;
arg->value = (gpointer) attr->status_foreground.pixel;
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_FOREGROUND;
}
@@ -923,7 +929,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNBackground;
arg->value = (gpointer) attr->status_background.pixel;
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_BACKGROUND;
}
@@ -932,7 +938,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNBackgroundPixmap;
arg->value = (gpointer) GDK_WINDOW_XWINDOW(attr->status_pixmap);
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_PIXMAP;
}
@@ -941,7 +947,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNColormap;
arg->value = (gpointer) GDK_COLORMAP_XCOLORMAP(attr->status_colormap);
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_COLORMAP;
}
@@ -1565,8 +1571,10 @@ gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
!= Success)
{
/* InvalidChar */
+ XFree(tpr.value);
return -1;
}
+ XFree(tpr.value);
if (num_wstrs == 0)
return 0;
wstr_src = wstrs[0];
diff --git a/gdk/gdkimage.c b/gdk/gdkimage.c
index d2e66803d1..7dae0d92ee 100644
--- a/gdk/gdkimage.c
+++ b/gdk/gdkimage.c
@@ -251,14 +251,12 @@ gdk_image_new (GdkImageType type,
return NULL;
}
- gdk_error_code = 0;
- gdk_error_warnings = 0;
+ gdk_error_trap_push ();
XShmAttach (private->xdisplay, x_shm_info);
XSync (private->xdisplay, False);
- gdk_error_warnings = 1;
- if (gdk_error_code == -1)
+ if (gdk_error_trap_pop ())
{
/* this is the common failure case so omit warning */
XDestroyImage (private->ximage);
@@ -269,6 +267,7 @@ gdk_image_new (GdkImageType type,
g_free (image);
gdk_use_xshm = False;
+
return NULL;
}
@@ -315,22 +314,7 @@ gdk_image_new (GdkImageType type,
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;
- }
+ image->bpp = (private->ximage->bits_per_pixel + 7) / 8;
}
}
diff --git a/gdk/gdkpixmap.c b/gdk/gdkpixmap.c
index 22e5a07867..6fc47e316e 100644
--- a/gdk/gdkpixmap.c
+++ b/gdk/gdkpixmap.c
@@ -518,7 +518,7 @@ _gdk_pixmap_create_from_xpm (GdkWindow *window,
color_name = gdk_pixmap_extract_color (buffer);
- if (color_name == NULL ||
+ if (color_name == NULL || g_strcasecmp (color_name, "None") == 0 ||
gdk_color_parse (color_name, &color->color) == FALSE)
{
color->color = *transparent_color;
@@ -817,7 +817,8 @@ void
gdk_pixmap_unref (GdkPixmap *pixmap)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap;
- g_return_if_fail(pixmap != NULL);
+ g_return_if_fail (pixmap != NULL);
+ g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)
diff --git a/gdk/gdkprivate.h b/gdk/gdkprivate.h
index 4f12915c1e..b549211858 100644
--- a/gdk/gdkprivate.h
+++ b/gdk/gdkprivate.h
@@ -146,6 +146,8 @@ struct _GdkFontPrivate
gpointer xfont;
Display *xdisplay;
guint ref_count;
+
+ GSList *names;
};
struct _GdkCursorPrivate
diff --git a/gdk/gdkproperty.c b/gdk/gdkproperty.c
index 5663352460..7973d8fc7e 100644
--- a/gdk/gdkproperty.c
+++ b/gdk/gdkproperty.c
@@ -45,15 +45,16 @@ gdk_atom_intern (const gchar *atom_name,
{
retval = XInternAtom (gdk_display, atom_name, only_if_exists);
- g_hash_table_insert (atom_hash,
- g_strdup (atom_name),
- GUINT_TO_POINTER (retval));
+ if (retval != None)
+ g_hash_table_insert (atom_hash,
+ g_strdup (atom_name),
+ GUINT_TO_POINTER (retval));
}
return retval;
}
-gchar *
+gchar*
gdk_atom_name (GdkAtom atom)
{
gchar *t;
@@ -69,7 +70,7 @@ gdk_atom_name (GdkAtom atom)
t = XGetAtomName (gdk_display, atom);
gdk_error_warnings = old_error_warnings;
- if (gdk_error_code == -1)
+ if (gdk_error_code)
{
if (t)
XFree (t);
@@ -162,10 +163,10 @@ gdk_property_get (GdkWindow *window,
ret_length = ret_nitems;
break;
case 16:
- ret_length = 2 * ret_nitems;
+ ret_length = sizeof(short) * ret_nitems;
break;
case 32:
- ret_length = 4 * ret_nitems;
+ ret_length = sizeof(long) * ret_nitems;
break;
default:
g_warning ("unknown property return format: %d", ret_format);
diff --git a/gdk/gdkrgb.c b/gdk/gdkrgb.c
index 86d6f998d1..e800916f50 100644
--- a/gdk/gdkrgb.c
+++ b/gdk/gdkrgb.c
@@ -482,27 +482,30 @@ gdk_rgb_score_visual (GdkVisual *visual)
static void
gdk_rgb_choose_visual (void)
{
- GList *visuals;
+ GList *visuals, *tmp_list;
guint32 score, best_score;
GdkVisual *visual, *best_visual;
visuals = gdk_list_visuals ();
+ tmp_list = visuals;
- best_visual = visuals->data;
+ best_visual = tmp_list->data;
best_score = gdk_rgb_score_visual (best_visual);
- visuals = visuals->next;
- while (visuals)
+ tmp_list = tmp_list->next;
+ while (tmp_list)
{
- visual = visuals->data;
+ visual = tmp_list->data;
score = gdk_rgb_score_visual (visual);
if (score > best_score)
{
best_score = score;
best_visual = visual;
}
- visuals = visuals->next;
+ tmp_list = tmp_list->next;
}
+ g_list_free (visuals);
+
image_info->visual = best_visual;
}
diff --git a/gdk/gdkselection.c b/gdk/gdkselection.c
index 64a18d0424..3ee2e43b3d 100644
--- a/gdk/gdkselection.c
+++ b/gdk/gdkselection.c
@@ -105,11 +105,11 @@ gdk_selection_property_get (GdkWindow *requestor,
gulong length;
GdkAtom prop_type;
gint prop_format;
- guchar *t;
+ guchar *t = NULL;
g_return_val_if_fail (requestor != NULL, 0);
- /* If retrieved chunks are typically small, (and the ICCM says the
+ /* If retrieved chunks are typically small, (and the ICCCM 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 */
@@ -133,11 +133,11 @@ gdk_selection_property_get (GdkWindow *requestor,
*data = NULL;
return 0;
}
-
+
if (t)
{
- t = NULL;
XFree (t);
+ t = NULL;
}
/* Add on an extra byte to handle null termination. X guarantees
@@ -188,7 +188,7 @@ gdk_selection_send_notify (guint32 requestor,
xevent.property = property;
xevent.time = time;
- XSendEvent (gdk_display, requestor, False, NoEventMask, (XEvent*) &xevent);
+ gdk_send_xevent (requestor, False, NoEventMask, (XEvent*) &xevent);
}
gint
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 93fd0a4a7d..47b200c3e4 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -34,17 +34,9 @@
#include "gdkprivate.h"
#include "MwmUtil.h"
-#if HAVE_CONFIG_H
-# include <config.h>
-# if STDC_HEADERS
-# include <stdlib.h>
-# include <stdio.h>
-# include <string.h>
-# endif
-#else
-# include <stdlib.h>
-# include <stdio.h>
-#endif
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
#ifdef HAVE_SHAPE_EXT
@@ -707,10 +699,10 @@ gdk_window_destroy_notify (GdkWindow *window)
if (!private->destroyed)
{
- if (private->window_type == GDK_WINDOW_FOREIGN)
- gdk_window_internal_destroy (window, FALSE, FALSE);
- else
+ if (private->window_type != GDK_WINDOW_FOREIGN)
g_warning ("GdkWindow %#lx unexpectedly destroyed", private->xwindow);
+
+ gdk_window_internal_destroy (window, FALSE, FALSE);
}
gdk_xid_table_remove (private->xwindow);
@@ -732,6 +724,7 @@ gdk_window_unref (GdkWindow *window)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)window;
g_return_if_fail (window != NULL);
+ g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)
@@ -1089,8 +1082,10 @@ gdk_window_set_hints (GdkWindow *window,
size_hints.max_height = max_height;
}
- if (flags)
- XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints);
+ /* FIXME: Would it be better to delete this property of
+ * flags == 0? It would save space on the server
+ */
+ XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints);
}
void
@@ -1110,7 +1105,15 @@ gdk_window_set_geometry_hints (GdkWindow *window,
size_hints.flags = 0;
if (geom_mask & GDK_HINT_POS)
- size_hints.flags |= PPosition;
+ {
+ size_hints.flags |= PPosition;
+ /* We need to initialize the following obsolete fields because KWM
+ * apparently uses these fields if they are non-zero.
+ * #@#!#!$!.
+ */
+ size_hints.x = 0;
+ size_hints.y = 0;
+ }
if (geom_mask & GDK_HINT_MIN_SIZE)
{
@@ -1145,28 +1148,30 @@ gdk_window_set_geometry_hints (GdkWindow *window,
size_hints.flags |= PAspect;
if (geometry->min_aspect <= 1)
{
- size_hints.min_aspect.x = G_MAXINT * geometry->min_aspect;
- size_hints.min_aspect.y = G_MAXINT;
+ size_hints.min_aspect.x = 65536 * geometry->min_aspect;
+ size_hints.min_aspect.y = 65536;
}
else
{
- size_hints.min_aspect.x = G_MAXINT;
- size_hints.min_aspect.y = G_MAXINT / geometry->min_aspect;;
+ size_hints.min_aspect.x = 65536;
+ size_hints.min_aspect.y = 65536 / geometry->min_aspect;;
}
if (geometry->max_aspect <= 1)
{
- size_hints.max_aspect.x = G_MAXINT * geometry->max_aspect;
- size_hints.max_aspect.y = G_MAXINT;
+ size_hints.max_aspect.x = 65536 * geometry->max_aspect;
+ size_hints.max_aspect.y = 65536;
}
else
{
- size_hints.max_aspect.x = G_MAXINT;
- size_hints.max_aspect.y = G_MAXINT / geometry->max_aspect;;
+ size_hints.max_aspect.x = 65536;
+ size_hints.max_aspect.y = 65536 / geometry->max_aspect;;
}
}
-
- if (geom_mask)
- XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints);
+
+ /* FIXME: Would it be better to delete this property of
+ * geom_mask == 0? It would save space on the server
+ */
+ XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints);
}
void
diff --git a/gdk/x11/gdkcc-x11.c b/gdk/x11/gdkcc-x11.c
index 573b2efa15..d1d1e754f7 100644
--- a/gdk/x11/gdkcc-x11.c
+++ b/gdk/x11/gdkcc-x11.c
@@ -491,10 +491,11 @@ init_palette (GdkColorContext *cc)
if (cc->color_hash)
{
- /* XXX: quick-and-dirty way to remove everything */
-
+ g_hash_table_foreach (cc->color_hash,
+ free_hash_entry,
+ NULL);
g_hash_table_destroy (cc->color_hash);
- cc->color_hash = g_hash_table_new (hash_color, compare_colors);
+ cc->color_hash = NULL;
}
cc->palette = NULL;
@@ -618,11 +619,6 @@ gdk_color_context_new (GdkVisual *visual,
g_message ("gdk_color_context_new: screen depth is %i, no. of colors is %i\n",
cc->visual->depth, cc->num_colors));
- /* check if we need to initialize a hash table */
-
- if ((cc->mode == GDK_CC_MODE_STD_CMAP) || (cc->mode == GDK_CC_MODE_UNDEFINED))
- cc->color_hash = g_hash_table_new (hash_color, compare_colors);
-
return (GdkColorContext *) cc;
}
@@ -677,17 +673,9 @@ gdk_color_context_free (GdkColorContext *cc)
gdk_colormap_unref (cc->colormap);
/* free any palette that has been associated with this GdkColorContext */
-
+
init_palette (cc);
- if (cc->color_hash)
- {
- g_hash_table_foreach (cc->color_hash,
- free_hash_entry,
- NULL);
- g_hash_table_destroy (cc->color_hash);
- }
-
g_free (cc);
}
@@ -780,13 +768,14 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
default:
{
GdkColor color;
- GdkColor *result;
+ GdkColor *result = NULL;
color.red = red;
color.green = green;
color.blue = blue;
-
- result = g_hash_table_lookup (cc->color_hash, &color);
+
+ if (cc->color_hash)
+ result = g_hash_table_lookup (cc->color_hash, &color);
if (!result)
{
@@ -831,6 +820,9 @@ gdk_color_context_get_pixel (GdkColorContext *cc,
cnew = g_new (GdkColor, 1);
*cnew = color;
+
+ if (!cc->color_hash)
+ cc->color_hash = g_hash_table_new (hash_color, compare_colors);
g_hash_table_insert (cc->color_hash, cnew, cnew);
cc->clut[cc->num_allocated] = color.pixel;
@@ -1489,20 +1481,7 @@ gdk_color_context_add_palette (GdkColorContext *cc,
/* restore previous mode if we aren't adding a new palette */
if (num_palette == 0)
- {
- /* GDK_CC_MODE_STD_CMAP uses a hash table, so we'd better initialize one */
-
- /* XXX: here, the hash table is already initialized */
-
- return 0;
- }
-
- /* Initialize a hash table for this palette (we need one for allocating
- * the pixels in the palette using the current settings)
- */
-
- if (cc->color_hash == NULL)
- cc->color_hash = g_hash_table_new (hash_color, compare_colors);
+ return 0;
/* copy incoming palette */
@@ -1549,6 +1528,9 @@ gdk_color_context_add_palette (GdkColorContext *cc,
if (cc->color_hash)
{
+ g_hash_table_foreach (cc->color_hash,
+ free_hash_entry,
+ NULL);
g_hash_table_destroy (cc->color_hash);
cc->color_hash = NULL;
}
diff --git a/gdk/x11/gdkcolor-x11.c b/gdk/x11/gdkcolor-x11.c
index bd48087543..2baa200ee0 100644
--- a/gdk/x11/gdkcolor-x11.c
+++ b/gdk/x11/gdkcolor-x11.c
@@ -70,13 +70,14 @@ gdk_colormap_new (GdkVisual *visual,
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
colormap->size = visual->colormap_size;
- colormap->colors = g_new (GdkColor, colormap->size);
+ colormap->colors = NULL;
switch (visual->type)
{
case GDK_VISUAL_GRAYSCALE:
case GDK_VISUAL_PSEUDO_COLOR:
private->info = g_new0 (GdkColorInfo, colormap->size);
+ colormap->colors = g_new (GdkColor, colormap->size);
private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
(GCompareFunc) gdk_color_equal);
@@ -116,6 +117,7 @@ gdk_colormap_new (GdkVisual *visual,
private->private_val = TRUE;
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
xvisual, AllocAll);
+ colormap->colors = g_new (GdkColor, colormap->size);
size = 1 << visual->red_prec;
for (i = 0; i < size; i++)
@@ -428,56 +430,7 @@ gdk_colors_alloc (GdkColormap *colormap,
}
}
- return return_val;
-}
-
-/* This is almost identical to gdk_colormap_free_colors.
- * Keep them in sync!
- */
-void
-gdk_colors_free (GdkColormap *colormap,
- gulong *in_pixels,
- gint in_npixels,
- gulong planes)
-{
- GdkColormapPrivate *private;
- gulong *pixels;
- gint npixels = 0;
- gint i;
-
- g_return_if_fail (colormap != NULL);
- g_return_if_fail (in_pixels != NULL);
-
- private = (GdkColormapPrivate*) colormap;
-
- if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
- (private->visual->type != GDK_VISUAL_GRAYSCALE))
- return;
-
- pixels = g_new (gulong, in_npixels);
-
- for (i=0; i<in_npixels; i++)
- {
- gulong pixel = in_pixels[i];
-
- if (private->info[pixel].ref_count)
- {
- private->info[pixel].ref_count--;
-
- if (private->info[pixel].ref_count == 0)
- {
- pixels[npixels++] = pixel;
- if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
- g_hash_table_remove (private->hash, &colormap->colors[in_pixels[i]]);
- private->info[pixel].flags = 0;
- }
- }
- }
-
- if (npixels)
- XFreeColors (private->xdisplay, private->xcolormap,
- pixels, npixels, planes);
- g_free (pixels);
+ return return_val != 0;
}
/*
@@ -536,7 +489,7 @@ gdk_color_free (GdkColor *color)
g_mem_chunk_free (color_chunk, color);
}
-gint
+gboolean
gdk_color_white (GdkColormap *colormap,
GdkColor *color)
{
@@ -559,7 +512,7 @@ gdk_color_white (GdkColormap *colormap,
return return_val;
}
-gint
+gboolean
gdk_color_black (GdkColormap *colormap,
GdkColor *color)
{
@@ -608,6 +561,104 @@ gdk_color_parse (const gchar *spec,
return return_val;
}
+/* This is almost identical to gdk_colormap_free_colors.
+ * Keep them in sync!
+ */
+void
+gdk_colors_free (GdkColormap *colormap,
+ gulong *in_pixels,
+ gint in_npixels,
+ gulong planes)
+{
+ GdkColormapPrivate *private;
+ gulong *pixels;
+ gint npixels = 0;
+ gint i;
+
+ g_return_if_fail (colormap != NULL);
+ g_return_if_fail (in_pixels != NULL);
+
+ private = (GdkColormapPrivate*) colormap;
+
+ if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
+ (private->visual->type != GDK_VISUAL_GRAYSCALE))
+ return;
+
+ pixels = g_new (gulong, in_npixels);
+
+ for (i=0; i<in_npixels; i++)
+ {
+ gulong pixel = in_pixels[i];
+
+ if (private->info[pixel].ref_count)
+ {
+ private->info[pixel].ref_count--;
+
+ if (private->info[pixel].ref_count == 0)
+ {
+ pixels[npixels++] = pixel;
+ if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
+ g_hash_table_remove (private->hash, &colormap->colors[pixel]);
+ private->info[pixel].flags = 0;
+ }
+ }
+ }
+
+ if (npixels)
+ XFreeColors (private->xdisplay, private->xcolormap,
+ pixels, npixels, planes);
+ g_free (pixels);
+}
+
+/* This is almost identical to gdk_colors_free.
+ * Keep them in sync!
+ */
+void
+gdk_colormap_free_colors (GdkColormap *colormap,
+ GdkColor *colors,
+ gint ncolors)
+{
+ GdkColormapPrivate *private;
+ gulong *pixels;
+ gint npixels = 0;
+ gint i;
+
+ g_return_if_fail (colormap != NULL);
+ g_return_if_fail (colors != NULL);
+
+ private = (GdkColormapPrivate*) colormap;
+
+ if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
+ (private->visual->type != GDK_VISUAL_GRAYSCALE))
+ return;
+
+ pixels = g_new (gulong, ncolors);
+
+ for (i=0; i<ncolors; i++)
+ {
+ gulong pixel = colors[i].pixel;
+
+ if (private->info[pixel].ref_count)
+ {
+ private->info[pixel].ref_count--;
+
+ if (private->info[pixel].ref_count == 0)
+ {
+ pixels[npixels++] = pixel;
+ if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
+ g_hash_table_remove (private->hash, &colormap->colors[pixel]);
+ private->info[pixel].flags = 0;
+ }
+ }
+ }
+
+ if (npixels)
+ XFreeColors (private->xdisplay, private->xcolormap,
+ pixels, npixels, 0);
+
+ g_free (pixels);
+}
+
/********************
* Color allocation *
********************/
@@ -648,6 +699,7 @@ gdk_colormap_alloc1 (GdkColormap *colormap,
else
{
colormap->colors[ret->pixel] = *color;
+ colormap->colors[ret->pixel].pixel = ret->pixel;
private->info[ret->pixel].ref_count = 1;
g_hash_table_insert (private->hash,
@@ -1025,55 +1077,6 @@ gdk_colormap_alloc_color (GdkColormap *colormap,
return success;
}
-/* This is almost identical to gdk_colors_free.
- * Keep them in sync!
- */
-void
-gdk_colormap_free_colors (GdkColormap *colormap,
- GdkColor *colors,
- gint ncolors)
-{
- GdkColormapPrivate *private;
- gulong *pixels;
- gint npixels = 0;
- gint i;
-
- g_return_if_fail (colormap != NULL);
- g_return_if_fail (colors != NULL);
-
- private = (GdkColormapPrivate*) colormap;
-
- if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
- (private->visual->type != GDK_VISUAL_GRAYSCALE))
- return;
-
- pixels = g_new (gulong, ncolors);
-
- for (i=0; i<ncolors; i++)
- {
- gulong pixel = colors[i].pixel;
-
- if (private->info[pixel].ref_count)
- {
- private->info[pixel].ref_count--;
-
- if (private->info[pixel].ref_count == 0)
- {
- pixels[npixels++] = pixel;
- if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
- g_hash_table_remove (private->hash, &colors[i]);
- private->info[pixel].flags = 0;
- }
- }
- }
-
- if (npixels)
- XFreeColors (private->xdisplay, private->xcolormap,
- pixels, npixels, 0);
-
- g_free (pixels);
-}
-
gboolean
gdk_color_alloc (GdkColormap *colormap,
GdkColor *color)
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index 3b8f05d8fd..a2be5e160c 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -31,8 +31,6 @@
#include "gdk/gdkprivate.h"
#include "gdk.h"
-#define NEW_DRAGS
-
typedef struct _GdkDragContextPrivate GdkDragContextPrivate;
typedef enum {
@@ -70,7 +68,8 @@ struct _GdkDragContextPrivate {
GdkDragAction old_actions; /* The last actions we sent to the source */
GdkDragAction xdnd_actions; /* What is currently set in XdndActionList */
- Window dest_xid;
+ Window dest_xid; /* The last window we looked up */
+ Window drop_xid; /* The (non-proxied) window that is receiving drops */
guint xdnd_targets_set : 1; /* Whether we've already set XdndTypeList */
guint xdnd_actions_set : 1; /* Whether we've already set XdndActionList */
guint xdnd_have_actions : 1; /* Whether an XdndActionList was provided */
@@ -151,6 +150,7 @@ gdk_drag_context_unref (GdkDragContext *context)
GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
g_return_if_fail (context != NULL);
+ g_return_if_fail (private->ref_count > 0);
private->ref_count--;
@@ -196,8 +196,8 @@ gdk_drag_context_find (gboolean is_source,
private = (GdkDragContextPrivate *)context;
context_dest_xid = context->dest_window ?
- (private->dest_xid ?
- private->dest_xid :
+ (private->drop_xid ?
+ private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window)) :
None;
@@ -387,7 +387,7 @@ gdk_window_cache_new (void)
xwa.x, xwa.y, xwa.width, xwa.height,
xwa.map_state != IsUnmapped);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
gdk_error_code = 0;
else
{
@@ -441,9 +441,10 @@ get_client_window_at_coords_recurse (Window win,
wm_state_atom, 0, 0, False, AnyPropertyType,
&type, &format, &nitems, &after, &data);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
{
gdk_error_code = 0;
+
return None;
}
@@ -458,9 +459,10 @@ get_client_window_at_coords_recurse (Window win,
XTranslateCoordinates (gdk_display, gdk_root_window, win,
x_root, y_root, &dest_x, &dest_y, &child);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
{
gdk_error_code = 0;
+
return None;
}
@@ -469,7 +471,7 @@ get_client_window_at_coords_recurse (Window win,
&root, &tmp_parent, &children, &nchildren) == 0)
return 0;
- if (gdk_error_code == 0)
+ if (!gdk_error_code)
{
for (i = nchildren - 1; (i >= 0) && (child == None); i--)
{
@@ -477,7 +479,7 @@ get_client_window_at_coords_recurse (Window win,
XGetWindowAttributes (gdk_display, children[i], &xwa);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
gdk_error_code = 0;
else if ((xwa.map_state == IsViewable) && (xwa.class == InputOutput) &&
(x >= xwa.x) && (x < xwa.x + (gint)xwa.width) &&
@@ -566,9 +568,10 @@ get_client_window_at_coords_recurse (Window win,
wm_state_atom, 0, 0, False, AnyPropertyType,
&type, &format, &nitems, &after, &data);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
{
gdk_error_code = 0;
+
return None;
}
@@ -581,9 +584,10 @@ get_client_window_at_coords_recurse (Window win,
XTranslateCoordinates (gdk_display, gdk_root_window, win,
x_root, y_root, &dest_x, &dest_y, &child);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
{
gdk_error_code = 0;
+
return None;
}
@@ -620,7 +624,7 @@ get_client_window_at_coords (Window ignore,
XGetWindowAttributes (gdk_display, children[i], &xwa);
- if (gdk_error_code != 0)
+ if (gdk_error_code)
gdk_error_code = 0;
else if ((xwa.map_state == IsViewable) &&
(x_root >= xwa.x) && (x_root < xwa.x + (gint)xwa.width) &&
@@ -869,7 +873,7 @@ motif_find_drag_window (gboolean create)
Display *display;
XSetWindowAttributes attr;
- display = XOpenDisplay (NULL);
+ display = XOpenDisplay (gdk_display_name);
XSetCloseDownMode (display, RetainPermanent);
XGrabServer (display);
@@ -2027,6 +2031,8 @@ xdnd_set_targets (GdkDragContext *context)
XA_ATOM, 32, PropModeReplace,
(guchar *)atomlist, n_atoms);
+ g_free (atomlist);
+
private->xdnd_targets_set = 1;
}
@@ -2073,6 +2079,8 @@ xdnd_set_actions (GdkDragContext *context)
XA_ATOM, 32, PropModeReplace,
(guchar *)atomlist, n_atoms);
+ g_free (atomlist);
+
private->xdnd_actions_set = 1;
private->xdnd_actions = context->actions;
}
@@ -2106,13 +2114,9 @@ xdnd_send_enter (GdkDragContext *context)
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("XdndEnter", FALSE);
xev.xclient.format = 32;
-#ifdef NEW_DRAGS
- xev.xclient.window = private->dest_xid ?
- private->dest_xid :
+ xev.xclient.window = private->drop_xid ?
+ private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window);
-#else
- xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
-#endif
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
xev.xclient.data.l[1] = (3 << 24); /* version */
xev.xclient.data.l[2] = 0;
@@ -2162,13 +2166,9 @@ xdnd_send_leave (GdkDragContext *context)
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("XdndLeave", FALSE);
xev.xclient.format = 32;
-#ifdef NEW_DRAGS
- xev.xclient.window = private->dest_xid ?
- private->dest_xid :
+ xev.xclient.window = private->drop_xid ?
+ private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window);
-#else
- xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
-#endif
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = 0;
@@ -2195,13 +2195,9 @@ xdnd_send_drop (GdkDragContext *context, guint32 time)
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("XdndDrop", FALSE);
xev.xclient.format = 32;
-#ifdef NEW_DRAGS
- xev.xclient.window = private->dest_xid ?
- private->dest_xid :
+ xev.xclient.window = private->drop_xid ?
+ private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window);
-#else
- xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
-#endif
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = time;
@@ -2232,13 +2228,9 @@ xdnd_send_motion (GdkDragContext *context,
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_atom_intern ("XdndPosition", FALSE);
xev.xclient.format = 32;
-#ifdef NEW_DRAGS
- xev.xclient.window = private->dest_xid ?
- private->dest_xid :
+ xev.xclient.window = private->drop_xid ?
+ private->drop_xid :
GDK_WINDOW_XWINDOW (context->dest_window);
-#else
- xev.xclient.window = GDK_WINDOW_XWINDOW (context->dest_window);
-#endif
xev.xclient.data.l[0] = GDK_WINDOW_XWINDOW (context->source_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = (x_root << 16) | y_root;
@@ -2859,6 +2851,12 @@ gdk_drag_find_window (GdkDragContext *context,
/* Check if new destination accepts drags, and which protocol */
+ /* There is some ugliness here. We actually need to pass
+ * _three_ pieces of information to drag_motion - dest_window,
+ * protocol, and the XID of the unproxied window. The first
+ * two are passed explicitely, the third implicitly through
+ * protocol->dest_xid.
+ */
if ((recipient = gdk_drag_get_protocol (dest, protocol)))
{
*dest_window = gdk_window_lookup (recipient);
@@ -2917,6 +2915,7 @@ gdk_drag_motion (GdkDragContext *context,
if (dest_window)
{
context->dest_window = dest_window;
+ private->drop_xid = private->dest_xid;
gdk_window_ref (context->dest_window);
context->protocol = protocol;
@@ -2941,6 +2940,7 @@ gdk_drag_motion (GdkDragContext *context,
else
{
context->dest_window = NULL;
+ private->drop_xid = None;
context->action = 0;
}
diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c
index 159e0ee9e5..4f6f577f29 100644
--- a/gdk/x11/gdkevents-x11.c
+++ b/gdk/x11/gdkevents-x11.c
@@ -27,7 +27,6 @@
#include "gdk.h"
#include "gdkx.h"
#include "gdkprivate.h"
-#include "gdkinput.h"
#include "gdkkeysyms.h"
#if HAVE_CONFIG_H
@@ -37,6 +36,7 @@
# endif
#endif
+#include "gdkinput.h"
typedef struct _GdkIOClosure GdkIOClosure;
typedef struct _GdkEventPrivate GdkEventPrivate;
@@ -88,9 +88,11 @@ static GdkEvent* gdk_event_unqueue (void);
static gboolean gdk_event_prepare (gpointer source_data,
GTimeVal *current_time,
- gint *timeout);
+ gint *timeout,
+ gpointer user_data);
static gboolean gdk_event_check (gpointer source_data,
- GTimeVal *current_time);
+ GTimeVal *current_time,
+ gpointer user_data);
static gboolean gdk_event_dispatch (gpointer source_data,
GTimeVal *current_time,
gpointer user_data);
@@ -434,6 +436,10 @@ gdk_compress_exposures (XEvent *xevent,
rect1.width = xevent->xexpose.width;
rect1.height = xevent->xexpose.height;
+ event.any.type = GDK_EXPOSE;
+ event.any.window = None;
+ event.any.send_event = FALSE;
+
while (1)
{
if (count == 0)
@@ -449,6 +455,8 @@ gdk_compress_exposures (XEvent *xevent,
&tmp_event,
expose_predicate,
(XPointer)&info);
+
+ event.any.window = window;
/* We apply filters here, and if it was filtered, completely
* ignore the return
@@ -849,6 +857,12 @@ gdk_io_destroy (gpointer data)
g_free (closure);
}
+/* What do we do with G_IO_NVAL?
+ */
+#define READ_CONDITION (G_IO_IN | G_IO_HUP | G_IO_ERR)
+#define WRITE_CONDITION (G_IO_OUT | G_IO_ERR)
+#define EXCEPTION_CONDITION (G_IO_PRI)
+
static gboolean
gdk_io_invoke (GIOChannel *source,
GIOCondition condition,
@@ -857,11 +871,11 @@ gdk_io_invoke (GIOChannel *source,
GdkIOClosure *closure = data;
GdkInputCondition gdk_cond = 0;
- if (condition & (G_IO_IN | G_IO_PRI))
+ if (condition & READ_CONDITION)
gdk_cond |= GDK_INPUT_READ;
- if (condition & G_IO_OUT)
+ if (condition & WRITE_CONDITION)
gdk_cond |= GDK_INPUT_WRITE;
- if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
+ if (condition & EXCEPTION_CONDITION)
gdk_cond |= GDK_INPUT_EXCEPTION;
if (closure->condition & gdk_cond)
@@ -888,11 +902,11 @@ gdk_input_add_full (gint source,
closure->data = data;
if (condition & GDK_INPUT_READ)
- cond |= (G_IO_IN | G_IO_PRI);
+ cond |= READ_CONDITION;
if (condition & GDK_INPUT_WRITE)
- cond |= G_IO_OUT;
+ cond |= WRITE_CONDITION;
if (condition & GDK_INPUT_EXCEPTION)
- cond |= G_IO_ERR|G_IO_HUP|G_IO_NVAL;
+ cond |= EXCEPTION_CONDITION;
channel = g_io_channel_unix_new (source);
result = g_io_add_watch_full (channel, G_PRIORITY_DEFAULT, cond,
@@ -923,7 +937,6 @@ gdk_event_apply_filters (XEvent *xevent,
GdkEvent *event,
GList *filters)
{
- GdkEventFilter *filter;
GList *tmp_list;
GdkFilterReturn result;
@@ -931,13 +944,12 @@ gdk_event_apply_filters (XEvent *xevent,
while (tmp_list)
{
- filter = (GdkEventFilter*) tmp_list->data;
+ GdkEventFilter *filter = (GdkEventFilter*) tmp_list->data;
- result = (*filter->function) (xevent, event, filter->data);
+ tmp_list = tmp_list->next;
+ result = filter->function (xevent, event, filter->data);
if (result != GDK_FILTER_CONTINUE)
return result;
-
- tmp_list = tmp_list->next;
}
return GDK_FILTER_CONTINUE;
@@ -1002,7 +1014,7 @@ gdk_event_translate (GdkEvent *event,
gdk_window_ref (window);
event->any.window = window;
- event->any.send_event = xevent->xany.send_event;
+ event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
if (window_private && window_private->destroyed)
{
@@ -1057,9 +1069,6 @@ gdk_event_translate (GdkEvent *event,
}
#endif
- if (window == NULL)
- g_message ("Got event for unknown window: %#lx\n", xevent->xany.window);
-
/* We do a "manual" conversion of the XEvent to a
* GdkEvent. The structures are mostly the same so
* the conversion is fairly straightforward. We also
@@ -1513,10 +1522,11 @@ gdk_event_translate (GdkEvent *event,
/* Print debugging info.
*/
GDK_NOTE (EVENTS,
- g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d",
+ g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d%s",
xevent->xexpose.window, xevent->xexpose.count,
xevent->xexpose.x, xevent->xexpose.y,
- xevent->xexpose.width, xevent->xexpose.height));
+ xevent->xexpose.width, xevent->xexpose.height,
+ event->any.send_event ? " (send)" : ""));
gdk_compress_exposures (xevent, window);
event->expose.type = GDK_EXPOSE;
@@ -1601,7 +1611,17 @@ gdk_event_translate (GdkEvent *event,
break;
case CreateNotify:
- /* Not currently handled */
+ GDK_NOTE (EVENTS,
+ g_message ("create notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d parent: %ld ovr: %d",
+ xevent->xcreatewindow.window,
+ xevent->xcreatewindow.x,
+ xevent->xcreatewindow.y,
+ xevent->xcreatewindow.width,
+ xevent->xcreatewindow.height,
+ xevent->xcreatewindow.border_width,
+ xevent->xcreatewindow.parent,
+ xevent->xcreatewindow.override_redirect));
+ /* not really handled */
break;
case DestroyNotify:
@@ -1616,7 +1636,7 @@ gdk_event_translate (GdkEvent *event,
return_val = window_private && !window_private->destroyed;
- if(window && window_private->xwindow != GDK_ROOT_WINDOW())
+ if (window && window_private->xwindow != GDK_ROOT_WINDOW())
gdk_window_destroy_notify (window);
break;
@@ -1651,8 +1671,12 @@ gdk_event_translate (GdkEvent *event,
/* Print debugging info.
*/
GDK_NOTE (EVENTS,
- g_message ("reparent notify:\twindow: %ld",
- xevent->xreparent.window));
+ g_message ("reparent notify:\twindow: %ld x,y: %d %d parent: %ld ovr: %d",
+ xevent->xreparent.window,
+ xevent->xreparent.x,
+ xevent->xreparent.y,
+ xevent->xreparent.parent,
+ xevent->xreparent.override_redirect));
/* Not currently handled */
return_val = FALSE;
@@ -1661,36 +1685,8 @@ gdk_event_translate (GdkEvent *event,
case ConfigureNotify:
/* Print debugging info.
*/
- while ((XPending (gdk_display) > 0) &&
- XCheckTypedWindowEvent(gdk_display, xevent->xany.window,
- ConfigureNotify, xevent))
- {
- GdkFilterReturn result;
-
- GDK_NOTE (EVENTS,
- g_message ("configure notify discarded:\twindow: %ld",
- xevent->xconfigure.window));
-
- result = gdk_event_apply_filters (xevent, event,
- window_private
- ?window_private->filters
- :gdk_default_filters);
-
- /* If the result is GDK_FILTER_REMOVE, there will be
- * trouble, but anybody who filtering the Configure events
- * better know what they are doing
- */
- if (result != GDK_FILTER_CONTINUE)
- {
- return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
- }
-
- /*XSync (gdk_display, 0);*/
- }
-
-
GDK_NOTE (EVENTS,
- g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d",
+ g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d%s",
xevent->xconfigure.window,
xevent->xconfigure.x,
xevent->xconfigure.y,
@@ -1698,14 +1694,19 @@ gdk_event_translate (GdkEvent *event,
xevent->xconfigure.height,
xevent->xconfigure.border_width,
xevent->xconfigure.above,
- xevent->xconfigure.override_redirect));
-
- if (!window_private->destroyed &&
+ xevent->xconfigure.override_redirect,
+ !window
+ ? " (discarding)"
+ : window_private->window_type == GDK_WINDOW_CHILD
+ ? " (discarding child)"
+ : ""));
+ if (window &&
+ !window_private->destroyed &&
(window_private->extension_events != 0) &&
gdk_input_vtable.configure_event)
gdk_input_vtable.configure_event (&xevent->xconfigure, window);
- if (window_private->window_type == GDK_WINDOW_CHILD)
+ if (!window || window_private->window_type == GDK_WINDOW_CHILD)
return_val = FALSE;
else
{
@@ -1721,17 +1722,23 @@ gdk_event_translate (GdkEvent *event,
gint tx = 0;
gint ty = 0;
Window child_window = 0;
-
- if (!XTranslateCoordinates (window_private->xdisplay,
- window_private->xwindow,
- gdk_root_window,
- 0, 0,
- &tx, &ty,
- &child_window))
- g_warning ("GdkWindow %ld doesn't share root windows display?",
- window_private->xwindow);
- event->configure.x = tx;
- event->configure.y = ty;
+
+ gdk_error_trap_push ();
+ if (XTranslateCoordinates (window_private->xdisplay,
+ window_private->xwindow,
+ gdk_root_window,
+ 0, 0,
+ &tx, &ty,
+ &child_window))
+ {
+ if (!gdk_error_trap_pop ())
+ {
+ event->configure.x = tx;
+ event->configure.y = ty;
+ }
+ }
+ else
+ gdk_error_trap_pop ();
}
else
{
@@ -1751,8 +1758,15 @@ gdk_event_translate (GdkEvent *event,
/* Print debugging info.
*/
GDK_NOTE (EVENTS,
- g_message ("property notify:\twindow: %ld",
- xevent->xproperty.window));
+ gchar *atom = gdk_atom_name (xevent->xproperty.atom);
+ g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s",
+ xevent->xproperty.window,
+ xevent->xproperty.atom,
+ atom ? "\"" : "",
+ atom ? atom : "unknown",
+ atom ? "\"" : "");
+ g_free (atom);
+ );
event->property.type = GDK_PROPERTY_NOTIFY;
event->property.window = window;
@@ -1910,8 +1924,8 @@ gdk_event_translate (GdkEvent *event,
GdkFilterReturn
gdk_wm_protocols_filter (GdkXEvent *xev,
- GdkEvent *event,
- gpointer data)
+ GdkEvent *event,
+ gpointer data)
{
XEvent *xevent = (XEvent *)xev;
@@ -1993,8 +2007,7 @@ gdk_events_queue (void)
event->any.type = GDK_NOTHING;
event->any.window = NULL;
- event->any.send_event = FALSE;
- event->any.send_event = xevent.xany.send_event;
+ event->any.send_event = xevent.xany.send_event ? TRUE : FALSE;
((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
@@ -2017,7 +2030,8 @@ gdk_events_queue (void)
static gboolean
gdk_event_prepare (gpointer source_data,
GTimeVal *current_time,
- gint *timeout)
+ gint *timeout,
+ gpointer user_data)
{
gboolean retval;
@@ -2034,7 +2048,8 @@ gdk_event_prepare (gpointer source_data,
static gboolean
gdk_event_check (gpointer source_data,
- GTimeVal *current_time)
+ GTimeVal *current_time,
+ gpointer user_data)
{
gboolean retval;
@@ -2133,29 +2148,29 @@ gdk_event_send_client_message_to_all_recurse (XEvent *xev,
guint level)
{
static GdkAtom wm_state_atom = GDK_NONE;
-
Atom type = None;
int format;
unsigned long nitems, after;
unsigned char *data;
-
Window *ret_children, ret_root, ret_parent;
unsigned int ret_nchildren;
- int i;
-
+ gint old_warnings = gdk_error_warnings;
gboolean send = FALSE;
gboolean found = FALSE;
+ int i;
if (!wm_state_atom)
wm_state_atom = gdk_atom_intern ("WM_STATE", FALSE);
+ gdk_error_warnings = FALSE;
gdk_error_code = 0;
XGetWindowProperty (gdk_display, xid, wm_state_atom, 0, 0, False, AnyPropertyType,
&type, &format, &nitems, &after, &data);
if (gdk_error_code)
{
- gdk_error_code = 0;
+ gdk_error_warnings = old_warnings;
+
return FALSE;
}
@@ -2167,18 +2182,20 @@ gdk_event_send_client_message_to_all_recurse (XEvent *xev,
else
{
/* OK, we're all set, now let's find some windows to send this to */
- if (XQueryTree(gdk_display, xid, &ret_root, &ret_parent,
- &ret_children, &ret_nchildren) != True)
- return FALSE;
-
- if (gdk_error_code)
- return FALSE;
+ if (XQueryTree (gdk_display, xid, &ret_root, &ret_parent,
+ &ret_children, &ret_nchildren) != True ||
+ gdk_error_code)
+ {
+ gdk_error_warnings = old_warnings;
+
+ return FALSE;
+ }
for(i = 0; i < ret_nchildren; i++)
- if (gdk_event_send_client_message_to_all_recurse(xev, ret_children[i], level + 1))
+ if (gdk_event_send_client_message_to_all_recurse (xev, ret_children[i], level + 1))
found = TRUE;
- XFree(ret_children);
+ XFree (ret_children);
}
if (send || (!found && (level == 1)))
@@ -2187,6 +2204,8 @@ gdk_event_send_client_message_to_all_recurse (XEvent *xev,
gdk_send_xevent (xid, False, NoEventMask, xev);
}
+ gdk_error_warnings = old_warnings;
+
return (send || found);
}
diff --git a/gdk/x11/gdkfont-x11.c b/gdk/x11/gdkfont-x11.c
index d1f779a064..096cf8a537 100644
--- a/gdk/x11/gdkfont-x11.c
+++ b/gdk/x11/gdkfont-x11.c
@@ -29,6 +29,63 @@
#include "gdk.h"
#include "gdkprivate.h"
+static GHashTable *font_name_hash = NULL;
+static GHashTable *fontset_name_hash = NULL;
+
+static void
+gdk_font_hash_insert (GdkFontType type, GdkFont *font, const gchar *font_name)
+{
+ GdkFontPrivate *private = (GdkFontPrivate *)font;
+ GHashTable **hashp = (type == GDK_FONT_FONT) ?
+ &font_name_hash : &fontset_name_hash;
+
+ if (!*hashp)
+ *hashp = g_hash_table_new (g_str_hash, g_str_equal);
+
+ private->names = g_slist_prepend (private->names, g_strdup (font_name));
+ g_hash_table_insert (*hashp, private->names->data, font);
+}
+
+static void
+gdk_font_hash_remove (GdkFontType type, GdkFont *font)
+{
+ GdkFontPrivate *private = (GdkFontPrivate *)font;
+ GSList *tmp_list;
+ GHashTable *hash = (type == GDK_FONT_FONT) ?
+ font_name_hash : fontset_name_hash;
+
+ tmp_list = private->names;
+ while (tmp_list)
+ {
+ g_hash_table_remove (hash, tmp_list->data);
+ g_free (tmp_list->data);
+
+ tmp_list = tmp_list->next;
+ }
+
+ g_slist_free (private->names);
+ private->names = NULL;
+}
+
+static GdkFont *
+gdk_font_hash_lookup (GdkFontType type, const gchar *font_name)
+{
+ GdkFont *result;
+ GHashTable *hash = (type == GDK_FONT_FONT) ?
+ font_name_hash : fontset_name_hash;
+
+ if (!hash)
+ return NULL;
+ else
+ {
+ result = g_hash_table_lookup (hash, font_name);
+ if (result)
+ gdk_font_ref (result);
+
+ return result;
+ }
+}
+
GdkFont*
gdk_font_load (const gchar *font_name)
{
@@ -38,6 +95,10 @@ gdk_font_load (const gchar *font_name)
g_return_val_if_fail (font_name != NULL, NULL);
+ font = gdk_font_hash_lookup (GDK_FONT_FONT, font_name);
+ if (font)
+ return font;
+
xfont = XLoadQueryFont (gdk_display, font_name);
if (xfont == NULL)
return NULL;
@@ -57,7 +118,8 @@ gdk_font_load (const gchar *font_name)
private->xdisplay = gdk_display;
private->xfont = xfont;
private->ref_count = 1;
-
+ private->names = NULL;
+
font = (GdkFont*) private;
font->type = GDK_FONT_FONT;
font->ascent = xfont->ascent;
@@ -66,6 +128,8 @@ gdk_font_load (const gchar *font_name)
gdk_xid_table_insert (&xfont->fid, font);
}
+ gdk_font_hash_insert (GDK_FONT_FONT, font, font_name);
+
return font;
}
@@ -79,6 +143,10 @@ gdk_fontset_load (gchar *fontset_name)
gchar **missing_charset_list;
gchar *def_string;
+ font = gdk_font_hash_lookup (GDK_FONT_FONTSET, fontset_name);
+ if (font)
+ return font;
+
private = g_new (GdkFontPrivate, 1);
font = (GdkFont*) private;
@@ -121,8 +189,12 @@ gdk_fontset_load (gchar *fontset_name)
font->ascent = MAX (font->ascent, font_structs[i]->ascent);
font->descent = MAX (font->descent, font_structs[i]->descent);
}
+
+ private->names = NULL;
+ gdk_font_hash_insert (GDK_FONT_FONTSET, font, fontset_name);
+
+ return font;
}
- return font;
}
GdkFont*
@@ -141,14 +213,16 @@ void
gdk_font_unref (GdkFont *font)
{
GdkFontPrivate *private;
+ private = (GdkFontPrivate*) font;
g_return_if_fail (font != NULL);
-
- private = (GdkFontPrivate*) font;
+ g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)
{
+ gdk_font_hash_remove (font->type, font);
+
switch (font->type)
{
case GDK_FONT_FONT:
@@ -205,8 +279,12 @@ gdk_font_equal (const GdkFont *fonta,
}
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));
+ gchar *namea, *nameb;
+
+ namea = XBaseFontNameListOfFontSet((XFontSet) privatea->xfont);
+ nameb = XBaseFontNameListOfFontSet((XFontSet) privateb->xfont);
+
+ return (strcmp(namea, nameb) == 0);
}
else
/* fontset != font */
@@ -578,7 +656,20 @@ gdk_text_extents_wc (GdkFont *font,
}
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
- XwcTextExtents (fontset, text, text_length, &ink, &logical);
+
+ if (sizeof(GdkWChar) == sizeof(wchar_t))
+ XwcTextExtents (fontset, (wchar_t *)text, text_length, &ink, &logical);
+ else
+ {
+ wchar_t *text_wchar;
+ gint i;
+
+ text_wchar = g_new (wchar_t, text_length);
+ for (i = 0; i < text_length; i++)
+ text_wchar[i] = text[i];
+ XwcTextExtents (fontset, text_wchar, text_length, &ink, &logical);
+ g_free (text_wchar);
+ }
if (lbearing)
*lbearing = ink.x;
if (rbearing)
@@ -652,7 +743,7 @@ gdk_text_measure (GdkFont *font,
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
XmbTextExtents (fontset, text, text_length, &ink, &log);
- width = log.width;
+ width = ink.x + ink.width;
break;
default:
width = 0;
diff --git a/gdk/x11/gdkglobals-x11.c b/gdk/x11/gdkglobals-x11.c
index 7a9307b2af..ae6c066f96 100644
--- a/gdk/x11/gdkglobals-x11.c
+++ b/gdk/x11/gdkglobals-x11.c
@@ -57,7 +57,7 @@ GdkDndGlobals gdk_dnd = {None,None,None,
{0,0}, {0,0},
{0,0,0,0}, NULL, None, 0};
gchar *gdk_progclass = NULL;
-gint gdk_error_code;
+gint gdk_error_code = 0;
gint gdk_error_warnings = TRUE;
gint gdk_null_window_warnings = TRUE;
GList *gdk_default_filters = NULL;
diff --git a/gdk/x11/gdkim-x11.c b/gdk/x11/gdkim-x11.c
index c06afc0577..e453925093 100644
--- a/gdk/x11/gdkim-x11.c
+++ b/gdk/x11/gdkim-x11.c
@@ -386,7 +386,7 @@ gdk_im_real_open (void)
destroy_cb.callback = gdk_im_destroy_cb;
destroy_cb.client_data = NULL;
- if (NULL != XSetIMValues (xim_im, XNDestroyCallback, &destroy_cb, NULL))
+ if (NULL != (void *) XSetIMValues (xim_im, XNDestroyCallback, &destroy_cb, NULL))
GDK_NOTE (XIM, g_warning ("Could not set destroy callback to IM. Be careful to not destroy your input method."));
#endif
@@ -469,7 +469,7 @@ gdk_ic_real_new (GdkIC *ic)
mask |= GDK_IC_PREEDIT_AREA_REQ;
preedit_area.x = attr->preedit_area.x;
- preedit_area.y = attr->preedit_area.x;
+ preedit_area.y = attr->preedit_area.y;
preedit_area.width = attr->preedit_area.width;
preedit_area.height = attr->preedit_area.height;
@@ -484,7 +484,7 @@ gdk_ic_real_new (GdkIC *ic)
mask |= GDK_IC_PREEDIT_POSITION_REQ;
preedit_area.x = attr->preedit_area.x;
- preedit_area.y = attr->preedit_area.x;
+ preedit_area.y = attr->preedit_area.y;
preedit_area.width = attr->preedit_area.width;
preedit_area.height = attr->preedit_area.height;
@@ -506,7 +506,7 @@ gdk_ic_real_new (GdkIC *ic)
mask |= GDK_IC_STATUS_AREA_REQ;
status_area.x = attr->status_area.x;
- status_area.y = attr->status_area.x;
+ status_area.y = attr->status_area.y;
status_area.width = attr->status_area.width;
status_area.height = attr->status_area.height;
@@ -518,6 +518,12 @@ gdk_ic_real_new (GdkIC *ic)
break;
}
+ /* We have to ensure that the client window is actually created on
+ * the X server, or XCreateIC fails because the XIM server can't get
+ * information about the client window.
+ */
+ gdk_flush();
+
if (preedit_attr != NULL && status_attr != NULL)
private->xic = XCreateIC (xim_im,
XNInputStyle,
@@ -871,7 +877,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNFontSet;
arg->value = (gpointer) GDK_FONT_XFONT(attr->status_fontset);
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_FONTSET;
}
@@ -887,7 +893,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNArea;
arg->value = (gpointer) &rect;
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_AREA;
}
@@ -903,7 +909,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNArea;
arg->value = (gpointer) &rect;
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_AREA_NEEDED;
else
private->mask &= ~GDK_IC_STATUS_AREA_NEEDED;
@@ -914,7 +920,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNForeground;
arg->value = (gpointer) attr->status_foreground.pixel;
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_FOREGROUND;
}
@@ -923,7 +929,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNBackground;
arg->value = (gpointer) attr->status_background.pixel;
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_BACKGROUND;
}
@@ -932,7 +938,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNBackgroundPixmap;
arg->value = (gpointer) GDK_WINDOW_XWINDOW(attr->status_pixmap);
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_PIXMAP;
}
@@ -941,7 +947,7 @@ gdk_ic_real_set_attr (GdkIC *ic,
arg->name = XNColormap;
arg->value = (gpointer) GDK_COLORMAP_XCOLORMAP(attr->status_colormap);
- if (XSetICValues (xic, XNPreeditAttributes, arg, NULL))
+ if (XSetICValues (xic, XNStatusAttributes, arg, NULL))
error |= GDK_IC_STATUS_COLORMAP;
}
@@ -1565,8 +1571,10 @@ gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
!= Success)
{
/* InvalidChar */
+ XFree(tpr.value);
return -1;
}
+ XFree(tpr.value);
if (num_wstrs == 0)
return 0;
wstr_src = wstrs[0];
diff --git a/gdk/x11/gdkimage-x11.c b/gdk/x11/gdkimage-x11.c
index d2e66803d1..7dae0d92ee 100644
--- a/gdk/x11/gdkimage-x11.c
+++ b/gdk/x11/gdkimage-x11.c
@@ -251,14 +251,12 @@ gdk_image_new (GdkImageType type,
return NULL;
}
- gdk_error_code = 0;
- gdk_error_warnings = 0;
+ gdk_error_trap_push ();
XShmAttach (private->xdisplay, x_shm_info);
XSync (private->xdisplay, False);
- gdk_error_warnings = 1;
- if (gdk_error_code == -1)
+ if (gdk_error_trap_pop ())
{
/* this is the common failure case so omit warning */
XDestroyImage (private->ximage);
@@ -269,6 +267,7 @@ gdk_image_new (GdkImageType type,
g_free (image);
gdk_use_xshm = False;
+
return NULL;
}
@@ -315,22 +314,7 @@ gdk_image_new (GdkImageType type,
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;
- }
+ image->bpp = (private->ximage->bits_per_pixel + 7) / 8;
}
}
diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c
index e907f04adb..de1d55ea8c 100644
--- a/gdk/x11/gdkmain-x11.c
+++ b/gdk/x11/gdkmain-x11.c
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
+#include <errno.h>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
@@ -48,6 +49,7 @@
#include "gdkinput.h"
#include "gdkx.h"
#include "gdki18n.h"
+#include "gdkkeysyms.h"
#ifndef X_GETTIMEOFDAY
#define X_GETTIMEOFDAY(tv) gettimeofday (tv, NULL)
@@ -333,6 +335,7 @@ gdk_init_check (int *argc,
gdk_im_set_best_style (GDK_IM_PREEDIT_POSITION);
else if (strcmp ("callbacks", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
+ (*argv)[i] = NULL;
}
}
else if (strcmp ("--xim-status", (*argv)[i]) == 0)
@@ -348,6 +351,7 @@ gdk_init_check (int *argc,
gdk_im_set_best_style (GDK_IM_STATUS_AREA);
else if (strcmp ("callbacks", (*argv)[i]) == 0)
gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
+ (*argv)[i] = NULL;
}
}
#endif
@@ -406,9 +410,9 @@ gdk_init_check (int *argc,
g_free(argv_orig[i]);
g_free(argv_orig);
- gdk_wm_delete_window = XInternAtom (gdk_display, "WM_DELETE_WINDOW", True);
- gdk_wm_take_focus = XInternAtom (gdk_display, "WM_TAKE_FOCUS", True);
- gdk_wm_protocols = XInternAtom (gdk_display, "WM_PROTOCOLS", True);
+ gdk_wm_delete_window = XInternAtom (gdk_display, "WM_DELETE_WINDOW", False);
+ gdk_wm_take_focus = XInternAtom (gdk_display, "WM_TAKE_FOCUS", False);
+ gdk_wm_protocols = XInternAtom (gdk_display, "WM_PROTOCOLS", False);
gdk_wm_window_protocols[0] = gdk_wm_delete_window;
gdk_wm_window_protocols[1] = gdk_wm_take_focus;
gdk_selection_property = XInternAtom (gdk_display, "GDK_SELECTION", False);
@@ -1032,20 +1036,35 @@ static int
gdk_x_error (Display *display,
XErrorEvent *error)
{
- char buf[64];
-
- if (gdk_error_warnings)
+ if (error->error_code)
{
- XGetErrorText (display, error->error_code, buf, 63);
- g_error ("%s\n serial %ld error_code %d request_code %d minor_code %d\n",
- buf,
- error->serial,
- error->error_code,
- error->request_code,
- error->minor_code);
+ if (gdk_error_warnings)
+ {
+ char buf[64];
+
+ XGetErrorText (display, error->error_code, buf, 63);
+
+#ifdef G_ENABLE_DEBUG
+ g_error ("%s\n serial %ld error_code %d request_code %d minor_code %d\n",
+ buf,
+ error->serial,
+ error->error_code,
+ error->request_code,
+ error->minor_code);
+#else /* !G_ENABLE_DEBUG */
+ fprintf (stderr, "Gdk-ERROR **: %s\n serial %ld error_code %d request_code %d minor_code %d\n",
+ buf,
+ error->serial,
+ error->error_code,
+ error->request_code,
+ error->minor_code);
+
+ exit(1);
+#endif /* G_ENABLE_DEBUG */
+ }
+ gdk_error_code = error->error_code;
}
- gdk_error_code = -1;
return 0;
}
@@ -1071,8 +1090,27 @@ gdk_x_error (Display *display,
static int
gdk_x_io_error (Display *display)
{
- g_error ("an x io error occurred");
- return 0;
+ /* This is basically modelled after the code in XLib. We need
+ * an explicit error handler here, so we can disable our atexit()
+ * which would otherwise cause a nice segfault.
+ * We fprintf(stderr, instead of g_warning() because g_warning()
+ * could possibly be redirected to a dialog
+ */
+ if (errno == EPIPE)
+ {
+ fprintf (stderr, "Gdk-ERROR **: X connection to %s broken (explicit kill or server shutdown).\n", gdk_display ? DisplayString (gdk_display) : gdk_get_display());
+ }
+ else
+ {
+ fprintf (stderr, "Gdk-ERROR **: Fatal IO error %d (%s) on X server %s.\n",
+ errno, g_strerror (errno),
+ gdk_display ? DisplayString (gdk_display) : gdk_get_display());
+ }
+
+ /* Disable the atexit shutdown for GDK */
+ gdk_initialized = 0;
+
+ exit(1);
}
gchar *
@@ -1104,7 +1142,7 @@ gdk_error_trap_push (void)
}
else
{
- node = g_slist_alloc();
+ node = g_slist_alloc ();
node->data = g_new (GdkErrorTrap, 1);
}
@@ -1166,7 +1204,7 @@ gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
XSync (gdk_display, False);
gdk_error_warnings = old_warnings;
- return result && (gdk_error_code != -1);
+ return result && !gdk_error_code;
}
#ifndef HAVE_XCONVERTCASE
diff --git a/gdk/x11/gdkpixmap-x11.c b/gdk/x11/gdkpixmap-x11.c
index 22e5a07867..6fc47e316e 100644
--- a/gdk/x11/gdkpixmap-x11.c
+++ b/gdk/x11/gdkpixmap-x11.c
@@ -518,7 +518,7 @@ _gdk_pixmap_create_from_xpm (GdkWindow *window,
color_name = gdk_pixmap_extract_color (buffer);
- if (color_name == NULL ||
+ if (color_name == NULL || g_strcasecmp (color_name, "None") == 0 ||
gdk_color_parse (color_name, &color->color) == FALSE)
{
color->color = *transparent_color;
@@ -817,7 +817,8 @@ void
gdk_pixmap_unref (GdkPixmap *pixmap)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap;
- g_return_if_fail(pixmap != NULL);
+ g_return_if_fail (pixmap != NULL);
+ g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)
diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c
index 5663352460..7973d8fc7e 100644
--- a/gdk/x11/gdkproperty-x11.c
+++ b/gdk/x11/gdkproperty-x11.c
@@ -45,15 +45,16 @@ gdk_atom_intern (const gchar *atom_name,
{
retval = XInternAtom (gdk_display, atom_name, only_if_exists);
- g_hash_table_insert (atom_hash,
- g_strdup (atom_name),
- GUINT_TO_POINTER (retval));
+ if (retval != None)
+ g_hash_table_insert (atom_hash,
+ g_strdup (atom_name),
+ GUINT_TO_POINTER (retval));
}
return retval;
}
-gchar *
+gchar*
gdk_atom_name (GdkAtom atom)
{
gchar *t;
@@ -69,7 +70,7 @@ gdk_atom_name (GdkAtom atom)
t = XGetAtomName (gdk_display, atom);
gdk_error_warnings = old_error_warnings;
- if (gdk_error_code == -1)
+ if (gdk_error_code)
{
if (t)
XFree (t);
@@ -162,10 +163,10 @@ gdk_property_get (GdkWindow *window,
ret_length = ret_nitems;
break;
case 16:
- ret_length = 2 * ret_nitems;
+ ret_length = sizeof(short) * ret_nitems;
break;
case 32:
- ret_length = 4 * ret_nitems;
+ ret_length = sizeof(long) * ret_nitems;
break;
default:
g_warning ("unknown property return format: %d", ret_format);
diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c
index 64a18d0424..3ee2e43b3d 100644
--- a/gdk/x11/gdkselection-x11.c
+++ b/gdk/x11/gdkselection-x11.c
@@ -105,11 +105,11 @@ gdk_selection_property_get (GdkWindow *requestor,
gulong length;
GdkAtom prop_type;
gint prop_format;
- guchar *t;
+ guchar *t = NULL;
g_return_val_if_fail (requestor != NULL, 0);
- /* If retrieved chunks are typically small, (and the ICCM says the
+ /* If retrieved chunks are typically small, (and the ICCCM 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 */
@@ -133,11 +133,11 @@ gdk_selection_property_get (GdkWindow *requestor,
*data = NULL;
return 0;
}
-
+
if (t)
{
- t = NULL;
XFree (t);
+ t = NULL;
}
/* Add on an extra byte to handle null termination. X guarantees
@@ -188,7 +188,7 @@ gdk_selection_send_notify (guint32 requestor,
xevent.property = property;
xevent.time = time;
- XSendEvent (gdk_display, requestor, False, NoEventMask, (XEvent*) &xevent);
+ gdk_send_xevent (requestor, False, NoEventMask, (XEvent*) &xevent);
}
gint
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 93fd0a4a7d..47b200c3e4 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -34,17 +34,9 @@
#include "gdkprivate.h"
#include "MwmUtil.h"
-#if HAVE_CONFIG_H
-# include <config.h>
-# if STDC_HEADERS
-# include <stdlib.h>
-# include <stdio.h>
-# include <string.h>
-# endif
-#else
-# include <stdlib.h>
-# include <stdio.h>
-#endif
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
#ifdef HAVE_SHAPE_EXT
@@ -707,10 +699,10 @@ gdk_window_destroy_notify (GdkWindow *window)
if (!private->destroyed)
{
- if (private->window_type == GDK_WINDOW_FOREIGN)
- gdk_window_internal_destroy (window, FALSE, FALSE);
- else
+ if (private->window_type != GDK_WINDOW_FOREIGN)
g_warning ("GdkWindow %#lx unexpectedly destroyed", private->xwindow);
+
+ gdk_window_internal_destroy (window, FALSE, FALSE);
}
gdk_xid_table_remove (private->xwindow);
@@ -732,6 +724,7 @@ gdk_window_unref (GdkWindow *window)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)window;
g_return_if_fail (window != NULL);
+ g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)
@@ -1089,8 +1082,10 @@ gdk_window_set_hints (GdkWindow *window,
size_hints.max_height = max_height;
}
- if (flags)
- XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints);
+ /* FIXME: Would it be better to delete this property of
+ * flags == 0? It would save space on the server
+ */
+ XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints);
}
void
@@ -1110,7 +1105,15 @@ gdk_window_set_geometry_hints (GdkWindow *window,
size_hints.flags = 0;
if (geom_mask & GDK_HINT_POS)
- size_hints.flags |= PPosition;
+ {
+ size_hints.flags |= PPosition;
+ /* We need to initialize the following obsolete fields because KWM
+ * apparently uses these fields if they are non-zero.
+ * #@#!#!$!.
+ */
+ size_hints.x = 0;
+ size_hints.y = 0;
+ }
if (geom_mask & GDK_HINT_MIN_SIZE)
{
@@ -1145,28 +1148,30 @@ gdk_window_set_geometry_hints (GdkWindow *window,
size_hints.flags |= PAspect;
if (geometry->min_aspect <= 1)
{
- size_hints.min_aspect.x = G_MAXINT * geometry->min_aspect;
- size_hints.min_aspect.y = G_MAXINT;
+ size_hints.min_aspect.x = 65536 * geometry->min_aspect;
+ size_hints.min_aspect.y = 65536;
}
else
{
- size_hints.min_aspect.x = G_MAXINT;
- size_hints.min_aspect.y = G_MAXINT / geometry->min_aspect;;
+ size_hints.min_aspect.x = 65536;
+ size_hints.min_aspect.y = 65536 / geometry->min_aspect;;
}
if (geometry->max_aspect <= 1)
{
- size_hints.max_aspect.x = G_MAXINT * geometry->max_aspect;
- size_hints.max_aspect.y = G_MAXINT;
+ size_hints.max_aspect.x = 65536 * geometry->max_aspect;
+ size_hints.max_aspect.y = 65536;
}
else
{
- size_hints.max_aspect.x = G_MAXINT;
- size_hints.max_aspect.y = G_MAXINT / geometry->max_aspect;;
+ size_hints.max_aspect.x = 65536;
+ size_hints.max_aspect.y = 65536 / geometry->max_aspect;;
}
}
-
- if (geom_mask)
- XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints);
+
+ /* FIXME: Would it be better to delete this property of
+ * geom_mask == 0? It would save space on the server
+ */
+ XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints);
}
void