diff --git a/gdk/x11/gdkdevicemanager-core-x11.c b/gdk/x11/gdkdevicemanager-core-x11.c
index 0e49fb7..a6b20c2 100644
--- a/gdk/x11/gdkdevicemanager-core-x11.c
+++ b/gdk/x11/gdkdevicemanager-core-x11.c
@@ -633,6 +633,7 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
           break;
         }
 
+      printf("event crossing with focus=1\n");
       event->crossing.type = GDK_LEAVE_NOTIFY;
       event->crossing.window = window;
       gdk_event_set_device (event, device_manager->core_pointer);
@@ -805,25 +806,35 @@ _gdk_device_manager_core_handle_focus (GdkWindow *window,
   GdkToplevelX11 *toplevel;
   gboolean had_focus;
 
+  printf("%s called with %d %s %s\n", __func__, focus_in, notify_details[detail], notify_modes[mode]);
+
   g_return_if_fail (GDK_IS_WINDOW (window));
   g_return_if_fail (GDK_IS_DEVICE (device));
   g_return_if_fail (source_device == NULL || GDK_IS_DEVICE (source_device));
 
   GDK_NOTE (EVENTS,
-            g_message ("focus out:\t\twindow: %ld, detail: %s, mode: %s",
+            g_message ("focus out:\t\t%d window: %ld, detail: %s, mode: %s",
+                       focus_in,
                        GDK_WINDOW_XID (window),
                        notify_details[detail],
                        notify_modes[mode]));
 
   toplevel = _gdk_x11_window_get_toplevel (window);
+  printf("has_focus=%d has_pointer_focus=%d has_pointer=%d has_focus_window=%d\n", toplevel->has_focus, toplevel->has_pointer_focus, toplevel->has_pointer, toplevel->has_focus_window);
+
 
-  if (!toplevel)
+  if (!toplevel) {
+      //printf("early return 1\n");
     return;
+  }
 
-  if (toplevel->focus_window == original)
+  if (toplevel->focus_window == original) {
+      //printf("early return 2\n");
     return;
+  }
 
   had_focus = HAS_FOCUS (toplevel);
+  //printf("had focus = %d toplevel->has_focus=%d toplevel->has_pointer_focus=%d\n", had_focus, toplevel->has_focus, toplevel->has_pointer_focus);
 
   switch (detail)
     {
@@ -874,6 +885,10 @@ _gdk_device_manager_core_handle_focus (GdkWindow *window,
     {
       GdkEvent *event;
 
+      //printf("has focus != had_focus\n");
+      //printf("toplevel->has_focus=%d toplevel->has_pointer_focus=%d\n", toplevel->has_focus, toplevel->has_pointer_focus);
+      printf("%s: focus changed from %d to %d\n", __func__, had_focus, HAS_FOCUS( toplevel));
+      printf("has_focus=%d has_pointer_focus=%d has_pointer=%d has_focus_window=%d\n", toplevel->has_focus, toplevel->has_pointer_focus, toplevel->has_pointer, toplevel->has_focus_window);
       event = gdk_event_new (GDK_FOCUS_CHANGE);
       event->focus_change.window = g_object_ref (window);
       event->focus_change.send_event = FALSE;
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index a0fba5f..db3e526 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -1540,6 +1540,8 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
         XIEnterEvent *xev = (XIEnterEvent *) ev;
         GdkDevice *device, *source_device;
 
+        printf("event crossing with focus=%d\n", xev->focus);
+
         event->crossing.type = (ev->evtype == XI_Enter) ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY;
 
         event->crossing.x = (gdouble) xev->event_x;
diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c
index 6b82611..7fc3978 100644
--- a/gdk/x11/gdkeventsource.c
+++ b/gdk/x11/gdkeventsource.c
@@ -136,22 +136,32 @@ handle_focus_change (GdkEventCrossing *event)
 
   toplevel = _gdk_x11_window_get_toplevel (event->window);
   focus_in = (event->type == GDK_ENTER_NOTIFY);
+  printf("%s called with %d\n", __func__, focus_in);
+  printf("has_focus=%d has_pointer_focus=%d has_pointer=%d has_focus_window=%d event->detail=%d evfoc=%d\n", toplevel->has_focus, toplevel->has_pointer_focus, toplevel->has_pointer, toplevel->has_focus_window, event->detail, event->focus);
 
-  if (!toplevel || event->detail == GDK_NOTIFY_INFERIOR)
+  if (!toplevel || event->detail == GDK_NOTIFY_INFERIOR) {
+      //printf("early return 1\n");
     return;
+  }
 
   toplevel->has_pointer = focus_in;
+//  printf("has pointer = %d\n", toplevel->has_pointer);
 
-  if (!event->focus || toplevel->has_focus_window)
+  if (!event->focus || toplevel->has_focus_window) {
+      //  printf("early return 2\n");
     return;
+  }
 
   had_focus = HAS_FOCUS (toplevel);
+//  printf("had focus = %d\n", had_focus);
   toplevel->has_pointer_focus = focus_in;
 
   if (HAS_FOCUS (toplevel) != had_focus)
     {
       GdkEvent *focus_event;
 
+      printf("%s: focus changed from %d to %d\n", __func__, had_focus, HAS_FOCUS( toplevel));
+      printf("has_focus=%d has_pointer_focus=%d has_pointer=%d has_focus_window=%d event->detail=%d evfoc=%d\n", toplevel->has_focus, toplevel->has_pointer_focus, toplevel->has_pointer, toplevel->has_focus_window, event->detail, event->focus);
       focus_event = gdk_event_new (GDK_FOCUS_CHANGE);
       focus_event->focus_change.window = g_object_ref (event->window);
       focus_event->focus_change.send_event = FALSE;
@@ -188,6 +198,8 @@ gdk_event_source_translate_event (GdkEventSource *event_source,
   if (filter_window)
     event->any.window = g_object_ref (filter_window);
 
+  //printf("reved xevent %d\n", xevent->xcrossing.focus);
+
   /* Run default filters */
   if (_gdk_default_filters)
     {
