[mutter/wip/multitouchr: 12/73] window: use input event helper functions on notify_focus()



commit a3ca52bf0f4dac83dae860b28d571e448b8bff41
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 |   55 ++++++++++++++++++++++++++++++++++------------------
 1 files changed, 36 insertions(+), 19 deletions(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index e99411b..bb94511 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -44,6 +44,7 @@
 #include "window-props.h"
 #include "constraints.h"
 #include "mutter-enum-types.h"
+#include "input-events.h"
 
 #include <X11/Xatom.h>
 #include <X11/Xlibint.h> /* For display->resource_mask */
@@ -6818,6 +6819,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
    */
@@ -6836,23 +6840,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
@@ -6873,19 +6890,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)
         {
@@ -6965,11 +6982,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]