Index: gdk/gdkevents.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkevents.c,v
retrieving revision 1.76
diff -u -p -r1.76 gdkevents.c
--- gdk/gdkevents.c	6 Dec 2005 10:40:09 -0000	1.76
+++ gdk/gdkevents.c	14 Nov 2006 18:13:23 -0000
@@ -644,6 +644,10 @@ gdk_event_get_state (GdkEvent        *ev
  * @y_win: location to put event window y coordinate
  * 
  * Extract the event window relative x/y coordinates from an event.
+ * The events that deliver window coordinates are:
+ *
+ * #GdkEventConfigure, #GdkEventScroll, #GdkEventCrossing, #GdkEventMotion
+ * and #GdkEventButton.
  * 
  * Return value: %TRUE if the event delivered event window coordinates
  **/
Index: gtk/gtkwidget.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.c,v
retrieving revision 1.446
diff -u -p -r1.446 gtkwidget.c
--- gtk/gtkwidget.c	8 Oct 2006 05:07:45 -0000	1.446
+++ gtk/gtkwidget.c	14 Nov 2006 18:13:29 -0000
@@ -1,3 +1,4 @@
+/* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
 /* GTK - The GIMP Toolkit
  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  *
@@ -8054,6 +8055,68 @@ gtk_widget_set_no_show_all (GtkWidget *w
     GTK_WIDGET_UNSET_FLAGS (widget, GTK_NO_SHOW_ALL);
   
   g_object_notify (G_OBJECT (widget), "no-show-all");
+}
+
+/**
+ * gtk_widget_get_event_position:
+ * @widget: a #GtkWidget
+ * @event: a #GdkEvent
+ * @x: return location for the x coordinate (relative to @widget)
+ * @y: return location for the y coordinate (relative to @widget)
+ * 
+ * Gets the x/y coordinates from an event in values relative
+ * to the given widget instead of the event window. This will only work
+ * if the widget is realized, both the given widget and the event window
+ * widget share a common toplevel and the event delivers event window
+ * coordinates.
+ *
+ * For a list of events that deliver window events (and therefore, where
+ * this function can be used), see gdk_event_get_coords().
+ *
+ * Return Value: #FALSE if the widget is not realized, the widget and
+ * the event window do not share a common toplevel, or the event doesn't
+ * deliver event window coordinates. Otherwise #TRUE.
+ *
+ * Since: 2.12
+ **/
+gboolean
+gtk_widget_get_event_position (GtkWidget *widget,
+			       GdkEvent  *event,
+			       gint      *x,
+			       gint      *y)
+{
+  GtkWidget *event_widget;
+  gdouble event_x, event_y;
+  gint window_x, window_y, coord_x, coord_y;
+  gboolean event_delivers_coordinates;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+  g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), FALSE);
+  g_return_val_if_fail (event != NULL, FALSE);
+
+  event_delivers_coordinates = gdk_event_get_coords (event, &event_x, &event_y);
+
+  if (!event_delivers_coordinates)
+    return FALSE;
+
+  gdk_window_get_user_data (((GdkEventAny*) event)->window, &event_widget);
+  gdk_window_get_position (((GdkEventAny*) event)->window, &window_x, &window_y);
+
+  coord_x = window_x - event_widget->allocation.x + (gint) event_x;
+  coord_y = window_y - event_widget->allocation.y + (gint) event_y;
+
+  if (widget == event_widget)
+    {
+      if (x)
+       *x = coord_x;
+
+      if (y)
+       *y = coord_y;
+
+      return TRUE;
+    }
+  else
+    return gtk_widget_translate_coordinates (event_widget, widget, (gint) event_x, (gint) event_y, x, y);
 }
 
 #define __GTK_WIDGET_C__
Index: gtk/gtkwidget.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.h,v
retrieving revision 1.159
diff -u -p -r1.159 gtkwidget.h
--- gtk/gtkwidget.h	25 Apr 2006 14:27:31 -0000	1.159
+++ gtk/gtkwidget.h	14 Nov 2006 18:13:29 -0000
@@ -634,6 +634,10 @@ gboolean     gtk_widget_translate_coordi
 					       gint        src_y,
 					       gint       *dest_x,
 					       gint       *dest_y);
+gboolean     gtk_widget_get_event_position    (GtkWidget *widget,
+					       GdkEvent  *event,
+					       gint      *x,
+					       gint      *y);
 
 /* Hide widget and return TRUE.
  */
Index: gtk/gtknotebook.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtknotebook.c,v
retrieving revision 1.230
diff -u -p -r1.230 gtknotebook.c
--- gtk/gtknotebook.c	7 Nov 2006 16:54:34 -0000	1.230
+++ gtk/gtknotebook.c	14 Nov 2006 18:13:34 -0000
@@ -7410,5 +7410,39 @@ gtk_notebook_set_tab_detachable (GtkNote
     }
 }
 
+/**
+ * gtk_notebook_get_tab_at_pos:
+ * @notebook: a #GtkNotebook
+ * @x: x coordinate (relative to the notebook widget)
+ * @y: y coordinate (relative to the notebook widget)
+ * 
+ * Returns the index corresponding to the tab under the x/y
+ * coordinates, or -1 if no tab is found in these coordinates.
+ *
+ * To translate the coordinates from a #GdkEvent into widget
+ * relative coordinates, see gtk_widget_get_event_position().
+ * 
+ * Return Value: The index corresponding to the tab, or -1.
+ *
+ * Since: 2.12
+ **/
+gint
+gtk_notebook_get_tab_at_pos (GtkNotebook *notebook,
+			     gint         x,
+			     gint         y)
+{
+  GtkWidget *widget;
+  GList *page;
+
+  g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), -1);
+
+  widget = GTK_WIDGET (notebook);
+  x += widget->allocation.x;
+  y += widget->allocation.y;
+
+  page = get_tab_at_pos (notebook, x, y);
+  return g_list_position (notebook->children, page);
+}
+
 #define __GTK_NOTEBOOK_C__
 #include "gtkaliasdef.c"
Index: gtk/gtknotebook.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtknotebook.h,v
retrieving revision 1.40
diff -u -p -r1.40 gtknotebook.h
--- gtk/gtknotebook.h	8 Jun 2006 00:17:00 -0000	1.40
+++ gtk/gtknotebook.h	14 Nov 2006 18:13:35 -0000
@@ -267,6 +267,9 @@ gboolean gtk_notebook_get_tab_detachable
 void gtk_notebook_set_tab_detachable      (GtkNotebook *notebook,
 					   GtkWidget   *child,
 					   gboolean     detachable);
+gint gtk_notebook_get_tab_at_pos          (GtkNotebook *notebook,
+					   gint         x,
+					   gint         y);
 
 #ifndef GTK_DISABLE_DEPRECATED
 #define	gtk_notebook_current_page               gtk_notebook_get_current_page
