From b50a9f760b38081e06559e3baf229fc0bb8ef3d5 Mon Sep 17 00:00:00 2001 From: Elliot Lee Date: Fri, 28 Nov 1997 06:47:01 +0000 Subject: [PATCH] Misc fixes for color changing stuff --- gdk/gdk.c | 11 ++++++++--- gdk/x11/gdkmain-x11.c | 11 ++++++++--- gtk/gtkstyle.c | 5 ++--- gtk/gtkwidget.c | 37 +++++++++++++++++++++++++------------ gtk/gtkwindow.c | 12 ++++++++---- 5 files changed, 51 insertions(+), 25 deletions(-) diff --git a/gdk/gdk.c b/gdk/gdk.c index 8c2aa54c33..f787e59cdf 100644 --- a/gdk/gdk.c +++ b/gdk/gdk.c @@ -2488,9 +2488,13 @@ gdk_event_translate (GdkEvent *event, event->client.data_format = xevent->xclient.format; memcpy(&event->client.data, &xevent->xclient.data, sizeof(event->client.data)); - return_val = TRUE; + if(window) + return_val = TRUE; + else + return_val = FALSE; } - return_val = return_val && !window_private->destroyed; + if(window_private) + return_val = return_val && !window_private->destroyed; break; case MappingNotify: @@ -3385,12 +3389,13 @@ getchildren (Display *dpy, &after, &data); if (type != 0) inf = children[i]; + XFree(data); } for (i = 0; !inf && (i < nchildren); i++) inf = getchildren (dpy, children[i], WM_STATE); - if (children != 0) + if (children != None) XFree ((char *) children); return inf; diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index 8c2aa54c33..f787e59cdf 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -2488,9 +2488,13 @@ gdk_event_translate (GdkEvent *event, event->client.data_format = xevent->xclient.format; memcpy(&event->client.data, &xevent->xclient.data, sizeof(event->client.data)); - return_val = TRUE; + if(window) + return_val = TRUE; + else + return_val = FALSE; } - return_val = return_val && !window_private->destroyed; + if(window_private) + return_val = return_val && !window_private->destroyed; break; case MappingNotify: @@ -3385,12 +3389,13 @@ getchildren (Display *dpy, &after, &data); if (type != 0) inf = children[i]; + XFree(data); } for (i = 0; !inf && (i < nchildren); i++) inf = getchildren (dpy, children[i], WM_STATE); - if (children != 0) + if (children != None) XFree ((char *) children); return inf; diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index ae8c1a5d9f..5f490c8a54 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -18,6 +18,7 @@ #include #include "gtkgc.h" #include "gtkstyle.h" +#include "gtkwidget.h" #define LIGHTNESS_MULT 1.3 @@ -296,9 +297,8 @@ gtk_style_detach (GtkStyle *style) style->depth = -1; style->colormap = NULL; + gtk_style_remove (style); } - - gtk_style_remove (style); } GtkStyle* @@ -600,7 +600,6 @@ gtk_style_remove (GtkStyle *style) { if (initialize) gtk_styles_init (); - g_cache_remove (style_cache, style); } diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 4c0250377a..7cf35547ea 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -75,6 +75,7 @@ enum { DROP_LEAVE_EVENT, DROP_DATA_AVAILABLE_EVENT, OTHER_EVENT, + CLIENT_EVENT, LAST_SIGNAL }; @@ -577,7 +578,15 @@ gtk_widget_class_init (GtkWidgetClass *klass) gtk_widget_marshal_signal_4, GTK_TYPE_BOOL, 1, GTK_TYPE_GDK_EVENT); - + widget_signals[CLIENT_EVENT] = + gtk_signal_new ("client_event", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (GtkWidgetClass, client_event), + gtk_widget_marshal_signal_4, + GTK_TYPE_BOOL, 1, + GTK_TYPE_GDK_EVENT); + gtk_object_class_add_signals (object_class, widget_signals, LAST_SIGNAL); object_class->destroy = gtk_real_widget_destroy; @@ -1499,6 +1508,9 @@ gtk_widget_event (GtkWidget *widget, case GDK_OTHER_EVENT: signal_num = OTHER_EVENT; break; + case GDK_CLIENT_EVENT: + signal_num = CLIENT_EVENT; + break; default: g_warning ("could not determine signal number for event: %d", event->type); return return_val; @@ -2482,14 +2494,15 @@ gtk_widget_propagate_default_style (void) int i; /* Set the property on the root window */ - gdk_property_change (GDK_ROOT_PARENT(), - gdk_atom_intern("_GTK_DEFAULT_COLORS", FALSE), - GDK_NONE, 8*sizeof(gushort), - GDK_PROP_MODE_REPLACE, - (guchar *)gtk_widget_get_default_style(), - GTK_STYLE_NUM_STYLECOLORS() * sizeof(GdkColor)); - - for (i = 0; i < 5; i++) + gdk_property_change(GDK_ROOT_PARENT(), + gdk_atom_intern("_GTK_DEFAULT_COLORS", FALSE), + gdk_atom_intern("STRING", FALSE), + 8*sizeof(gushort), + GDK_PROP_MODE_REPLACE, + (guchar *)gtk_widget_get_default_style(), + GTK_STYLE_NUM_STYLECOLORS() * sizeof(GdkColor)); + + for(i = 0; i < 5; i++) sev.data.l[i] = 0; sev.data_format = 32; sev.message_type = gdk_atom_intern ("_GTK_STYLE_CHANGED", FALSE); @@ -2840,9 +2853,9 @@ gtk_real_widget_unrealize (GtkWidget *widget) { g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); - - GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED | GTK_MAPPED); - + + GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED | GTK_MAPPED | GTK_VISIBLE); + gtk_style_detach (widget->style); if (!GTK_WIDGET_NO_WINDOW (widget)) { diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 8ae112adf8..90cfc844b9 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -841,16 +841,20 @@ gtk_window_style_set_event (GtkWidget *widget, if(gdk_property_get (GDK_ROOT_PARENT(), atom_default_colors, - GDK_NONE, + gdk_atom_intern("STRING", FALSE), 0, sizeof(GdkColor) * GTK_STYLE_NUM_STYLECOLORS(), FALSE, &realtype, &retfmt, &retlen, - (guchar **)&data) != TRUE - || retfmt != sizeof(gushort)) { - g_warning("gdk_property_get() failed in _GTK_STYLE_CHANGED\n"); + (guchar **)&data) != TRUE) { + g_warning("gdk_property_get() failed in _GTK_STYLE_CHANGED handler\n"); + return; + } + if(retfmt != sizeof(gushort)*8) { + g_warning("retfmt (%d) != sizeof(gushort)*8 (%d)\n", retfmt, + sizeof(gushort)*8); return; } /* We have the color data, now let's interpret it */