[mutter/wip/xinput2r: 16/68] window: use input event helper functions on notify_focus()



commit d9e02531b250fd89b3cf2c44d5e29c830d9390ef
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jun 9 17:47:45 2011 +0200

    window: use input event helper functions on notify_focus()

 src/core/window.c |   54 ++++++++++++++++++++++++++++++++++------------------
 1 files changed, 35 insertions(+), 19 deletions(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index 391bec1..3cb92e9 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -6820,6 +6820,9 @@ gboolean
 meta_window_notify_focus (MetaWindow *window,
                           XEvent     *event)
 {
+  guint evtype, mode, detail;
+  Window xwindow;
+
   /* note the event can be on either the window or the frame,
    * we focus the frame for shaded windows
    */
@@ -6838,23 +6841,36 @@ meta_window_notify_focus (MetaWindow *window,
    * the MRU list gets confused from what the user expects once a
    * keybinding is used.
    */
+  if (meta_input_event_get_type (window->display, event, &evtype))
+    {
+      meta_input_event_get_crossing_details (window->display, event,
+                                             &mode, &detail);
+      xwindow = meta_input_event_get_window (window->display, event);
+    }
+  else
+    {
+      xwindow = event->xany.window;
+      evtype = event->type;
+      mode = detail = 0;
+    }
+
   meta_topic (META_DEBUG_FOCUS,
               "Focus %s event received on %s 0x%lx (%s) "
               "mode %s detail %s\n",
-              event->type == FocusIn ? "in" :
-              event->type == FocusOut ? "out" :
-              event->type == UnmapNotify ? "unmap" :
+              evtype == FocusIn ? "in" :
+              evtype == FocusOut ? "out" :
+              evtype == UnmapNotify ? "unmap" :
               "???",
-              window->desc, event->xany.window,
-              event->xany.window == window->xwindow ?
+              window->desc, xwindow,
+              xwindow == window->xwindow ?
               "client window" :
               (window->frame && event->xany.window == window->frame->xwindow) ?
               "frame window" :
               "unknown window",
-              event->type != UnmapNotify ?
-              meta_event_mode_to_string (event->xfocus.mode) : "n/a",
-              event->type != UnmapNotify ?
-              meta_event_detail_to_string (event->xfocus.detail) : "n/a");
+              evtype != UnmapNotify ?
+              meta_event_mode_to_string (mode) : "n/a",
+              evtype != UnmapNotify ?
+              meta_event_detail_to_string (detail) : "n/a");
 
   /* FIXME our pointer tracking is broken; see how
    * gtk+/gdk/x11/gdkevents-x11.c or XFree86/xc/programs/xterm/misc.c
@@ -6875,19 +6891,19 @@ meta_window_notify_focus (MetaWindow *window,
    * http://bugzilla.gnome.org/show_bug.cgi?id=90382
    */
 
-  if ((event->type == FocusIn ||
-       event->type == FocusOut) &&
-      (event->xfocus.mode == NotifyGrab ||
-       event->xfocus.mode == NotifyUngrab ||
+  if ((evtype == FocusIn ||
+       evtype == FocusOut) &&
+      (mode == NotifyGrab ||
+       mode == NotifyUngrab ||
        /* From WindowMaker, ignore all funky pointer root events */
-       event->xfocus.detail > NotifyNonlinearVirtual))
+       detail > NotifyNonlinearVirtual))
     {
       meta_topic (META_DEBUG_FOCUS,
                   "Ignoring focus event generated by a grab or other weirdness\n");
       return TRUE;
     }
 
-  if (event->type == FocusIn)
+  if (evtype == FocusIn)
     {
       if (window->override_redirect)
         {
@@ -6967,11 +6983,11 @@ meta_window_notify_focus (MetaWindow *window,
           meta_window_propagate_focus_appearance (window, TRUE);
         }
     }
-  else if (event->type == FocusOut ||
-           event->type == UnmapNotify)
+  else if (evtype == FocusOut ||
+           evtype == UnmapNotify)
     {
-      if (event->type == FocusOut &&
-          event->xfocus.detail == NotifyInferior)
+      if (evtype == FocusOut &&
+          detail == NotifyInferior)
         {
           /* This event means the client moved focus to a subwindow */
           meta_topic (META_DEBUG_FOCUS,



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