Index: gtk+/modules/input/gtkimcontextxim.h
===================================================================
RCS file: /sgnome/cvsroots/sun-gnome/gtk+/modules/input/gtkimcontextxim.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 gtkimcontextxim.h
--- gtk+/modules/input/gtkimcontextxim.h	14 Oct 2002 17:05:23 -0000	1.1.1.1
+++ gtk+/modules/input/gtkimcontextxim.h	31 Oct 2002 03:59:27 -0000
@@ -75,6 +75,8 @@
 
   guint use_preedit : 1;
   guint status_visible : 1;
+
+  guint snooper_id;
 };
 
 struct _GtkIMContextXIMClass
Index: gtk+/modules/input/gtkimcontextxim.c
===================================================================
RCS file: /sgnome/cvsroots/sun-gnome/gtk+/modules/input/gtkimcontextxim.c,v
retrieving revision 1.4
diff -u -r1.4 gtkimcontextxim.c
--- gtk+/modules/input/gtkimcontextxim.c	30 Oct 2002 17:55:27 -0000	1.4
+++ gtk+/modules/input/gtkimcontextxim.c	31 Oct 2002 03:59:27 -0000
@@ -406,6 +406,7 @@
 {
   im_context_xim->use_preedit = TRUE;
   im_context_xim->filter_key_release = FALSE;
+  im_context_xim->snooper_id = 0;
 }
 
 static void
@@ -514,6 +515,7 @@
 {
   GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context);
   XIC ic = gtk_im_context_xim_get_ic (context_xim);
+  GdkWindow *root_window = gdk_screen_get_root_window (gdk_drawable_get_screen (event->window));
   gchar static_buffer[256];
   gchar *buffer = static_buffer;
   gint buffer_size = sizeof(static_buffer) - 1;
@@ -521,7 +523,6 @@
   KeySym keysym;
   Status status;
   gboolean result = FALSE;
-  GdkWindow *root_window = gdk_screen_get_root_window (gdk_drawable_get_screen (event->window));
 
   XKeyPressedEvent xevent;
 
@@ -542,9 +543,6 @@
   xevent.keycode = event->hardware_keycode;
   xevent.same_screen = True;
   
-  if (XFilterEvent ((XEvent *)&xevent, GDK_DRAWABLE_XID (context_xim->client_window)))
-    return TRUE;
-  
  again:
   if (ic)
     num_bytes = XmbLookupString (ic, &xevent, buffer, buffer_size, &keysym, &status);
@@ -590,6 +588,39 @@
   return result;
 }
 
+static gboolean
+gtk_im_context_xim_key_snooper (GtkWidget *grab_widget,
+				GdkEventKey *event,
+				gpointer func_data)
+{
+  GtkIMContext *context = (GtkIMContext*)func_data;
+  GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context);
+  GdkWindow *root_window = gdk_screen_get_root_window (gdk_drawable_get_screen (event->window));
+
+  gboolean ret;
+  XKeyPressedEvent xevent;
+
+  if (event->type == GDK_KEY_RELEASE && !context_xim->filter_key_release)
+    return FALSE;
+
+  xevent.type = (event->type == GDK_KEY_PRESS) ? KeyPress : KeyRelease;
+  xevent.serial = 0;		/* hope it doesn't matter */
+  xevent.send_event = event->send_event;
+  xevent.display = GDK_DRAWABLE_XDISPLAY (event->window);
+  xevent.window = GDK_DRAWABLE_XID (event->window);
+  xevent.root = GDK_DRAWABLE_XID (root_window);
+  xevent.subwindow = xevent.window;
+  xevent.time = event->time;
+  xevent.x = xevent.x_root = 0;
+  xevent.y = xevent.y_root = 0;
+  xevent.state = event->state;
+  xevent.keycode = event->hardware_keycode;
+  xevent.same_screen = True;
+  
+  ret = XFilterEvent ((XEvent *)&xevent, GDK_DRAWABLE_XID (context_xim->client_window));
+  return ret;
+}
+
 static void
 gtk_im_context_xim_focus_in (GtkIMContext *context)
 {
@@ -599,6 +630,8 @@
   if (!ic)
     return;
 
+  context_xim->snooper_id = gtk_key_snooper_install (gtk_im_context_xim_key_snooper,
+						     context);
   XSetICFocus (ic);
 
   status_window_show (context_xim);
@@ -614,6 +647,8 @@
 
   if (!ic)
     return;
+
+  gtk_key_snooper_remove (context_xim->snooper_id);
 
   XUnsetICFocus (ic);
 
