scrolledwindow: Fully reset indicators' state on unrealize

This avoids timers to run after realize(), and inconsistent initial states
if the scrolledwindow is just realized again.
This commit is contained in:
Carlos Garnacho 2015-02-17 16:15:26 +01:00
parent b3043e429b
commit c473afbdc9

View File

@ -4030,6 +4030,41 @@ gtk_scrolled_window_realize (GtkWidget *widget)
gtk_scrolled_window_update_use_indicators (scrolled_window); gtk_scrolled_window_update_use_indicators (scrolled_window);
} }
static void
indicator_reset (Indicator *indicator)
{
if (indicator->conceil_timer)
{
g_source_remove (indicator->conceil_timer);
indicator->conceil_timer = 0;
}
if (indicator->over_timeout_id)
{
g_source_remove (indicator->over_timeout_id);
indicator->over_timeout_id = 0;
}
if (indicator->scrollbar && indicator->tick_id)
{
gtk_widget_remove_tick_callback (indicator->scrollbar,
indicator->tick_id);
indicator->tick_id = 0;
}
if (indicator->window)
{
gdk_window_destroy (indicator->window);
indicator->window = NULL;
}
indicator->scrollbar = NULL;
indicator->dragging = FALSE;
indicator->over = FALSE;
indicator->current_pos = indicator->source_pos = indicator->target_pos = 0;
indicator->start_time = indicator->end_time = indicator->last_scroll_time = 0;
}
static void static void
gtk_scrolled_window_unrealize (GtkWidget *widget) gtk_scrolled_window_unrealize (GtkWidget *widget)
{ {
@ -4038,13 +4073,11 @@ gtk_scrolled_window_unrealize (GtkWidget *widget)
gtk_widget_set_parent_window (priv->hscrollbar, NULL); gtk_widget_set_parent_window (priv->hscrollbar, NULL);
gtk_widget_unregister_window (widget, priv->hindicator.window); gtk_widget_unregister_window (widget, priv->hindicator.window);
gdk_window_destroy (priv->hindicator.window); indicator_reset (&priv->hindicator);
priv->hindicator.window = NULL;
gtk_widget_set_parent_window (priv->vscrollbar, NULL); gtk_widget_set_parent_window (priv->vscrollbar, NULL);
gtk_widget_unregister_window (widget, priv->vindicator.window); gtk_widget_unregister_window (widget, priv->vindicator.window);
gdk_window_destroy (priv->vindicator.window); indicator_reset (&priv->hindicator);
priv->vindicator.window = NULL;
GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->unrealize (widget); GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->unrealize (widget);
} }