diff options
author | Federico Mena Quintero <federico@redhat.com> | 1999-09-28 20:19:13 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1999-09-28 20:19:13 +0000 |
commit | 95b3f3e46016e4993e60e8c139bfd03a106201ba (patch) | |
tree | b029a3211a1cfc14ec11507e3cce8c5be0657f60 /gdk/x11 | |
parent | c3e01fe599d7f6d7cb313545f9c136afb6a9fd68 (diff) | |
download | gtk+-95b3f3e46016e4993e60e8c139bfd03a106201ba.tar.gz |
[ Merges from gtk-1-2 ]
Wed Sep 8 07:13:29 1999 Tim Janik <timj@gtk.org>
* configure.in: fixed "GNU Make" check to pass with new make version
3.77.95.
Fri Sep 3 16:04:41 1999 Tim Janik <timj@gtk.org>
* gtk-config.in (--version): don't echo @GTK_VERSION@, but
@GTK_MAJOR_VERSION@.@GTK_MINOR_VERSION@.@GTK_MICRO_VERSION@, so the
AM_PATH_GTK() macros don't get confused by the -pre1.
Thu Sep 2 19:02:37 1999 Owen Taylor <otaylor@redhat.com>
* configure.in (REBUILD): Change check for perl5
to check explicitely for v >= 5.002. (5.001
does not work with our scripts.)
Wed Aug 25 15:45:46 1999 Tim Janik <timj@gtk.org>
* configure.in: evaluate $PERL for the perl version check. added
--disable-rebuilds to give the user an option to completely disable
any source autogeneration rules.
Mon Aug 23 23:16:14 1999 Tim Janik <timj@gtk.org>
* configure.in: evaluate $ac_make when checking for GNU Make.
Mon Aug 23 19:11:17 1999 Tim Janik <timj@gtk.org>
* docs/Makefile.am: added generation.txt.
* Makefile.am: require automake 1.4, build README from README.in and
INSTALL from INSTALL.in in dist-hook.
* README.in:
* INSTALL.in: new files to autogenerate README and INSTALL from.
* configure.in: figure whether we have GNU Make
* docs/generation.txt: minor additions/corrections.
Wed Aug 11 13:38:26 BST 1999 Tony Gale <gale@gtk.org>
* docs/gtkfaq.sgml: FAQ Update
July 30, 1999 Elliot Lee <sopwith@redhat.com>
* configure.in: Fix autoconf warnings about cross compilation by
trying to provide sane defaults for AC_TRY_RUN.
Fri Jul 16 22:20:21 PDT 1999 Manish Singh <yosh@gimp.org>
* ltconfig
* ltmain.sh: upgrade to libtool 1.3.3
Thu Jul 8 11:30:18 1999 Owen Taylor <otaylor@redhat.com>
* INSTALL: Indicate that the --with-glib= configure
time flag is unsupported.
Mon Jul 5 20:36:03 1999 Owen Taylor <otaylor@redhat.com>
* docs/generation.txt: Added a file that gives
documenation about the autogeneration process for
various autogenerated files.
Tue Jun 29 15:59:25 1999 Owen Taylor <otaylor@redhat.com>
* configure.in (LIBS): Look for libgmodule in the
right location.
Thu Jun 17 13:57:31 1999 Owen Taylor <otaylor@redhat.com>
* docs/gtk_tut.sgml: Removed references to
code examples in my directory on gtk.org as
they should all be in the tutorial now.
* docs/gtk_tut.sgml: Added sources for dial-test
and scribble-xinput programs that were previously
missing.
Fri Jun 4 00:08:59 1999 Owen Taylor <otaylor@redhat.com>
* TODO: Added entry about menu keyboard navigation, removed
some finished items.
Mon May 31 00:11:24 1999 Owen Taylor <otaylor@redhat.com>
* acinclude.m4: Standardize on func_dgettext
not func_gettext, so that the checks for dgettext
actually are paid attention to.
Wed May 5 10:47:54 1999 Owen Taylor <otaylor@redhat.com>
* configure.in (LIBS): Add $INTLLIBS into $LIBS
directly, rather than repeating the checks for
gettext.
* INSTALL: Added information about gettext and
NLS support.
* acinclude.m4 (LIBM): Check for dgettext, not
just gettext. This should hopefully fix things wrt
systems with old versions of GNU gettext installed.
Tue Jun 29 15:59:25 1999 Owen Taylor <otaylor@redhat.com>
* configure.in (LIBS): Look for libgmodule in the
right location.
Thu Apr 1 16:58:10 PST 1999 Manish Singh <yosh@gimp.org>
* autogen.sh: add --enable-maintainer-mode
* configure.in: set ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
Wed Mar 24 23:03:49 CST 1999 Shawn T. Amundson <amundson@gtk.org>
* docs/gtk-config.1.in:
docs/Makefile.am:
configure.in: gtk-config is now generated.
* docs/gtk-config.1: Removed, now generated.
Thu Sep 23 17:59:59 1999 Tim Janik <timj@gtk.org>
* gdk/gdkevents.c (gdk_event_translate): grr, even if Gdk doesn't
handle CreateNotify itself, still put out a debuging message for
--gdk-debug=events. made the ReparentNotify debugging message more
verbose.
wrap xcoords translation for ConfigureEvents into an error trap,
a destroy event may already be pending, and in that case, the
actuall coordinate values are not at all critical.
Sat Sep 18 22:24:15 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcc.c: Stop leaking the color_hash all over
the place. Simplify and improve the logic.
Fri Sep 17 09:57:15 1999 Tim Janik <timj@gtk.org>
* gdk/gdk.h, gdk/gdkcolor.c: make return types (gint or gboolean)
for prototypes and function implementations consistent (reported
by Tomas Ogren).
Tue Sep 14 18:23:01 1999 Tim Janik <timj@gtk.org>
* gdk/gdkevents.c (gdk_event_translate): tell if expose events have
send_event set in debugging output.
(gdk_compress_exposures): default initialize the event so we don't
operate on bogus values (namely send_event).
Thu Sep 2 16:33:59 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c: When we receive an unexpected
destroy notify on one of our windows, don't just
warn about it, also mark our windows as destroyed.
Sun Sep 5 08:10:53 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkfont.c (gdk_font_hash_insert): Add
name => font and name => fontset hashes. The
name => fontset hash is a _big_ win since we
weren't previously caching fontsets at all and loading
fontsets is expensive. The name => font hash
is less of a win, but it does save us from doing
repeated XQueryFont calls on the same font.
* gdk/gdkprivate.h (struct _GdkFontPrivate): Add a names
list so we can remove font/fontset from hash.
Thu Sep 2 19:02:37 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkproperty.c (gdk_atom_intern): Remove useless
and slightly confusing test. [ XInternAtom (,,TRUE)
will never return None ].
Sat Sep 4 08:39:26 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_set_geometry_hints)
gdk/gdkwindow.c (gdk_window_set_hints):
Don't omit setting the properties if flags == 0 -
there may be an existing set of properties there
already. (Very old bug. Would it be better to
delete the property instead?)
* gdk/gdkselection.c (gdk_selection_property_get): Fix
spelling error in comment.
Wed Sep 1 14:05:30 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkimage.c (gdk_image_new): Use gdk_error_trap_push()
to avoid stomping over gdk_error_warnings.
* gdk/gdkimage.c (gdk_image_new): compute image->bpp
as (bits_per_pixel + 7) / 8. This gives the same
result as before for multiples of 8, but actually
a "reasonable" value for 1bit or 4bit displays.
Mon Aug 23 19:11:17 1999 Tim Janik <timj@gtk.org>
* gdk/Makefile.am: minor cleanups, strip spaces on build rules for
GNU Make.
Tue Aug 17 07:43:04 1999 Tim Janik <timj@gtk.org>
* gdk/gdkevents.c (gdk_event_translate): give a debugging note when
discarding configure events.
1999-08-18 Federico Mena Quintero <federico@redhat.com>
* gdk/gdkpixmap.c (gdk_pixmap_unref): g_return_if_fail() the
refcount is greater than zero.
* gdk/gdkwindow.c (gdk_window_unref): Likewise.
* gdk/gdkfont.c (gdk_font_unref): Likewise.
* gdk/gdkgc.c (gdk_gc_unref): Likewise.
* gdk/gdkdnd.c (gdk_drag_context_unref): Likewise.
Wed Aug 11 01:04:57 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkproperty.c (gdk_property_get): Fix assumption
that format 32 => sizeof(item) == 4. It really is
sizeof(long).
Tue Jun 29 23:02:42 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.c (gdk_x_error / gdk_x_io_error): Don't
core dump at all on X IO errors, only core dump
if --enable-debug for X errors.
Thu Jun 24 17:06:23 1999 Tim Janik <timj@gtk.org>
* gdk/gdkevents.c (gdk_event_translate): removed old ""Got event for
unknown window:" message. disabled ConfigureNotify discarding code,
because it led to events being processed out of order.
Thu Jun 24 12:22:02 1999 Tim Janik <timj@gtk.org>
* gdk/gdkglobals.c: preinitialize gdk_error_code to 0.
* gdk/gdkevents.c (gdk_event_send_client_message_to_all_recurse): since
we export this function, supress error warnings and don't reset the
error code in the first half of this function.
* gdk/gdk.c (gdk_x_error): set gdk_error_code to the actuall X error
code (instead of just -1) so gdk_error_trap_pop() reveals something
actually informative about the error that happened.
* gdk/*.c:
don't rely on gdk_error_code being -1 if an error occoured, but just
gdk_error_code != 0.
Thu Jun 24 11:50:07 1999 Tim Janik <timj@gtk.org>
* gdk/gdkevents.c (gdk_event_apply_filters): advance the filter list
pointer *before* invoking the filter function, so we at least don't
crash if a filter is removed that is currently executed. window filters
*really* need to be made truely reentrant at some point.
Mon Jun 14 11:10:15 1999 Tim Janik <timj@gtk.org>
* gdk/gdkevents.c (gdk_event_translate): print the atom name in the
PropertyNotify debug messages.
Wed May 5 22:51:06 1999 Owen Taylor <otaylor@redhat.com>
Patch from Sung-Hyun Nam <namsh@lgic.co.kr>
* gdk/gdkim.c: Fix cut-and-paste errors for
x/y and PreeditAttributes/StatusAttributes.
Wed May 5 22:24:21 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_set_geometry_hints): Change
G_MAXINT to 2^16 to alleviate overflow problems in
various window managers.
Wed Apr 21 00:42:08 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkfont.c (gdk_text_measure): Fix the return value
for fontsets.
Wed May 5 12:42:01 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_set_geometry_hints):
Initialize size_hints.x and size_hints.y because kwm
brokenly pays attention to them.
(Bug #1181 - Lars Heete <hel@admin.de>)
Wed May 5 11:38:56 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkrgb.c (gdk_rgb_choose_visual): Free the
return value of gdk_list_visuals().
(Bug #1193 - Morten Welinder <terra@diku.dk>)
Tue May 4 11:12:56 PDT 1999 Manish Singh <yosh@gimp.org>
* gdk/gdkim.c (gdk_im_real_open): cast the return value of
XSetIMValues to (void *) when comparing to NULL, to workaround
the problem of some compilers barfing since older X headers don't
have the prototype for it.
Mon Apr 19 10:11:12 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcolor.c (gdk_colormap_new): Fix memory leak
for pseudocolor where colormap->colors was double
allocated.
* gdk/gdkcolor.c (gdk_colormap_alloc1): Store the
color value in the hash table with the pixel filled
in so when we do later hash table lookups, the color
value is correct.
Sun May 2 15:29:45 PDT 1999 Manish Singh <yosh@gimp.org>
* gdk/gdkdraw.c (gdk_draw_lines): check private->destroyed before
making the call
Tue Apr 27 11:17:35 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdnd.c (xdnd_set_{targets,actions}): Fix leak
pointed out by Morten Welinder <terra@diku.dk>.
Wed Apr 21 14:20:22 1999 George Lebl <jirka@5z.com>
* gdk/gdkwindow.c: (gdk_window_remove_filter) correctly remove the
default filter from the list
Wed Apr 21 14:20:22 1999 George Lebl <jirka@5z.com>
* gdk/gdkwindow.c: (gdk_window_remove_filter) correctly remove the
default filter from the list
Fri Apr 16 20:41:43 PDT 1999 Manish Singh <yosh@gimp.org>
* gdk/gdk.c: #include "gdkkeysyms.h" for gdk_XConvertCase #defines
* gtk/gtkfontsel.c (gtk_font_selection_create_xlfd): use
g_strdup_printf instead of calcing the length separately
Tue Apr 13 02:49:33 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c: removed some silly #ifdef HAVE_CONFIG
that we don't do in many other places. (Fixing duplicate
#include of config.h)
* gdk/gdkevents.c: include gdkinput.h _after_ config.h.
Otherwise, #ifndef XINPUT_NONE check in the latter
doesn't work. (Bug #546)
Sun Apr 11 14:38:03 1999 Tim Janik <timj@gtk.org>
* gdk/gdkpixmap.c (_gdk_pixmap_create_from_xpm): check for color
"None" case insensitive.
Tue Apr 6 16:38:51 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkselection.c:
Add error traps so if the other end of the connection
dies, we survive.
Tue Apr 6 12:24:21 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdnd.c (gdk_drag_motion): Separate out the
dest_xid field into two fields - one for the window
to send in messages, one to indicate the last looked
up window for caching purposes. This is needed, so
that Leave messages get the correct window.
Mon Apr 5 13:21:30 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.c (gdk_event_check, gdk_event_prepare):
Fix warning created by people mucking around
with the gsource API.
* gdk/gdkevents.c (gdk_io_invoke, gdk_input_add_full):
Change mapping between GIOCondition and GdkInputCondition
to match the way the Linux kernel does it. This should
fix problems where closed pipes were no longer signalling
GDK_INPUT_READ on systems with a native poll().
Mon Apr 5 17:11:57 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkpixmap.c (_gdk_pixmap_create_from_xpm): Check
explicitly for the string "None" - it is in the XPM
spec and some servers treat unknown colors in odd ways
(like asking the user!)
Thu Apr 1 16:58:10 PST 1999 Manish Singh <yosh@gimp.org>
* gdk/gdkevents.c: made "->" into a "." of previous change so
it compiles
Thu Apr 1 18:41:25 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.c (gdk_compress_exposures): Set the
window field of the event structure before calling
user filters.
1999-03-31 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gdk/gdk.c (gdk_init_check): Use False as the last argument to
XInternAtom() here. This is a particularly Old And Nasty(tm) bug.
Mon Mar 29 17:31:52 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkim.c (gdk_mbstowcs): Free the value of the
intermediate text property - prevents major memory
leak when gdk_use_mb.
gtk-d3august-990311-0: Bj|rn Augustsson <d3august@dtek.chalmers.se>
Mon Mar 29 17:02:58 1999 Owen Taylor <otaylor@redhat.com>
Patches from Akira Higuchi <a-higuti@math.sci.hokudai.ac.jp>
gtk-a-higuti-990322-[0-3]
* gdk/gdkfont.c (gdk_text_extents_wc): Make work when
sizeof(wchar_t) != sizeof (GdkWChar)
* configure.in: Fix confusion between GTK_LOCALE_[C]FLAGS
that was causing -DX_LOCALE not to work.
* gtk/gtkrc.c (gtk_rc_init):
X_LOCALE will never have LC_MESSAGES defined
* gdk/gdk.c (gdk_init_check):
Remove --xim-preedit and --xim-status from argv properly.
* gdk/gdkim.c (gdk_ic_real_new): Add a gdk_flush() so
that the client window is present on the X server
before we pass it to the input method.
Tue Mar 9 10:46:49 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdnd.c (motif_find_drag_window): Fix bug where
if --display is specified on the command line, than
the drag window will not be created on that display.
Tue Mar 9 10:38:24 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkproperty.c (gdk_atom_intern): Fixed bug where
lookups with only_if_exists == TRUE were inserting
bogus values into the atom cache.
Wed Mar 17 09:00:00 1999 Tim Janik <timj@gtk.org>
* gdk/gdkselection.c (gdk_selection_property_get): first XFree(t),
then reset it to NULL.
* gdk/gdkcolor.c:
(gdk_colors_free):
(gdk_colormap_free_colors): use colormap->colors[in_pixels[i]] as the
key for g_hash_table_remove() in both functions, this prevents us
from accessing possibly uninitialized portions of a GdkColor structure
where we are only interested in its pixel value.
Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org>
* gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our
font hash table, if we have a GdkFontPrivate entry for this font
already, simply increment its reference count, provided by Olaf Dietsche
<olaf.dietsche+list.gtk@netcologne.de>.
1999-09-21 Tor Lillqvist <tml@iki.fi>
Diffstat (limited to 'gdk/x11')
-rw-r--r-- | gdk/x11/gdkcc-x11.c | 50 | ||||
-rw-r--r-- | gdk/x11/gdkcolor-x11.c | 207 | ||||
-rw-r--r-- | gdk/x11/gdkdnd-x11.c | 76 | ||||
-rw-r--r-- | gdk/x11/gdkevents-x11.c | 197 | ||||
-rw-r--r-- | gdk/x11/gdkfont-x11.c | 107 | ||||
-rw-r--r-- | gdk/x11/gdkglobals-x11.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdkim-x11.c | 30 | ||||
-rw-r--r-- | gdk/x11/gdkimage-x11.c | 24 | ||||
-rw-r--r-- | gdk/x11/gdkmain-x11.c | 74 | ||||
-rw-r--r-- | gdk/x11/gdkpixmap-x11.c | 5 | ||||
-rw-r--r-- | gdk/x11/gdkproperty-x11.c | 15 | ||||
-rw-r--r-- | gdk/x11/gdkselection-x11.c | 10 | ||||
-rw-r--r-- | gdk/x11/gdkwindow-x11.c | 61 |
13 files changed, 495 insertions, 363 deletions
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) ▭ - 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) ▭ - 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 |