[gtk+/wip/carlosg/event-delivery-cleanups: 26/30] gdk: Remove motion hints



commit 32de3372cea1457e09ea1ec80d888433aea61143
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Sep 15 18:58:50 2017 +0200

    gdk: Remove motion hints
    
    Motion hints are now literally a thing of the past. Everything should be
    using the full motion event stream.

 gdk/gdkdevice.c                |    3 +--
 gdk/gdkdisplay.c               |   32 --------------------------------
 gdk/gdkdisplayprivate.h        |    3 ---
 gdk/gdkevents.c                |   40 ----------------------------------------
 gdk/gdktypes.h                 |   10 ----------
 gdk/gdkwindow.c                |   35 +----------------------------------
 gdk/x11/gdkdevice-core-x11.c   |    1 -
 gdk/x11/gdkdevice-xi2.c        |    3 +--
 gdk/x11/gdkdevicemanager-xi2.c |    1 -
 gtk/gtkaboutdialog.c           |    2 --
 gtk/gtkgesture.c               |    3 ---
 gtk/gtktooltip.c               |    3 ---
 gtk/gtkwidget.c                |   11 -----------
 13 files changed, 3 insertions(+), 144 deletions(-)
---
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index 9c84e0c..fd918f3 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -1378,8 +1378,7 @@ get_native_grab_event_mask (GdkEventMask grab_mask)
     GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
     GDK_SCROLL_MASK |
     (grab_mask &
-     ~(GDK_POINTER_MOTION_HINT_MASK |
-       GDK_BUTTON_MOTION_MASK |
+     ~(GDK_BUTTON_MOTION_MASK |
        GDK_BUTTON1_MOTION_MASK |
        GDK_BUTTON2_MOTION_MASK |
        GDK_BUTTON3_MOTION_MASK));
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index a4a75bc..b0d30b5 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -379,8 +379,6 @@ gdk_display_init (GdkDisplay *display)
 
   display->touch_implicit_grabs = g_array_new (FALSE, FALSE, sizeof (GdkTouchGrabInfo));
   display->device_grabs = g_hash_table_new (NULL, NULL);
-  display->motion_hint_info = g_hash_table_new_full (NULL, NULL, NULL,
-                                                     (GDestroyNotify) g_free);
 
   display->pointers_info = g_hash_table_new_full (NULL, NULL, NULL,
                                                   (GDestroyNotify) free_pointer_info);
@@ -433,7 +431,6 @@ gdk_display_finalize (GObject *object)
 
   g_array_free (display->touch_implicit_grabs, TRUE);
 
-  g_hash_table_destroy (display->motion_hint_info);
   g_hash_table_destroy (display->pointers_info);
 
   g_list_free_full (display->input_devices, g_object_unref);
@@ -605,35 +602,6 @@ gdk_flush (void)
   g_slist_free (list);
 }
 
-void
-_gdk_display_enable_motion_hints (GdkDisplay *display,
-                                  GdkDevice  *device)
-{
-  gulong *device_serial, serial;
-
-  device_serial = g_hash_table_lookup (display->motion_hint_info, device);
-
-  if (!device_serial)
-    {
-      device_serial = g_new0 (gulong, 1);
-      *device_serial = G_MAXULONG;
-      g_hash_table_insert (display->motion_hint_info, device, device_serial);
-    }
-
-  if (*device_serial != 0)
-    {
-      serial = _gdk_display_get_next_serial (display);
-      /* We might not actually generate the next request, so
-        make sure this triggers always, this may cause it to
-        trigger slightly too early, but this is just a hint
-        anyway. */
-      if (serial > 0)
-       serial--;
-      if (serial < *device_serial)
-       *device_serial = serial;
-    }
-}
-
 static void
 generate_grab_broken_event (GdkDisplay *display,
                             GdkWindow  *window,
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index 8c37ed6..fe6ea0f 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -99,7 +99,6 @@ struct _GdkDisplay
 
   GArray *touch_implicit_grabs;
   GHashTable *device_grabs;
-  GHashTable *motion_hint_info;
   GdkDeviceManager *device_manager;
   GList *input_devices; /* Deprecated, only used to keep gdk_display_list_devices working */
 
@@ -298,8 +297,6 @@ GdkTouchGrabInfo *  _gdk_display_has_touch_grab       (GdkDisplay       *display
 gboolean            _gdk_display_end_touch_grab       (GdkDisplay       *display,
                                                        GdkDevice        *device,
                                                        GdkEventSequence *sequence);
-void                _gdk_display_enable_motion_hints  (GdkDisplay       *display,
-                                                       GdkDevice        *device);
 GdkPointerWindowInfo * _gdk_display_get_pointer_info  (GdkDisplay       *display,
                                                        GdkDevice        *device);
 void                _gdk_display_pointer_info_foreach (GdkDisplay       *display,
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index b47212b..448f515 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -1788,46 +1788,6 @@ gdk_event_get_source_device (const GdkEvent *event)
 }
 
 /**
- * gdk_event_request_motions:
- * @event: a valid #GdkEvent
- *
- * Request more motion notifies if @event is a motion notify hint event.
- *
- * This function should be used instead of gdk_window_get_pointer() to
- * request further motion notifies, because it also works for extension
- * events where motion notifies are provided for devices other than the
- * core pointer. Coordinate extraction, processing and requesting more
- * motion events from a %GDK_MOTION_NOTIFY event usually works like this:
- *
- * |[<!-- language="C" -->
- * {
- *   // motion_event handler
- *   x = motion_event->x;
- *   y = motion_event->y;
- *   // handle (x,y) motion
- *   gdk_event_request_motions (motion_event); // handles is_hint events
- * }
- * ]|
- *
- * Since: 2.12
- **/
-void
-gdk_event_request_motions (const GdkEventMotion *event)
-{
-  GdkDisplay *display;
-  
-  g_return_if_fail (event != NULL);
-  
-  if (event->type == GDK_MOTION_NOTIFY && event->is_hint)
-    {
-      gdk_device_get_state (event->device, event->window, NULL, NULL);
-      
-      display = gdk_window_get_display (event->window);
-      _gdk_display_enable_motion_hints (display, event->device);
-    }
-}
-
-/**
  * gdk_event_triggers_context_menu:
  * @event: a #GdkEvent, currently only button events are meaningful values
  *
diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h
index 73bf2fe..20f759f 100644
--- a/gdk/gdktypes.h
+++ b/gdk/gdktypes.h
@@ -373,7 +373,6 @@ typedef enum
  * GdkEventMask:
  * @GDK_EXPOSURE_MASK: receive expose events
  * @GDK_POINTER_MOTION_MASK: receive all pointer motion events
- * @GDK_POINTER_MOTION_HINT_MASK: deprecated. see the explanation above
  * @GDK_BUTTON_MOTION_MASK: receive pointer motion events while any button is pressed
  * @GDK_BUTTON1_MOTION_MASK: receive pointer motion events while 1 button is pressed
  * @GDK_BUTTON2_MOTION_MASK: receive pointer motion events while 2 button is pressed
@@ -406,14 +405,6 @@ typedef enum
  * See the [input handling overview][chap-input-handling] for details of
  * [event masks][event-masks] and [event propagation][event-propagation].
  *
- * %GDK_POINTER_MOTION_HINT_MASK is deprecated. It is a special mask
- * to reduce the number of %GDK_MOTION_NOTIFY events received. When using
- * %GDK_POINTER_MOTION_HINT_MASK, fewer %GDK_MOTION_NOTIFY events will
- * be sent, some of which are marked as a hint (the is_hint member is
- * %TRUE). To receive more motion events after a motion hint event,
- * the application needs to asks for more, by calling
- * gdk_event_request_motions().
- * 
  * Since GTK 3.8, motion events are already compressed by default, independent
  * of this mechanism. This compression can be disabled with
  * gdk_window_set_event_compression(). See the documentation of that function
@@ -430,7 +421,6 @@ typedef enum
 {
   GDK_EXPOSURE_MASK             = 1 << 1,
   GDK_POINTER_MOTION_MASK       = 1 << 2,
-  GDK_POINTER_MOTION_HINT_MASK  = 1 << 3,
   GDK_BUTTON_MOTION_MASK        = 1 << 4,
   GDK_BUTTON1_MOTION_MASK       = 1 << 5,
   GDK_BUTTON2_MOTION_MASK       = 1 << 6,
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 394c466..1617676 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -948,14 +948,7 @@ get_native_device_event_mask (GdkWindow *private,
     {
       GdkEventMask mask;
 
-      /* Do whatever the app asks to, since the app
-       * may be asking for weird things for native windows,
-       * but don't use motion hints as that may affect non-native
-       * child windows that don't want it. Also, we need to
-       * set all the app-specified masks since they will be picked
-       * up by any implicit grabs (i.e. if they were not set as
-       * native we would not get the events we need). */
-      mask = private->event_mask & ~GDK_POINTER_MOTION_HINT_MASK;
+      mask = private->event_mask;
 
       /* We need thse for all native windows so we can
         emulate events on children: */
@@ -3397,8 +3390,6 @@ gdk_window_get_device_position_double (GdkWindow       *window,
   if (mask)
     *mask = tmp_mask;
 
-  _gdk_display_enable_motion_hints (gdk_window_get_display (window), device);
-
   if (normal_child)
     return _gdk_window_find_child_at (window, tmp_x, tmp_y);
   return NULL;
@@ -3953,27 +3944,12 @@ gdk_window_set_events (GdkWindow       *window,
                       GdkEventMask     event_mask)
 {
   GdkWindowImplClass *impl_class;
-  GdkDisplay *display;
 
   g_return_if_fail (GDK_IS_WINDOW (window));
 
   if (window->destroyed)
     return;
 
-  /* If motion hint is disabled, enable motion events again */
-  display = gdk_window_get_display (window);
-  if ((window->event_mask & GDK_POINTER_MOTION_HINT_MASK) &&
-      !(event_mask & GDK_POINTER_MOTION_HINT_MASK))
-    {
-      GList *devices = window->devices_inside;
-
-      while (devices)
-        {
-          _gdk_display_enable_motion_hints (display, (GdkDevice *) devices->data);
-          devices = devices->next;
-        }
-    }
-
   window->event_mask = event_mask;
 
   if (gdk_window_has_impl (window))
@@ -4027,7 +4003,6 @@ gdk_window_set_device_events (GdkWindow    *window,
                               GdkEventMask  event_mask)
 {
   GdkEventMask device_mask;
-  GdkDisplay *display;
   GdkWindow *native;
 
   g_return_if_fail (GDK_IS_WINDOW (window));
@@ -4036,12 +4011,6 @@ gdk_window_set_device_events (GdkWindow    *window,
   if (GDK_WINDOW_DESTROYED (window))
     return;
 
-  /* If motion hint is disabled, enable motion events again */
-  display = gdk_window_get_display (window);
-  if ((window->event_mask & GDK_POINTER_MOTION_HINT_MASK) &&
-      !(event_mask & GDK_POINTER_MOTION_HINT_MASK))
-    _gdk_display_enable_motion_hints (display, device);
-
   if (G_UNLIKELY (!window->device_events))
     window->device_events = g_hash_table_new (NULL, NULL);
 
@@ -5777,8 +5746,6 @@ _gdk_display_set_window_under_pointer (GdkDisplay *display,
       g_object_ref (window);
       update_cursor (display, device);
     }
-
-  _gdk_display_enable_motion_hints (display, device);
 }
 
 static void
diff --git a/gdk/x11/gdkdevice-core-x11.c b/gdk/x11/gdkdevice-core-x11.c
index e0d34ed..418546c 100644
--- a/gdk/x11/gdkdevice-core-x11.c
+++ b/gdk/x11/gdkdevice-core-x11.c
@@ -571,7 +571,6 @@ gdk_x11_device_core_select_window_events (GdkDevice    *device,
 
   window_mask = gdk_window_get_events (window);
   filter_mask = GDK_POINTER_MOTION_MASK
-                | GDK_POINTER_MOTION_HINT_MASK
                 | GDK_BUTTON_MOTION_MASK
                 | GDK_BUTTON1_MOTION_MASK
                 | GDK_BUTTON2_MOTION_MASK
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index 23857a5..bdf28c4 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -709,8 +709,7 @@ _gdk_x11_device_xi2_translate_event_mask (GdkX11DeviceManagerXI2 *device_manager
   *len = XIMaskLen (XI_LASTEVENT);
   mask = g_new0 (guchar, *len);
 
-  if (event_mask & GDK_POINTER_MOTION_MASK ||
-      event_mask & GDK_POINTER_MOTION_HINT_MASK)
+  if (event_mask & GDK_POINTER_MOTION_MASK)
     XISetMask (mask, XI_Motion);
 
   if (event_mask & GDK_BUTTON_MOTION_MASK ||
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 787da0c..41d5fae 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -1979,7 +1979,6 @@ gdk_x11_device_manager_xi2_get_handled_events (GdkEventTranslator *translator)
           GDK_ENTER_NOTIFY_MASK |
           GDK_LEAVE_NOTIFY_MASK |
           GDK_POINTER_MOTION_MASK |
-          GDK_POINTER_MOTION_HINT_MASK |
           GDK_BUTTON1_MOTION_MASK |
           GDK_BUTTON2_MOTION_MASK |
           GDK_BUTTON3_MOTION_MASK |
diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c
index eee6fe5..9f20d01 100644
--- a/gtk/gtkaboutdialog.c
+++ b/gtk/gtkaboutdialog.c
@@ -2127,8 +2127,6 @@ text_view_motion_notify_event (GtkWidget      *text_view,
 
   set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), event->device, x, y);
 
-  gdk_event_request_motions (event);
-
   return FALSE;
 }
 
diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c
index 88bbbfb..70499ca 100644
--- a/gtk/gtkgesture.c
+++ b/gtk/gtkgesture.c
@@ -720,9 +720,6 @@ gtk_gesture_handle_event (GtkEventController *controller,
         {
           if ((event->motion.state & BUTTONS_MASK) == 0)
             return FALSE;
-
-          if (event->motion.is_hint)
-            gdk_event_request_motions (&event->motion);
         }
 
       if (_gtk_gesture_update_point (gesture, event, FALSE) &&
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index 4d57c5a..a11ba10 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -1434,9 +1434,6 @@ gtk_tooltip_handle_event_internal (GdkEvent *event)
       return;
     }
 
-  /* Always poll for a next motion event */
-  gdk_event_request_motions (&event->motion);
-
   /* Hide the tooltip when there's no new tooltip widget */
   if (!has_tooltip_widget)
     {
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 4faa25b..11cbe68 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6672,17 +6672,6 @@ _gtk_widget_captured_event (GtkWidget      *widget,
   return_val |= handler (widget, event_copy);
   return_val |= !WIDGET_REALIZED_FOR_EVENT (widget, event_copy);
 
-  /* The widget that was originally to receive the event
-   * handles motion hints, but the capturing widget might
-   * not, so ensure we get further motion events.
-   */
-  if (return_val &&
-      event_copy->type == GDK_MOTION_NOTIFY &&
-      event_copy->motion.is_hint &&
-      (gdk_window_get_events (event_copy->any.window) &
-       GDK_POINTER_MOTION_HINT_MASK) != 0)
-    gdk_event_request_motions (&event_copy->motion);
-
   g_object_unref (widget);
 
 out:


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