diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index f058570..a12a65b 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -10731,6 +10731,9 @@ proxy_button_event (GdkEvent *source_event,
 					toplevel_x, toplevel_y,
 					NULL, NULL);
 
+      if (pointer_window == NULL)
+        pointer_window = toplevel_window;
+
       /* Find the event window, that gets the grab */
       w = (GdkWindowObject *)pointer_window;
       while (w != NULL &&
