mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-12 13:30:19 +00:00
gdk: Remove motion hints
Motion hints are now literally a thing of the past. Everything should be using the full motion event stream.
This commit is contained in:
parent
3e1f672170
commit
44cb3ccfa1
@ -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));
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -1860,46 +1860,6 @@ gdk_event_get_source_device (const GdkEvent *event)
|
||||
return gdk_event_get_device (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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 ||
|
||||
|
@ -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 |
|
||||
|
@ -2134,8 +2134,6 @@ text_view_motion_notify_event (GtkWidget *text_view,
|
||||
set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view),
|
||||
gdk_event_get_device ((GdkEvent *) event), x, y);
|
||||
|
||||
gdk_event_request_motions (event);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -722,8 +722,6 @@ gtk_gesture_handle_event (GtkEventController *controller,
|
||||
{
|
||||
if ((state & BUTTONS_MASK) == 0)
|
||||
return FALSE;
|
||||
|
||||
gdk_event_request_motions ((GdkEventMotion *)event);
|
||||
}
|
||||
|
||||
if (_gtk_gesture_update_point (gesture, event, FALSE) &&
|
||||
|
@ -1393,10 +1393,6 @@ _gtk_tooltip_handle_event (GdkEvent *event)
|
||||
gdk_event_get_coords (event, &dx, &dy);
|
||||
|
||||
gtk_tooltip_handle_event_internal (event_type, window, dx, dy);
|
||||
|
||||
/* Always poll for a next motion event */
|
||||
gdk_event_request_motions ((GdkEventMotion *) event);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -6675,17 +6675,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:
|
||||
|
Loading…
Reference in New Issue
Block a user