diff --git a/ChangeLog b/ChangeLog index 3f207ad26b..59dcfd0cb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Tue Feb 6 15:53:59 2007 Tim Janik + + * gtk/gtktextview.c (gtk_text_view_motion_event): + * gtk/gtkspinbutton.c (gtk_spin_button_motion_notify): + * gtk/gtkaboutdialog.c (credits_motion_notify_event): + * gtk/gtkhruler.c (gtk_hruler_motion_notify): + * gtk/gtkvruler.c (gtk_vruler_motion_notify): + * gtk/gtkentry.c (gtk_entry_motion_notify): + * gtk/gtktooltip.c (_gtk_tooltip_handle_event): + * gtk/gtkhsv.c (gtk_hsv_motion): call gdk_event_request_motions() + for new motion events after receiving motion hints. + + * gdk/gdkevents.[hc]: added gdk_event_request_motions(). + 2007-02-06 Kristian Rietveld * gtk/gtktooltip.c (find_topmost_widget_coords_from_event): diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index ac6cd59d2e..fcc7559721 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -834,6 +834,26 @@ gdk_event_get_axis (GdkEvent *event, return gdk_device_get_axis (device, axes, axis_use, value); } +/** + * gdk_event_request_motions: + * @event: a valid #GdkEvent + * + * Request more motion notifies if #event is a motion notify hint event. + * This funciton 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. + * + * Since: 2.12 + **/ +void +gdk_event_request_motions (GdkEventMotion *event) +{ + 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); +} + /** * gdk_event_set_screen: * @event: a #GdkEvent diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h index 6c5ea277dc..5a30e99a32 100644 --- a/gdk/gdkevents.h +++ b/gdk/gdkevents.h @@ -529,6 +529,7 @@ gboolean gdk_event_get_root_coords (GdkEvent *event, gboolean gdk_event_get_axis (GdkEvent *event, GdkAxisUse axis_use, gdouble *value); +void gdk_event_request_motions (GdkEventMotion *event); void gdk_event_handler_set (GdkEventFunc func, gpointer data, GDestroyNotify notify); diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c index 863ac53ca8..38bd2c6213 100644 --- a/gtk/gtkaboutdialog.c +++ b/gtk/gtkaboutdialog.c @@ -1781,7 +1781,7 @@ credits_motion_notify_event (GtkWidget *text_view, set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y); - gdk_window_get_pointer (text_view->window, NULL, NULL, NULL); + gdk_event_request_motions (event); return FALSE; } diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 35445f8fcb..9da426264a 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -1872,8 +1872,8 @@ gtk_entry_motion_notify (GtkWidget *widget, if (entry->select_lines) return TRUE; - if (event->is_hint || (entry->text_area != event->window)) - gdk_window_get_pointer (entry->text_area, NULL, NULL, NULL); + if (entry->text_area != event->window) + gdk_event_request_motions (event); if (entry->in_drag) { diff --git a/gtk/gtkhruler.c b/gtk/gtkhruler.c index 94d00b5146..93ccff4478 100644 --- a/gtk/gtkhruler.c +++ b/gtk/gtkhruler.c @@ -89,10 +89,8 @@ gtk_hruler_motion_notify (GtkWidget *widget, ruler = GTK_RULER (widget); - if (event->is_hint) - gdk_window_get_pointer (widget->window, &x, NULL, NULL); - else - x = event->x; + gdk_event_request_motions (event); + x = event->x; ruler->position = ruler->lower + ((ruler->upper - ruler->lower) * x) / widget->allocation.width; g_object_notify (G_OBJECT (ruler), "position"); diff --git a/gtk/gtkhsv.c b/gtk/gtkhsv.c index 0bd8ff2dec..6c4723048e 100644 --- a/gtk/gtkhsv.c +++ b/gtk/gtkhsv.c @@ -851,18 +851,11 @@ gtk_hsv_motion (GtkWidget *widget, if (priv->mode == DRAG_NONE) return FALSE; - if (event->is_hint) - { - gdk_window_get_pointer (priv->window, &ix, &iy, &mods); - x = ix; - y = iy; - } - else - { - x = event->x; - y = event->y; - } - + gdk_event_request_motions (event); + x = event->x; + y = event->y; + mods = event->state; + if (priv->mode == DRAG_H) { gtk_hsv_set_color (hsv, compute_v (hsv, x, y), priv->s, priv->v); diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 741924551e..bf2e59632b 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -1148,9 +1148,9 @@ gtk_spin_button_motion_notify (GtkWidget *widget, if (event->window == spin->panel) { - gint y; - - gdk_window_get_pointer (spin->panel, NULL, &y, NULL); + gint y = event->y; + + gdk_event_request_motions (event); if (y <= widget->requisition.height / 2 && spin->in_child == GTK_ARROW_DOWN) diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 2e82d2445e..931b0304de 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -4170,10 +4170,10 @@ gtk_text_view_motion_event (GtkWidget *widget, GdkEventMotion *event) if (event->window == text_view->text_window->bin_window && text_view->drag_start_x >= 0) { - gint x, y; + gint x = event->x; + gint y = event->y; - gdk_window_get_pointer (text_view->text_window->bin_window, - &x, &y, NULL); + gdk_event_request_motions (event); if (gtk_drag_check_threshold (widget, text_view->drag_start_x, diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c index 047cdd877f..fbce27ff20 100644 --- a/gtk/gtktooltip.c +++ b/gtk/gtktooltip.c @@ -997,8 +997,7 @@ _gtk_tooltip_handle_event (GdkEvent *event) } /* Always poll for a next motion event */ - if (event->type == GDK_MOTION_NOTIFY && event->motion.is_hint) - gdk_window_get_pointer (event->any.window, NULL, NULL, NULL); + gdk_event_request_motions (&event->motion); /* Hide the tooltip when there's no new tooltip widget */ if (!has_tooltip_widget) diff --git a/gtk/gtkvruler.c b/gtk/gtkvruler.c index 0c08c18661..1c8419c850 100644 --- a/gtk/gtkvruler.c +++ b/gtk/gtkvruler.c @@ -90,10 +90,8 @@ gtk_vruler_motion_notify (GtkWidget *widget, ruler = GTK_RULER (widget); - if (event->is_hint) - gdk_window_get_pointer (widget->window, NULL, &y, NULL); - else - y = event->y; + gdk_event_request_motions (event); + y = event->y; ruler->position = ruler->lower + ((ruler->upper - ruler->lower) * y) / widget->allocation.height; g_object_notify (G_OBJECT (ruler), "position");