From 22a15408bb997b4adef2bda4e26fad83c651c35f Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Fri, 3 Sep 1999 20:08:13 +0000 Subject: [PATCH] When we receive an unexpected destroy notify on one of our windows, don't Thu Sep 2 16:33:59 1999 Owen Taylor * 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. * gtk/gtkmain.c: Ignore unexpected destroy notifies for children, for toplevel windows handle them like delete_event. * gtk/gtkplug.c: Add an unrealize handler so that we unref plug->socket_window when we are done with it. --- ChangeLog | 14 ++++++++++++++ ChangeLog.pre-2-0 | 14 ++++++++++++++ ChangeLog.pre-2-10 | 14 ++++++++++++++ ChangeLog.pre-2-2 | 14 ++++++++++++++ ChangeLog.pre-2-4 | 14 ++++++++++++++ ChangeLog.pre-2-6 | 14 ++++++++++++++ ChangeLog.pre-2-8 | 14 ++++++++++++++ gdk/gdkwindow.c | 6 +++--- gdk/x11/gdkwindow-x11.c | 6 +++--- gtk/gtkmain.c | 16 +++++++++++----- gtk/gtkplug.c | 27 +++++++++++++++++++++++++++ 11 files changed, 142 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index a356e48e86..2cde777dc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Thu Sep 2 16:33:59 1999 Owen Taylor + + * 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. + + * gtk/gtkmain.c: Ignore unexpected destroy notifies + for children, for toplevel windows handle them + like delete_event. + + * gtk/gtkplug.c: Add an unrealize handler so that + we unref plug->socket_window when we are done + with it. + Fri Sep 3 14:52:54 1999 Owen Taylor * gtk/gtktext.c (clear_area): Fix stupid signedness diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index a356e48e86..2cde777dc4 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,17 @@ +Thu Sep 2 16:33:59 1999 Owen Taylor + + * 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. + + * gtk/gtkmain.c: Ignore unexpected destroy notifies + for children, for toplevel windows handle them + like delete_event. + + * gtk/gtkplug.c: Add an unrealize handler so that + we unref plug->socket_window when we are done + with it. + Fri Sep 3 14:52:54 1999 Owen Taylor * gtk/gtktext.c (clear_area): Fix stupid signedness diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index a356e48e86..2cde777dc4 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,17 @@ +Thu Sep 2 16:33:59 1999 Owen Taylor + + * 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. + + * gtk/gtkmain.c: Ignore unexpected destroy notifies + for children, for toplevel windows handle them + like delete_event. + + * gtk/gtkplug.c: Add an unrealize handler so that + we unref plug->socket_window when we are done + with it. + Fri Sep 3 14:52:54 1999 Owen Taylor * gtk/gtktext.c (clear_area): Fix stupid signedness diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index a356e48e86..2cde777dc4 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,17 @@ +Thu Sep 2 16:33:59 1999 Owen Taylor + + * 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. + + * gtk/gtkmain.c: Ignore unexpected destroy notifies + for children, for toplevel windows handle them + like delete_event. + + * gtk/gtkplug.c: Add an unrealize handler so that + we unref plug->socket_window when we are done + with it. + Fri Sep 3 14:52:54 1999 Owen Taylor * gtk/gtktext.c (clear_area): Fix stupid signedness diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index a356e48e86..2cde777dc4 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,17 @@ +Thu Sep 2 16:33:59 1999 Owen Taylor + + * 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. + + * gtk/gtkmain.c: Ignore unexpected destroy notifies + for children, for toplevel windows handle them + like delete_event. + + * gtk/gtkplug.c: Add an unrealize handler so that + we unref plug->socket_window when we are done + with it. + Fri Sep 3 14:52:54 1999 Owen Taylor * gtk/gtktext.c (clear_area): Fix stupid signedness diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index a356e48e86..2cde777dc4 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,17 @@ +Thu Sep 2 16:33:59 1999 Owen Taylor + + * 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. + + * gtk/gtkmain.c: Ignore unexpected destroy notifies + for children, for toplevel windows handle them + like delete_event. + + * gtk/gtkplug.c: Add an unrealize handler so that + we unref plug->socket_window when we are done + with it. + Fri Sep 3 14:52:54 1999 Owen Taylor * gtk/gtktext.c (clear_area): Fix stupid signedness diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index a356e48e86..2cde777dc4 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,17 @@ +Thu Sep 2 16:33:59 1999 Owen Taylor + + * 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. + + * gtk/gtkmain.c: Ignore unexpected destroy notifies + for children, for toplevel windows handle them + like delete_event. + + * gtk/gtkplug.c: Add an unrealize handler so that + we unref plug->socket_window when we are done + with it. + Fri Sep 3 14:52:54 1999 Owen Taylor * gtk/gtktext.c (clear_area): Fix stupid signedness diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 7c7680925e..47b200c3e4 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -699,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); diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 7c7680925e..47b200c3e4 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -699,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); diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 9c4186ad6a..2df9e5f2f0 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -685,11 +685,17 @@ gtk_main_do_event (GdkEvent *event) break; case GDK_DESTROY: - gtk_widget_ref (event_widget); - gtk_widget_event (event_widget, event); - if (!GTK_OBJECT_DESTROYED (event_widget)) - gtk_widget_destroy (event_widget); - gtk_widget_unref (event_widget); + /* Unexpected GDK_DESTROY from the outside, ignore for + * child windows, handle like a GDK_DELETE for toplevels + */ + if (!event_widget->parent) + { + gtk_widget_ref (event_widget); + if (!gtk_widget_event (event_widget, event) && + !GTK_OBJECT_DESTROYED (event_widget)) + gtk_widget_destroy (event_widget); + gtk_widget_unref (event_widget); + } break; case GDK_PROPERTY_NOTIFY: diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c index e2ad46ef9d..a679f2387d 100644 --- a/gtk/gtkplug.c +++ b/gtk/gtkplug.c @@ -33,6 +33,7 @@ static void gtk_plug_class_init (GtkPlugClass *klass); static void gtk_plug_init (GtkPlug *plug); static void gtk_plug_realize (GtkWidget *widget); +static void gtk_plug_unrealize (GtkWidget *widget); static gint gtk_plug_key_press_event (GtkWidget *widget, GdkEventKey *event); static void gtk_plug_forward_key_press (GtkPlug *plug, GdkEventKey *event); @@ -44,6 +45,8 @@ static void gtk_plug_set_focus (GtkWindow *window, /* From Tk */ #define EMBEDDED_APP_WANTS_FOCUS NotifyNormal+20 +static GtkWindowClass *parent_class = NULL; + guint gtk_plug_get_type () { @@ -77,7 +80,10 @@ gtk_plug_class_init (GtkPlugClass *class) widget_class = (GtkWidgetClass *)class; window_class = (GtkWindowClass *)class; + parent_class = gtk_type_class (gtk_window_get_type ()); + widget_class->realize = gtk_plug_realize; + widget_class->unrealize = gtk_plug_unrealize; widget_class->key_press_event = gtk_plug_key_press_event; widget_class->focus_in_event = gtk_plug_focus_in_event; widget_class->focus_out_event = gtk_plug_focus_out_event; @@ -119,6 +125,27 @@ gtk_plug_new (guint32 socket_id) return GTK_WIDGET (plug); } +static void +gtk_plug_unrealize (GtkWidget *widget) +{ + GtkPlug *plug; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_PLUG (widget)); + + plug = GTK_PLUG (widget); + + if (plug->socket_window != NULL) + { + gdk_window_set_user_data (plug->socket_window, NULL); + gdk_window_unref (plug->socket_window); + plug->socket_window = NULL; + } + + if (GTK_WIDGET_CLASS (parent_class)->unrealize) + (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); +} + static void gtk_plug_realize (GtkWidget *widget) {