summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Brabec <sbrabec@suse.cz>2009-06-23 14:05:32 -0500
committerFederico Mena Quintero <federico@novell.com>2009-06-23 14:37:56 -0500
commitbc27497020de7287c74a012b8f6a49c9f30c35b8 (patch)
tree9cfbbf01abb7261a40b8334bca22670ee3083087
parent072ddd923d23956d48acaa5fed8e26ca89e57f18 (diff)
downloadgtk+-bc27497020de7287c74a012b8f6a49c9f30c35b8.tar.gz
bgo#529908 - Sanitize handling of motion events in GtkNotebook
GtkNotebook used gdk_window_get_pointer() incorrectly, as it already had coordinates from various GdkEvents. Using get_pointer() means that you get pointer positions *after* the event has happened, which leads to visual out-of-sync results, or inadvertently detached tabs if you click on them while your machine is being slow. Signed-off-by: Federico Mena Quintero <federico@novell.com>
-rw-r--r--gtk/gtknotebook.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 2e0e8dd2f6..aa1a5ade06 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -2532,10 +2532,8 @@ gtk_notebook_button_press (GtkWidget *widget,
priv->during_reorder = FALSE;
priv->pressed_button = event->button;
- gdk_window_get_pointer (widget->window,
- &priv->mouse_x,
- &priv->mouse_y,
- NULL);
+ priv->mouse_x = x;
+ priv->mouse_y = y;
priv->drag_begin_x = priv->mouse_x;
priv->drag_begin_y = priv->mouse_y;
@@ -2969,6 +2967,7 @@ gtk_notebook_motion_notify (GtkWidget *widget,
GtkNotebookPointerPosition pointer_position;
GtkSettings *settings;
guint timeout;
+ gint x_win, y_win;
page = notebook->cur_page;
@@ -2986,10 +2985,14 @@ gtk_notebook_motion_notify (GtkWidget *widget,
return FALSE;
priv->timestamp = event->time;
- gdk_window_get_pointer (widget->window,
- &priv->mouse_x,
- &priv->mouse_y,
- NULL);
+
+ /* While animating the move, event->x is relative to the flying tab
+ * (priv->drag_window has a pointer grab), but we need coordinates relative to
+ * the notebook widget.
+ */
+ gdk_window_get_origin (widget->window, &x_win, &y_win);
+ priv->mouse_x = event->x_root - x_win;
+ priv->mouse_y = event->y_root - y_win;
arrow = gtk_notebook_get_arrow (notebook, priv->mouse_x, priv->mouse_y);
if (arrow != notebook->in_child)