[mutter/wayland] display: clean up event handling



commit 5c99eae8a9ca04f5e89e60a314d3e19c7ef0a715
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Thu Feb 27 14:56:55 2014 +0100

    display: clean up event handling
    
    The only events we handle as XIEvents are FocusIn/Out, Enter and
    Leave.  Motion, ButtonPress/Release, KeyPress/Release are handled
    through clutter instead.
    Among other things, this means we don't need to fake motion compression
    by peeking over gdk event queue...

 src/core/display-private.h |    1 -
 src/core/display.c         |   68 +----------------
 src/core/window.c          |  182 --------------------------------------------
 3 files changed, 2 insertions(+), 249 deletions(-)
---
diff --git a/src/core/display-private.h b/src/core/display-private.h
index 4bd95cb..8973a59 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -215,7 +215,6 @@ struct _MetaDisplay
   gboolean    grab_threshold_movement_reached; /* raise_on_click == FALSE.    */
   MetaResizePopup *grab_resize_popup;
   GTimeVal    grab_last_moveresize_time;
-  guint32     grab_motion_notify_time;
   GList*      grab_old_window_stacking;
   MetaEdgeResistanceData *grab_edge_resistance_data;
   unsigned int grab_last_user_action_was_snap;
diff --git a/src/core/display.c b/src/core/display.c
index 2ae5db4..778f54d 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1715,17 +1715,6 @@ get_input_event (MetaDisplay *display,
 
       switch (input_event->evtype)
         {
-        case XI_Motion:
-        case XI_ButtonPress:
-        case XI_ButtonRelease:
-          if (((XIDeviceEvent *) input_event)->deviceid == META_VIRTUAL_CORE_POINTER_ID)
-            return input_event;
-          break;
-        case XI_KeyPress:
-        case XI_KeyRelease:
-          if (((XIDeviceEvent *) input_event)->deviceid == META_VIRTUAL_CORE_KEYBOARD_ID)
-            return input_event;
-          break;
         case XI_FocusIn:
         case XI_FocusOut:
           if (((XIEnterEvent *) input_event)->deviceid == META_VIRTUAL_CORE_KEYBOARD_ID)
@@ -2316,18 +2305,14 @@ handle_input_xevent (MetaDisplay *display,
                      XIEvent     *input_event,
                      gulong       serial)
 {
-  XIDeviceEvent *device_event = (XIDeviceEvent *) input_event;
   XIEnterEvent *enter_event = (XIEnterEvent *) input_event;
   Window modified;
   MetaWindow *window;
-  gboolean frame_was_receiver;
   MetaScreen *screen;
 
   if (input_event == NULL)
     return FALSE;
 
-  screen = meta_display_screen_for_root (display, device_event->root);
-
   modified = xievent_get_modified_window (display, input_event);
   window = modified != None ? meta_display_lookup_x_window (display, modified) : NULL;
 
@@ -2391,6 +2376,8 @@ handle_input_xevent (MetaDisplay *display,
           if (enter_event->root != enter_event->event)
             break;
 
+          screen = meta_display_screen_for_root (display, enter_event->root);
+
           if (enter_event->evtype == XI_FocusIn &&
               enter_event->mode == XINotifyDetailNone)
             {
@@ -3138,12 +3125,6 @@ xievent_get_modified_window (MetaDisplay *display,
 {
   switch (input_event->evtype)
     {
-    case XI_Motion:
-    case XI_ButtonPress:
-    case XI_ButtonRelease:
-    case XI_KeyPress:
-    case XI_KeyRelease:
-      return ((XIDeviceEvent *) input_event)->event;
     case XI_FocusIn:
     case XI_FocusOut:
     case XI_Enter:
@@ -3412,26 +3393,10 @@ meta_spew_xi2_event (MetaDisplay *display,
   const char *name = NULL;
   char *extra = NULL;
 
-  XIDeviceEvent *device_event = (XIDeviceEvent *) input_event;
   XIEnterEvent *enter_event = (XIEnterEvent *) input_event;
 
   switch (input_event->evtype)
     {
-    case XI_Motion:
-      name = "XI_Motion";
-      break;
-    case XI_ButtonPress:
-      name = "XI_ButtonPress";
-      break;
-    case XI_ButtonRelease:
-      name = "XI_ButtonRelease";
-      break;
-    case XI_KeyPress:
-      name = "XI_KeyPress";
-      break;
-    case XI_KeyRelease:
-      name = "XI_KeyRelease";
-      break;
     case XI_FocusIn:
       name = "XI_FocusIn";
       break;
@@ -3456,34 +3421,6 @@ meta_spew_xi2_event (MetaDisplay *display,
 
   switch (input_event->evtype)
     {
-    case XI_Motion:
-      extra = g_strdup_printf ("win: 0x%lx x: %g y: %g",
-                               device_event->event,
-                               device_event->root_x,
-                               device_event->root_y);
-      break;
-    case XI_ButtonPress:
-    case XI_ButtonRelease:
-      extra = g_strdup_printf ("button %u x %g y %g root 0x%lx",
-                               device_event->detail,
-                               device_event->root_x,
-                               device_event->root_y,
-                               device_event->root);
-      break;
-    case XI_KeyPress:
-    case XI_KeyRelease:
-      {
-        KeySym keysym;
-        const char *str;
-  
-        keysym = XKeycodeToKeysym (display->xdisplay, device_event->detail, 0);
-
-        str = XKeysymToString (keysym);
-
-        extra = g_strdup_printf ("Key '%s' state 0x%x",
-                                 str ? str : "none", device_event->mods.effective);
-      }
-      break;
     case XI_FocusIn:
     case XI_FocusOut:
       extra = g_strdup_printf ("detail: %s mode: %s\n",
@@ -4111,7 +4048,6 @@ meta_display_begin_grab_op (MetaDisplay *display,
   display->grab_latest_motion_y = root_y;
   display->grab_last_moveresize_time.tv_sec = 0;
   display->grab_last_moveresize_time.tv_usec = 0;
-  display->grab_motion_notify_time = 0;
   display->grab_old_window_stacking = NULL;
 #ifdef HAVE_XSYNC
   display->grab_last_user_action_was_snap = FALSE;
diff --git a/src/core/window.c b/src/core/window.c
index 8bbe5c4..d917d24 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -8521,98 +8521,6 @@ update_resize (MetaWindow *window,
     g_get_current_time (&window->display->grab_last_moveresize_time);
 }
 
-typedef struct
-{
-  Window  window;
-  int     count;
-  guint32 last_time;
-} EventScannerData;
-
-static Bool
-find_last_time_predicate (Display  *display,
-                          XEvent   *ev,
-                          XPointer  arg)
-{
-  EventScannerData *esd = (void*) arg;
-  XIEvent *xev;
-
-  if (ev->type != GenericEvent)
-    return False;
-
-  /* We are peeking into events not yet handled by GDK,
-   * Allocate cookie events here so we can handle XI2.
-   *
-   * GDK will handle later these events, and eventually
-   * free the cookie data itself.
-   */
-  XGetEventData (display, &ev->xcookie);
-  xev = (XIEvent *) ev->xcookie.data;
-
-  if (xev->evtype != XI_Motion)
-    return False;
-
-  if (esd->window != ((XIDeviceEvent *) xev)->event)
-    return False;
-
-  esd->count += 1;
-  esd->last_time = xev->time;
-
-  return False;
-}
-
-static gboolean
-check_use_this_motion_notify (MetaWindow *window,
-                              XIDeviceEvent *xev)
-{
-  EventScannerData esd;
-  XEvent useless;
-
-  /* This code is copied from Owen's GDK code. */
-
-  if (window->display->grab_motion_notify_time != 0)
-    {
-      /* == is really the right test, but I'm all for paranoia */
-      if (window->display->grab_motion_notify_time <=
-          xev->time)
-        {
-          meta_topic (META_DEBUG_RESIZING,
-                      "Arrived at event with time %u (waiting for %u), using it\n",
-                      (unsigned int)xev->time,
-                      window->display->grab_motion_notify_time);
-          window->display->grab_motion_notify_time = 0;
-          return TRUE;
-        }
-      else
-        return FALSE; /* haven't reached the saved timestamp yet */
-    }
-
-  esd.window = xev->event;
-  esd.count = 0;
-  esd.last_time = 0;
-
-  /* "useless" isn't filled in because the predicate never returns True */
-  XCheckIfEvent (window->display->xdisplay,
-                 &useless,
-                 find_last_time_predicate,
-                 (XPointer) &esd);
-
-  if (esd.count > 0)
-    meta_topic (META_DEBUG_RESIZING,
-                "Will skip %d motion events and use the event with time %u\n",
-                esd.count, (unsigned int) esd.last_time);
-
-  if (esd.last_time == 0)
-    return TRUE;
-  else
-    {
-      /* Save this timestamp, and ignore all motion notify
-       * until we get to the one with this stamp.
-       */
-      window->display->grab_motion_notify_time = esd.last_time;
-      return FALSE;
-    }
-}
-
 static void
 update_tile_mode (MetaWindow *window)
 {
@@ -8684,96 +8592,6 @@ meta_window_update_sync_request_counter (MetaWindow *window,
 #endif /* HAVE_XSYNC */
 
 void
-meta_window_handle_mouse_grab_op_xevent (MetaWindow         *window,
-                                         XIDeviceEvent      *xevent)
-{
-  gboolean is_window_root = (xevent->root == window->screen->xroot);
-
-  switch (xevent->evtype)
-    {
-    case XI_ButtonRelease:
-      if (xevent->detail == 1 ||
-          xevent->detail == meta_prefs_get_mouse_button_resize ())
-        {
-          meta_display_check_threshold_reached (window->display,
-                                                xevent->root_x,
-                                                xevent->root_y);
-          /* If the user was snap moving then ignore the button
-           * release because they may have let go of shift before
-           * releasing the mouse button and they almost certainly do
-           * not want a non-snapped movement to occur from the button
-           * release.
-           */
-          if (!window->display->grab_last_user_action_was_snap)
-            {
-              if (meta_grab_op_is_moving (window->display->grab_op))
-                {
-                  if (window->tile_mode != META_TILE_NONE)
-                    meta_window_tile (window);
-                  else if (is_window_root)
-                    update_move (window,
-                                 xevent->mods.effective & ShiftMask,
-                                 xevent->root_x,
-                                 xevent->root_y);
-                }
-              else if (meta_grab_op_is_resizing (window->display->grab_op))
-                {
-                  if (is_window_root)
-                    update_resize (window,
-                                   xevent->mods.effective & ShiftMask,
-                                   xevent->root_x,
-                                   xevent->root_y,
-                                   TRUE);
-
-                  /* If a tiled window has been dragged free with a
-                   * mouse resize without snapping back to the tiled
-                   * state, it will end up with an inconsistent tile
-                   * mode on mouse release; cleaning the mode earlier
-                   * would break the ability to snap back to the tiled
-                   * state, so we wait until mouse release.
-                   */
-                  update_tile_mode (window);
-                }
-              meta_display_end_grab_op (window->display, xevent->time);
-            }
-        }
-      break;
-
-    case XI_Motion:
-      meta_display_check_threshold_reached (window->display,
-                                            xevent->root_x,
-                                            xevent->root_y);
-      if (meta_grab_op_is_moving (window->display->grab_op))
-        {
-          if (is_window_root)
-            {
-              if (check_use_this_motion_notify (window, xevent))
-                update_move (window,
-                             xevent->mods.effective & ShiftMask,
-                             xevent->root_x,
-                             xevent->root_y);
-            }
-        }
-      else if (meta_grab_op_is_resizing (window->display->grab_op))
-        {
-          if (is_window_root)
-            {
-              if (check_use_this_motion_notify (window, xevent))
-                update_resize (window,
-                               xevent->mods.effective & ShiftMask,
-                               xevent->root_x,
-                               xevent->root_y,
-                               FALSE);
-            }
-        }
-      break;
-
-    default:
-      break;
-    }
-}
-
-void
 meta_window_handle_mouse_grab_op_event  (MetaWindow         *window,
                                          const ClutterEvent *event)
 {


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