delete event handling




This is a change for 1.4 discussed with Owen; basically it drops
delete_event if there's a grab held by a widget other than the window
receiving the delete_event. The patch lacks get_arg()/set_arg()
support, it would need that before commit.

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.1061.2.224
diff -u -u -r1.1061.2.224 ChangeLog
--- ChangeLog	2000/01/27 21:10:42	1.1061.2.224
+++ ChangeLog	2000/01/27 23:58:52
@@ -1,3 +1,15 @@
+2000-01-28  Havoc Pennington  <hp@redhat.com>
+
+	* gtk/gtkwindow.h (struct _GtkWindow): add a flag to turn off
+	the delete-event-dropping
+
+	* gtk/gtkwindow.c (gtk_window_set_never_drop_delete_event):
+	Function to turn off the new drop-delete-if-grab-exists behavior
+
+	* gtk/gtkmain.c (gtk_main_do_event): if some other widget has the
+	grab, don't send delete_event to windows, unless the window has 
+	the never_drop_delete_event flag set.
+
 2000-01-25  Havoc Pennington  <hp@pobox.com>
 	
 	* gdk/gdkwindow.c (gdk_window_set_back_pixmap): parent_relative
Index: gtk/gtkwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwindow.c,v
retrieving revision 1.75.2.21
diff -u -u -r1.75.2.21 gtkwindow.c
--- gtk/gtkwindow.c	1999/10/23 01:32:26	1.75.2.21
+++ gtk/gtkwindow.c	2000/01/27 23:58:52
@@ -274,6 +274,7 @@
   window->position = GTK_WIN_POS_NONE;
   window->use_uposition = TRUE;
   window->modal = FALSE;
+  window->never_drop_delete_event = FALSE;
   
   gtk_container_register_toplevel (GTK_CONTAINER (window));
 }
@@ -638,6 +639,16 @@
   
       gdk_window_move (GTK_WIDGET (window)->window, x, y);
     }
+}
+
+void
+gtk_window_set_never_drop_delete_event (GtkWindow        *window,
+                                        gboolean          setting)
+{
+  g_return_if_fail (window != NULL);
+  g_return_if_fail (GTK_IS_WINDOW (window));
+
+  window->never_drop_delete_event = setting;
 }
 
 static void
Index: gtk/gtkwindow.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwindow.h,v
retrieving revision 1.18.2.1
diff -u -u -r1.18.2.1 gtkwindow.h
--- gtk/gtkwindow.h	1999/09/01 01:13:10	1.18.2.1
+++ gtk/gtkwindow.h	2000/01/27 23:58:52
@@ -77,6 +77,9 @@
    */
   guint use_uposition : 1;
   guint modal : 1;
+  /* by default, if there's a grab owned by another window
+     then delete event for windows is dropped */
+  guint never_drop_delete_event : 1;
 };
 
 struct _GtkWindowClass
@@ -138,6 +141,9 @@
 void       gtk_window_reposition               (GtkWindow           *window,
 						gint                 x,
 						gint                 y);
+
+void       gtk_window_set_never_drop_delete_event (GtkWindow        *window,
+                                                   gboolean          setting);
 
 #ifdef __cplusplus
 }
Index: gtk/gtkmain.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmain.c,v
retrieving revision 1.112.2.6
diff -u -u -r1.112.2.6 gtkmain.c
--- gtk/gtkmain.c	1999/09/03 20:08:13	1.112.2.6
+++ gtk/gtkmain.c	2000/01/27 23:58:52
@@ -677,11 +677,15 @@
       break;
       
     case GDK_DELETE:
-      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);
+      if (GTK_WINDOW(event_widget)->never_drop_delete_event ||
+          grab_widget == event_widget)
+        {
+          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_DESTROY:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]