Remove :active state handling on widgets

This commit is contained in:
Timm Bäder 2019-01-25 17:17:20 +01:00
parent 1b504a3303
commit 20429f4764
5 changed files with 5 additions and 139 deletions

View File

@ -133,7 +133,6 @@ static void gtk_button_display_changed (GtkWidget *widget,
static void gtk_button_unrealize (GtkWidget * widget);
static void gtk_real_button_clicked (GtkButton * button);
static void gtk_real_button_activate (GtkButton *button);
static void gtk_button_update_state (GtkButton *button);
static void gtk_button_finish_activate (GtkButton *button,
gboolean do_it);
@ -305,10 +304,8 @@ multipress_pressed_cb (GtkGestureMultiPress *gesture,
priv->in_button = TRUE;
if (!priv->activate_timeout)
{
priv->button_down = TRUE;
gtk_button_update_state (button);
}
priv->button_down = TRUE;
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
}
@ -358,33 +355,7 @@ multipress_released_cb (GtkGestureMultiPress *gesture,
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
if (sequence)
{
priv->in_button = FALSE;
gtk_button_update_state (button);
}
}
static void
multipress_gesture_update_cb (GtkGesture *gesture,
GdkEventSequence *sequence,
GtkButton *button)
{
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
gboolean in_button;
gdouble x, y;
if (sequence != gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)))
return;
gtk_gesture_get_point (gesture, sequence, &x, &y);
in_button = gtk_widget_contains (GTK_WIDGET (button), x, y);
if (priv->in_button != in_button)
{
priv->in_button = in_button;
gtk_button_update_state (button);
}
priv->in_button = FALSE;
}
static void
@ -457,7 +428,6 @@ gtk_button_init (GtkButton *button)
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->gesture), GDK_BUTTON_PRIMARY);
g_signal_connect (priv->gesture, "pressed", G_CALLBACK (multipress_pressed_cb), button);
g_signal_connect (priv->gesture, "released", G_CALLBACK (multipress_released_cb), button);
g_signal_connect (priv->gesture, "update", G_CALLBACK (multipress_gesture_update_cb), button);
g_signal_connect (priv->gesture, "cancel", G_CALLBACK (multipress_gesture_cancel_cb), button);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->gesture), GTK_PHASE_CAPTURE);
gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (priv->gesture));
@ -772,8 +742,6 @@ gtk_button_do_release (GtkButton *button,
if (emit_clicked)
gtk_button_clicked (button);
gtk_button_update_state (button);
}
}
@ -805,7 +773,6 @@ gtk_real_button_activate (GtkButton *button)
priv->activate_timeout = g_timeout_add (ACTIVATE_TIMEOUT, button_activate_timeout, button);
g_source_set_name_by_id (priv->activate_timeout, "[gtk+] button_activate_timeout");
priv->button_down = TRUE;
gtk_button_update_state (button);
}
}
@ -820,8 +787,6 @@ gtk_button_finish_activate (GtkButton *button,
priv->button_down = FALSE;
gtk_button_update_state (button);
if (do_it)
gtk_button_clicked (button);
}
@ -957,26 +922,6 @@ gtk_button_get_use_underline (GtkButton *button)
return priv->use_underline;
}
static void
gtk_button_update_state (GtkButton *button)
{
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
GtkStateFlags new_state;
gboolean depressed;
if (priv->activate_timeout)
depressed = TRUE;
else
depressed = priv->in_button && priv->button_down;
new_state = gtk_widget_get_state_flags (GTK_WIDGET (button)) & ~(GTK_STATE_FLAG_ACTIVE);
if (depressed)
new_state |= GTK_STATE_FLAG_ACTIVE;
gtk_widget_set_state_flags (GTK_WIDGET (button), new_state, TRUE);
}
static void
gtk_button_display_changed (GtkWidget *widget,
GdkDisplay *previous_display)
@ -986,11 +931,7 @@ gtk_button_display_changed (GtkWidget *widget,
/* If the button is being pressed while the display changes the
release might never occur, so we reset the state. */
if (priv->button_down)
{
priv->button_down = FALSE;
gtk_button_update_state (button);
}
priv->button_down = FALSE;
}
static void

View File

@ -1744,9 +1744,6 @@ gtk_list_box_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
if (row != NULL && gtk_widget_is_sensitive (GTK_WIDGET (row)))
{
priv->active_row = row;
gtk_widget_set_state_flags (GTK_WIDGET (priv->active_row),
GTK_STATE_FLAG_ACTIVE,
FALSE);
if (n_press == 2 && !priv->activate_single_click)
gtk_list_box_activate (box, row);
@ -1842,7 +1839,6 @@ gtk_list_box_multipress_gesture_released (GtkGestureMultiPress *gesture,
if (priv->active_row)
{
gtk_widget_unset_state_flags (GTK_WIDGET (priv->active_row), GTK_STATE_FLAG_ACTIVE);
priv->active_row = NULL;
}
@ -1857,7 +1853,6 @@ gtk_list_box_multipress_gesture_stopped (GtkGestureMultiPress *gesture,
if (priv->active_row)
{
gtk_widget_unset_state_flags (GTK_WIDGET (priv->active_row), GTK_STATE_FLAG_ACTIVE);
priv->active_row = NULL;
gtk_widget_queue_draw (GTK_WIDGET (box));
}
@ -2321,10 +2316,7 @@ gtk_list_box_remove (GtkContainer *container,
if (row == priv->cursor_row)
priv->cursor_row = NULL;
if (row == priv->active_row)
{
gtk_widget_unset_state_flags (GTK_WIDGET (row), GTK_STATE_FLAG_ACTIVE);
priv->active_row = NULL;
}
priv->active_row = NULL;
if (row == priv->drag_highlighted_row)
gtk_list_box_drag_unhighlight_row (box);

View File

@ -3040,8 +3040,6 @@ gtk_menu_handle_scrolling (GtkMenu *menu,
if ((priv->upper_arrow_state & GTK_STATE_FLAG_INSENSITIVE) == 0)
{
gboolean arrow_pressed = FALSE;
if (gtk_widget_get_child_visible (priv->top_arrow_widget))
{
scroll_fast = (y < rect.y + MENU_SCROLL_FAST_ZONE);
@ -3083,9 +3081,6 @@ gtk_menu_handle_scrolling (GtkMenu *menu,
{
GtkStateFlags arrow_state = 0;
if (arrow_pressed)
arrow_state |= GTK_STATE_FLAG_ACTIVE;
if (priv->upper_arrow_prelight)
arrow_state |= GTK_STATE_FLAG_PRELIGHT;
@ -3111,8 +3106,6 @@ gtk_menu_handle_scrolling (GtkMenu *menu,
if ((priv->lower_arrow_state & GTK_STATE_FLAG_INSENSITIVE) == 0)
{
gboolean arrow_pressed = FALSE;
if (gtk_widget_get_child_visible (priv->bottom_arrow_widget))
{
scroll_fast = (y > rect.y + rect.height - MENU_SCROLL_FAST_ZONE);
@ -3154,9 +3147,6 @@ gtk_menu_handle_scrolling (GtkMenu *menu,
{
GtkStateFlags arrow_state = 0;
if (arrow_pressed)
arrow_state |= GTK_STATE_FLAG_ACTIVE;
if (priv->lower_arrow_prelight)
arrow_state |= GTK_STATE_FLAG_PRELIGHT;

View File

@ -1622,28 +1622,6 @@ gtk_range_unmap (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_range_parent_class)->unmap (widget);
}
static void
update_slider_state (GtkRange *range)
{
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
if (priv->grab_location == priv->slider_widget)
gtk_widget_set_state_flags (priv->slider_widget, GTK_STATE_FLAG_ACTIVE, FALSE);
else
gtk_widget_unset_state_flags (priv->slider_widget, GTK_STATE_FLAG_ACTIVE);
}
static void
update_trough_state (GtkRange *range)
{
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
if (priv->grab_location == priv->trough_widget)
gtk_widget_set_state_flags (priv->trough_widget, GTK_STATE_FLAG_ACTIVE, FALSE);
else
gtk_widget_unset_state_flags (priv->trough_widget, GTK_STATE_FLAG_ACTIVE);
}
static void
gtk_range_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction)
@ -1699,9 +1677,6 @@ range_grab_add (GtkRange *range,
*/
priv->grab_location = location;
update_trough_state (range);
update_slider_state (range);
gtk_style_context_add_class (context, "dragging");
}
@ -1735,8 +1710,6 @@ range_grab_remove (GtkRange *range)
priv->grab_location = NULL;
update_trough_state (range);
update_slider_state (range);
update_zoom_state (range, FALSE);
gtk_style_context_remove_class (context, "dragging");

View File

@ -109,34 +109,6 @@ _text_handle_pos_from_widget (GtkTextHandle *handle,
return -1;
}
static void
gtk_text_handle_set_state (GtkTextHandle *handle,
gint pos,
GtkStateFlags state)
{
GtkTextHandlePrivate *priv = handle->priv;
if (!priv->windows[pos].widget)
return;
gtk_widget_set_state_flags (priv->windows[pos].widget, state, FALSE);
gtk_widget_queue_draw (priv->windows[pos].widget);
}
static void
gtk_text_handle_unset_state (GtkTextHandle *handle,
gint pos,
GtkStateFlags state)
{
GtkTextHandlePrivate *priv = handle->priv;
if (!priv->windows[pos].widget)
return;
gtk_widget_unset_state_flags (priv->windows[pos].widget, state);
gtk_widget_queue_draw (priv->windows[pos].widget);
}
static void
handle_drag_begin (GtkGestureDrag *gesture,
gdouble x,
@ -164,7 +136,6 @@ handle_drag_begin (GtkGestureDrag *gesture,
priv->windows[pos].dx = x;
priv->windows[pos].dy = y;
priv->windows[pos].dragged = TRUE;
gtk_text_handle_set_state (handle, pos, GTK_STATE_FLAG_ACTIVE);
g_signal_emit (handle, signals[DRAG_STARTED], 0, pos);
}
@ -202,7 +173,6 @@ handle_drag_end (GtkGestureDrag *gesture,
gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)));
g_signal_emit (handle, signals[DRAG_FINISHED], 0, pos);
priv->windows[pos].dragged = FALSE;
gtk_text_handle_unset_state (handle, pos, GTK_STATE_FLAG_ACTIVE);
}
static void