Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.6705
diff -p -u -r1.6705 ChangeLog
--- ChangeLog	17 Jun 2005 14:17:42 -0000	1.6705
+++ ChangeLog	17 Jun 2005 21:27:23 -0000
@@ -1,3 +1,8 @@
+2005-06-17  William Jon McCann  <mccann@jhu.edu>
+
+	* tests/testsocket.c (grab_string, grab_window_toggled, main):
+	Add ability to test grabbed window case.
+
 2005-06-17  Owen Taylor  <otaylor@redhat.com>
 
 	* gdk/gdkcairo.c (gdk_cairo_set_source_pixbuf): Fix
Index: tests/testsocket.c
===================================================================
RCS file: /cvs/gnome/gtk+/tests/testsocket.c,v
retrieving revision 1.16
diff -p -u -r1.16 testsocket.c
--- tests/testsocket.c	28 Oct 2004 15:00:05 -0000	1.16
+++ tests/testsocket.c	17 Jun 2005 21:27:23 -0000
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */
+
 #undef GTK_DISABLE_DEPRECATED
 
 #include <config.h>
@@ -269,6 +271,45 @@ add_local_passive_child (GtkWidget *wind
   gtk_socket_add_id (GTK_SOCKET (socket->socket), xid);
 }
 
+static const char *
+grab_string (int status)
+{
+  switch (status) {
+  case GDK_GRAB_SUCCESS:          return "GrabSuccess";
+  case GDK_GRAB_ALREADY_GRABBED:  return "AlreadyGrabbed";
+  case GDK_GRAB_INVALID_TIME:     return "GrabInvalidTime";
+  case GDK_GRAB_NOT_VIEWABLE:     return "GrabNotViewable";
+  case GDK_GRAB_FROZEN:           return "GrabFrozen";
+  default:
+    {
+      static char foo [255];
+      sprintf (foo, "unknown status: %d", status);
+      return foo;
+    }
+  }
+}
+
+static void
+grab_window_toggled (GtkToggleButton *button,
+		     GtkWidget       *widget)
+{
+
+  if (gtk_toggle_button_get_active (button))
+    {
+      int status;
+
+      status = gdk_keyboard_grab (widget->window, FALSE, GDK_CURRENT_TIME);
+
+      if (status != GDK_GRAB_SUCCESS)
+	g_warning ("Could not grab keyboard!  (%s)", grab_string (status));
+
+    } 
+  else 
+    {
+      gdk_keyboard_ungrab (GDK_CURRENT_TIME);
+    }
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -276,6 +317,7 @@ main (int argc, char *argv[])
   GtkWidget *hbox;
   GtkWidget *vbox;
   GtkWidget *entry;
+  GtkWidget *checkbutton;
   GtkAccelGroup *accel_group;
   GtkItemFactory *item_factory;
 
@@ -333,6 +375,13 @@ main (int argc, char *argv[])
 
   g_signal_connect_swapped (button, "clicked",
 			    G_CALLBACK (remove_child), vbox);
+
+  checkbutton = gtk_check_button_new_with_label ("Grab keyboard");
+  gtk_box_pack_start (GTK_BOX (vbox), checkbutton, FALSE, FALSE, 0);
+
+  g_signal_connect (checkbutton, "toggled",
+		    G_CALLBACK (grab_window_toggled),
+		    window);
 
   hbox = gtk_hbox_new (FALSE, 0);
   gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
