Commit 6c1bee23 authored by Carlos Garnacho's avatar Carlos Garnacho

GtkNotebook: Unify two private variables

Button state was being kept in two separate variables, which lead
to slight confusions in DnD that caused the notebook to ignore the
first click after DnD happened from (within) it. Unify these two
into one, which helps us keep better track of the really pressed
buttons.
parent da31eb4f
...@@ -205,7 +205,6 @@ struct _GtkNotebookPrivate ...@@ -205,7 +205,6 @@ struct _GtkNotebookPrivate
guint32 timer; guint32 timer;
guint button : 2;
guint child_has_focus : 1; guint child_has_focus : 1;
guint click_child : 3; guint click_child : 3;
guint remove_in_detach : 1; guint remove_in_detach : 1;
...@@ -1273,13 +1272,12 @@ gtk_notebook_init (GtkNotebook *notebook) ...@@ -1273,13 +1272,12 @@ gtk_notebook_init (GtkNotebook *notebook)
priv->scrollable = FALSE; priv->scrollable = FALSE;
priv->in_child = ARROW_NONE; priv->in_child = ARROW_NONE;
priv->click_child = 0; priv->click_child = 0;
priv->button = 0;
priv->need_timer = 0; priv->need_timer = 0;
priv->child_has_focus = FALSE; priv->child_has_focus = FALSE;
priv->focus_out = FALSE; priv->focus_out = FALSE;
priv->group = 0; priv->group = 0;
priv->pressed_button = -1; priv->pressed_button = 0;
priv->dnd_timer = 0; priv->dnd_timer = 0;
priv->switch_tab_timer = 0; priv->switch_tab_timer = 0;
priv->source_targets = gtk_target_list_new (notebook_targets, priv->source_targets = gtk_target_list_new (notebook_targets,
...@@ -2606,10 +2604,13 @@ gtk_notebook_arrow_button_press (GtkNotebook *notebook, ...@@ -2606,10 +2604,13 @@ gtk_notebook_arrow_button_press (GtkNotebook *notebook,
gboolean left = (ARROW_IS_LEFT (arrow) && !is_rtl) || gboolean left = (ARROW_IS_LEFT (arrow) && !is_rtl) ||
(!ARROW_IS_LEFT (arrow) && is_rtl); (!ARROW_IS_LEFT (arrow) && is_rtl);
if (priv->pressed_button)
return FALSE;
if (!gtk_widget_has_focus (widget)) if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget); gtk_widget_grab_focus (widget);
priv->button = button; priv->pressed_button = button;
priv->click_child = arrow; priv->click_child = arrow;
if (button == GDK_BUTTON_PRIMARY) if (button == GDK_BUTTON_PRIMARY)
...@@ -2711,8 +2712,7 @@ gtk_notebook_button_press (GtkWidget *widget, ...@@ -2711,8 +2712,7 @@ gtk_notebook_button_press (GtkWidget *widget,
GtkNotebookArrow arrow; GtkNotebookArrow arrow;
gdouble x, y; gdouble x, y;
if (event->type != GDK_BUTTON_PRESS || !priv->children || if (event->type != GDK_BUTTON_PRESS || !priv->children)
priv->button)
return FALSE; return FALSE;
if (!get_widget_coordinates (widget, (GdkEvent *)event, &x, &y)) if (!get_widget_coordinates (widget, (GdkEvent *)event, &x, &y))
...@@ -2732,7 +2732,7 @@ gtk_notebook_button_press (GtkWidget *widget, ...@@ -2732,7 +2732,7 @@ gtk_notebook_button_press (GtkWidget *widget,
if (event->button != GDK_BUTTON_PRIMARY) if (event->button != GDK_BUTTON_PRIMARY)
return FALSE; return FALSE;
priv->button = event->button; priv->pressed_button = event->button;
if ((tab = get_tab_at_pos (notebook, x, y)) != NULL) if ((tab = get_tab_at_pos (notebook, x, y)) != NULL)
{ {
...@@ -2752,8 +2752,6 @@ gtk_notebook_button_press (GtkWidget *widget, ...@@ -2752,8 +2752,6 @@ gtk_notebook_button_press (GtkWidget *widget,
/* save press to possibly begin a drag */ /* save press to possibly begin a drag */
if (page->reorderable || page->detachable) if (page->reorderable || page->detachable)
{ {
priv->pressed_button = event->button;
priv->mouse_x = x; priv->mouse_x = x;
priv->mouse_y = y; priv->mouse_y = y;
...@@ -2841,7 +2839,7 @@ stop_scrolling (GtkNotebook *notebook) ...@@ -2841,7 +2839,7 @@ stop_scrolling (GtkNotebook *notebook)
priv->need_timer = FALSE; priv->need_timer = FALSE;
} }
priv->click_child = 0; priv->click_child = 0;
priv->button = 0; priv->pressed_button = 0;
gtk_notebook_redraw_arrows (notebook); gtk_notebook_redraw_arrows (notebook);
} }
...@@ -3009,7 +3007,7 @@ gtk_notebook_stop_reorder (GtkNotebook *notebook) ...@@ -3009,7 +3007,7 @@ gtk_notebook_stop_reorder (GtkNotebook *notebook)
if (!page || !page->tab_label) if (!page || !page->tab_label)
return; return;
priv->pressed_button = -1; priv->pressed_button = 0;
if (page->reorderable || page->detachable) if (page->reorderable || page->detachable)
{ {
...@@ -3062,19 +3060,16 @@ gtk_notebook_button_release (GtkWidget *widget, ...@@ -3062,19 +3060,16 @@ gtk_notebook_button_release (GtkWidget *widget,
notebook = GTK_NOTEBOOK (widget); notebook = GTK_NOTEBOOK (widget);
priv = notebook->priv; priv = notebook->priv;
if (priv->pressed_button != event->button)
return FALSE;
if (priv->operation == DRAG_OPERATION_REORDER && if (priv->operation == DRAG_OPERATION_REORDER &&
priv->cur_page && priv->cur_page &&
priv->cur_page->reorderable && priv->cur_page->reorderable)
event->button == priv->pressed_button)
gtk_notebook_stop_reorder (notebook); gtk_notebook_stop_reorder (notebook);
if (event->button == priv->button) stop_scrolling (notebook);
{ return TRUE;
stop_scrolling (notebook);
return TRUE;
}
else
return FALSE;
} }
static void static void
...@@ -3262,7 +3257,7 @@ gtk_notebook_motion_notify (GtkWidget *widget, ...@@ -3262,7 +3257,7 @@ gtk_notebook_motion_notify (GtkWidget *widget,
return FALSE; return FALSE;
if (!(event->state & GDK_BUTTON1_MASK) && if (!(event->state & GDK_BUTTON1_MASK) &&
priv->pressed_button != -1) priv->pressed_button != 0)
{ {
gtk_notebook_stop_reorder (notebook); gtk_notebook_stop_reorder (notebook);
stop_scrolling (notebook); stop_scrolling (notebook);
...@@ -3285,7 +3280,7 @@ gtk_notebook_motion_notify (GtkWidget *widget, ...@@ -3285,7 +3280,7 @@ gtk_notebook_motion_notify (GtkWidget *widget,
gtk_notebook_redraw_arrows (notebook); gtk_notebook_redraw_arrows (notebook);
} }
if (priv->pressed_button == -1) if (priv->pressed_button == 0)
return FALSE; return FALSE;
if (page->detachable && if (page->detachable &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment