[gtk+/xi2: 1177/1239] GdkEventSource: Fix critical warning when generating focus events for non-wm case.



commit afd4c01b5b51ea7f666475d6f72fc558bdecc692
Author: Carlos Garnacho <carlos gnome org>
Date:   Thu Sep 17 16:43:50 2009 +0200

    GdkEventSource: Fix critical warning when generating focus events for non-wm case.

 gdk/x11/gdkeventsource.c |   40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)
---
diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c
index 0d3b3dc..afe4f21 100644
--- a/gdk/x11/gdkeventsource.c
+++ b/gdk/x11/gdkeventsource.c
@@ -93,34 +93,33 @@ static void
 handle_focus_change (GdkEventCrossing *event)
 {
   GdkToplevelX11 *toplevel;
-  gboolean focus_in;
+  gboolean focus_in, had_focus;
 
   toplevel = _gdk_x11_window_get_toplevel (event->window);
   focus_in = (event->type == GDK_ENTER_NOTIFY);
 
-  if (toplevel && event->detail != GDK_NOTIFY_INFERIOR)
-    {
-      toplevel->has_pointer = focus_in;
+  if (!toplevel || event->detail == GDK_NOTIFY_INFERIOR)
+    return;
 
-      if (event->focus && !toplevel->has_focus_window)
-        {
-          gboolean had_focus = HAS_FOCUS (toplevel);
+  toplevel->has_pointer = focus_in;
 
-          toplevel->has_pointer_focus = focus_in;
+  if (!event->focus || toplevel->has_focus_window)
+    return;
 
-          if (HAS_FOCUS (toplevel) != had_focus)
-            {
-              GdkEvent focus_event;
+  had_focus = HAS_FOCUS (toplevel);
+  toplevel->has_pointer_focus = focus_in;
 
-              focus_event.type = GDK_FOCUS_CHANGE;
-              focus_event.focus_change.window = event->window;
-              focus_event.focus_change.send_event = FALSE;
-              focus_event.focus_change.in = focus_in;
-              focus_event.focus_change.device = event->device;
+  if (HAS_FOCUS (toplevel) != had_focus)
+    {
+      GdkEvent focus_event;
 
-              gdk_event_put (&focus_event);
-            }
-        }
+      focus_event.type = GDK_FOCUS_CHANGE;
+      focus_event.focus_change.window = event->window;
+      focus_event.focus_change.send_event = FALSE;
+      focus_event.focus_change.in = focus_in;
+      focus_event.focus_change.device = event->device;
+
+      gdk_event_put (&focus_event);
     }
 }
 
@@ -192,7 +191,8 @@ gdk_event_source_translate_event (GdkEventSource *event_source,
 
   if (event &&
       (event->type == GDK_ENTER_NOTIFY ||
-       event->type == GDK_LEAVE_NOTIFY))
+       event->type == GDK_LEAVE_NOTIFY) &&
+      event->crossing.window != NULL)
     {
       /* Handle focusing (in the case where no window manager is running */
       handle_focus_change (&event->crossing);



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