diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-04-07 21:36:40 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-04-08 08:42:25 -0400 |
commit | ef982b7d46125f206b59ae4222d26947bda86246 (patch) | |
tree | 02793fc177d5737d5177cfcc0bfa4e0191c5ec26 | |
parent | 1b362d1f01f114a6d5a324158a50a90e6b9a010b (diff) | |
download | gtk+-ef982b7d46125f206b59ae4222d26947bda86246.tar.gz |
Rename things
Rename the can-pick property to can-target,
and redo the pick flags with more descriptive names.
-rw-r--r-- | demos/gtk-demo/dnd.c | 2 | ||||
-rw-r--r-- | demos/gtk-demo/overlay.c | 2 | ||||
-rw-r--r-- | demos/gtk-demo/overlay2.c | 4 | ||||
-rw-r--r-- | demos/gtk-demo/sliding_puzzle.c | 2 | ||||
-rw-r--r-- | docs/reference/gtk/gtk4-sections.txt | 4 | ||||
-rw-r--r-- | gtk/gtkentry.c | 2 | ||||
-rw-r--r-- | gtk/gtkenums.h | 8 | ||||
-rw-r--r-- | gtk/gtkflowbox.c | 2 | ||||
-rw-r--r-- | gtk/gtkmain.c | 4 | ||||
-rw-r--r-- | gtk/gtkpointerfocus.c | 2 | ||||
-rw-r--r-- | gtk/gtkrange.c | 2 | ||||
-rw-r--r-- | gtk/gtktooltip.c | 2 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 56 | ||||
-rw-r--r-- | gtk/gtkwidget.h | 6 | ||||
-rw-r--r-- | gtk/gtkwidgetprivate.h | 2 | ||||
-rw-r--r-- | gtk/inspector/inspect-button.c | 2 | ||||
-rw-r--r-- | tests/testoverlay.c | 2 | ||||
-rw-r--r-- | tests/testwidgettransforms.c | 4 |
18 files changed, 56 insertions, 52 deletions
diff --git a/demos/gtk-demo/dnd.c b/demos/gtk-demo/dnd.c index 7ee7591e74..e8c184cdcc 100644 --- a/demos/gtk-demo/dnd.c +++ b/demos/gtk-demo/dnd.c @@ -243,7 +243,7 @@ pressed_cb (GtkGesture *gesture, GtkWidget *child; widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)); - child = gtk_widget_pick (widget, x, y, 0); + child = gtk_widget_pick (widget, x, y, GTK_PICK_DEFAULT); if (gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)) == GDK_BUTTON_SECONDARY) { diff --git a/demos/gtk-demo/overlay.c b/demos/gtk-demo/overlay.c index f2c67bad20..0e2f42a0e0 100644 --- a/demos/gtk-demo/overlay.c +++ b/demos/gtk-demo/overlay.c @@ -57,7 +57,7 @@ do_overlay (GtkWidget *do_widget) vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox); - gtk_widget_set_can_pick (vbox, FALSE); + gtk_widget_set_can_target (vbox, FALSE); gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER); gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER); diff --git a/demos/gtk-demo/overlay2.c b/demos/gtk-demo/overlay2.c index 67c72a0a2c..f26a10dc5f 100644 --- a/demos/gtk-demo/overlay2.c +++ b/demos/gtk-demo/overlay2.c @@ -66,13 +66,13 @@ do_overlay2 (GtkWidget *do_widget) image = gtk_picture_new_for_resource ("/overlay2/decor1.png"); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), image); - gtk_widget_set_can_pick (image, FALSE); + gtk_widget_set_can_target (image, FALSE); gtk_widget_set_halign (image, GTK_ALIGN_START); gtk_widget_set_valign (image, GTK_ALIGN_START); image = gtk_picture_new_for_resource ("/overlay2/decor2.png"); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), image); - gtk_widget_set_can_pick (image, FALSE); + gtk_widget_set_can_target (image, FALSE); gtk_widget_set_halign (image, GTK_ALIGN_END); gtk_widget_set_valign (image, GTK_ALIGN_END); diff --git a/demos/gtk-demo/sliding_puzzle.c b/demos/gtk-demo/sliding_puzzle.c index 2cba018d27..3cfb182d88 100644 --- a/demos/gtk-demo/sliding_puzzle.c +++ b/demos/gtk-demo/sliding_puzzle.c @@ -228,7 +228,7 @@ puzzle_button_pressed (GtkGestureMultiPress *gesture, int l, t, i; int pos; - child = gtk_widget_pick (grid, x, y, 0); + child = gtk_widget_pick (grid, x, y, GTK_PICK_DEFAULT); if (!child) { diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index b25a5d717d..3936a524d6 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -4516,8 +4516,8 @@ gtk_widget_set_can_focus gtk_widget_get_focus_on_click gtk_widget_set_focus_on_click gtk_widget_set_focus_child -gtk_widget_get_can_pick -gtk_widget_set_can_pick +gtk_widget_get_can_target +gtk_widget_set_can_target gtk_widget_get_has_surface gtk_widget_set_has_surface gtk_widget_get_sensitive diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index eafc963790..faa64decbf 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -3117,7 +3117,7 @@ gtk_entry_ensure_progress_widget (GtkEntry *entry) priv->progress_widget = g_object_new (GTK_TYPE_PROGRESS_BAR, "css-name", "progress", NULL); - gtk_widget_set_can_pick (priv->progress_widget, FALSE); + gtk_widget_set_can_target (priv->progress_widget, FALSE); gtk_widget_set_parent (priv->progress_widget, GTK_WIDGET (entry)); diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index 6081988278..dc097d2853 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -1042,12 +1042,16 @@ typedef enum { /** * GtkPickFlags: - * @GTK_PICK_ALL: Include insensitive widgets and widgets marked as "can't pick" + * @GTK_PICK_DEFAULT: The default behavior, include widgets that are receiving events + * @GTK_PICK_INSENSITIVE: Include widgets that are insensitive + * @GTK_PICK_NON_TARGETABLE: Include widgets that are marked as non-targetable. See #GtkWidget::can-target * * Flags that influence the behavior of gtk_widget_pick() */ typedef enum { - GTK_PICK_ALL = 1 << 0 + GTK_PICK_DEFAULT = 0, + GTK_PICK_INSENSITIVE = 1 << 0, + GTK_PICK_NON_TARGETABLE = 1 << 1 } GtkPickFlags; #endif /* __GTK_ENUMS_H__ */ diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c index d134da1c69..e4bfb813fc 100644 --- a/gtk/gtkflowbox.c +++ b/gtk/gtkflowbox.c @@ -3928,7 +3928,7 @@ gtk_flow_box_get_child_at_pos (GtkFlowBox *box, gint x, gint y) { - GtkWidget *child = gtk_widget_pick (GTK_WIDGET (box), x, y, 0); + GtkWidget *child = gtk_widget_pick (GTK_WIDGET (box), x, y, GTK_PICK_DEFAULT); if (!child) return NULL; diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index e00cc59497..bf58cb9453 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -1703,7 +1703,7 @@ handle_pointing_event (GdkEvent *event) target = gtk_window_lookup_pointer_focus_implicit_grab (toplevel, device, sequence); if (!target) - target = gtk_widget_pick (toplevel_widget, x, y, 0); + target = gtk_widget_pick (toplevel_widget, x, y, GTK_PICK_DEFAULT); if (!target) target = toplevel_widget; @@ -1742,7 +1742,7 @@ handle_pointing_event (GdkEvent *event) if (event->any.type == GDK_BUTTON_RELEASE) { GtkWidget *new_target; - new_target = gtk_widget_pick (GTK_WIDGET (toplevel), x, y, 0); + new_target = gtk_widget_pick (GTK_WIDGET (toplevel), x, y, GTK_PICK_DEFAULT); if (new_target == NULL) new_target = GTK_WIDGET (toplevel); gtk_synthesize_crossing_events (GTK_ROOT (toplevel), target, new_target, event, diff --git a/gtk/gtkpointerfocus.c b/gtk/gtkpointerfocus.c index cb338a11e8..c24243d718 100644 --- a/gtk/gtkpointerfocus.c +++ b/gtk/gtkpointerfocus.c @@ -135,7 +135,7 @@ gtk_pointer_focus_repick_target (GtkPointerFocus *focus) { GtkWidget *target; - target = gtk_widget_pick (GTK_WIDGET (focus->toplevel), focus->x, focus->y, 0); + target = gtk_widget_pick (GTK_WIDGET (focus->toplevel), focus->x, focus->y, GTK_PICK_DEFAULT); if (target == NULL) target = GTK_WIDGET (focus->toplevel); gtk_pointer_focus_set_target (focus, target); diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 9b430d79c9..06a0559b47 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -1865,7 +1865,7 @@ gtk_range_long_press_gesture_pressed (GtkGestureLongPress *gesture, GtkRangePrivate *priv = gtk_range_get_instance_private (range); GtkWidget *mouse_location; - mouse_location = gtk_widget_pick (GTK_WIDGET (range), x, y, 0); + mouse_location = gtk_widget_pick (GTK_WIDGET (range), x, y, GTK_PICK_DEFAULT); if (mouse_location == priv->slider_widget && !priv->zoom) { diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c index 3d5a9d0aac..794d65c30d 100644 --- a/gtk/gtktooltip.c +++ b/gtk/gtktooltip.c @@ -434,7 +434,7 @@ _gtk_widget_find_at_coords (GdkSurface *surface, if (!event_widget) return NULL; - picked_widget = gtk_widget_pick (event_widget, surface_x, surface_y, GTK_PICK_ALL); + picked_widget = gtk_widget_pick (event_widget, surface_x, surface_y, GTK_PICK_INSENSITIVE); if (picked_widget != NULL) gtk_widget_translate_coordinates (event_widget, picked_widget, surface_x, surface_y, widget_x, widget_y); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index ff728fed8b..ed93a7ba20 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -546,7 +546,7 @@ enum { PROP_CAN_FOCUS, PROP_HAS_FOCUS, PROP_IS_FOCUS, - PROP_CAN_PICK, + PROP_CAN_TARGET, PROP_FOCUS_ON_CLICK, PROP_CAN_DEFAULT, PROP_HAS_DEFAULT, @@ -1012,9 +1012,9 @@ gtk_widget_class_init (GtkWidgetClass *klass) FALSE, GTK_PARAM_READWRITE); - widget_props[PROP_CAN_PICK] = - g_param_spec_boolean ("can-pick", - P_("Can pick"), + widget_props[PROP_CAN_TARGET] = + g_param_spec_boolean ("can-target", + P_("Can target"), P_("Whether the widget can receive pointer events"), FALSE, GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY); @@ -2187,8 +2187,8 @@ gtk_widget_set_property (GObject *object, if (g_value_get_boolean (value)) gtk_widget_grab_focus (widget); break; - case PROP_CAN_PICK: - gtk_widget_set_can_pick (widget, g_value_get_boolean (value)); + case PROP_CAN_TARGET: + gtk_widget_set_can_target (widget, g_value_get_boolean (value)); break; case PROP_FOCUS_ON_CLICK: gtk_widget_set_focus_on_click (widget, g_value_get_boolean (value)); @@ -2368,8 +2368,8 @@ gtk_widget_get_property (GObject *object, case PROP_IS_FOCUS: g_value_set_boolean (value, gtk_widget_is_focus (widget)); break; - case PROP_CAN_PICK: - g_value_set_boolean (value, gtk_widget_get_can_pick (widget)); + case PROP_CAN_TARGET: + g_value_set_boolean (value, gtk_widget_get_can_target (widget)); break; case PROP_FOCUS_ON_CLICK: g_value_set_boolean (value, gtk_widget_get_focus_on_click (widget)); @@ -2808,7 +2808,7 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class) #ifdef G_ENABLE_DEBUG priv->highlight_resize = FALSE; #endif - priv->can_pick = TRUE; + priv->can_target = TRUE; switch (_gtk_widget_get_direction (widget)) { @@ -11041,12 +11041,13 @@ gtk_widget_pick (GtkWidget *widget, if (!_gtk_widget_is_drawable (widget)) return NULL; - if ((flags & GTK_PICK_ALL) == 0) - { - if (!gtk_widget_get_can_pick (widget) || - !_gtk_widget_is_sensitive (widget)) - return NULL; - } + if (!(flags & GTK_PICK_NON_TARGETABLE) && + !gtk_widget_get_can_target (widget)) + return NULL; + + if (!(flags & GTK_PICK_INSENSITIVE) && + !_gtk_widget_is_sensitive (widget)) + return NULL; switch (priv->overflow) { @@ -13462,31 +13463,30 @@ gtk_widget_get_cursor (GtkWidget *widget) } /** - * gtk_widget_set_can_pick: + * gtk_widget_set_can_target: * @widget: a #GtkWidget - * @can_pick: whether this widget should be able to receive pointer events + * @can_target: whether this widget should be able to receive pointer events * - * Sets whether @widget can be the target of pointer events and - * can be returned by gtk_widget_pick(). + * Sets whether @widget can be the target of pointer events. */ void -gtk_widget_set_can_pick (GtkWidget *widget, - gboolean can_pick) +gtk_widget_set_can_target (GtkWidget *widget, + gboolean can_target) { GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); - can_pick = !!can_pick; + can_target = !!can_target; - if (priv->can_pick == can_pick) + if (priv->can_target == can_target) return; - priv->can_pick = can_pick; + priv->can_target = can_target; - g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CAN_PICK]); + g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CAN_TARGET]); } /** - * gtk_widget_get_can_pick: + * gtk_widget_get_can_target: * @widget: a #GtkWidget * * Queries whether @widget can be the target of pointer events. @@ -13494,11 +13494,11 @@ gtk_widget_set_can_pick (GtkWidget *widget, * Returns: %TRUE if @widget can receive pointer events */ gboolean -gtk_widget_get_can_pick (GtkWidget *widget) +gtk_widget_get_can_target (GtkWidget *widget) { GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); - return priv->can_pick; + return priv->can_target; } /** diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 8f0591306b..30741b9499 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -469,10 +469,10 @@ GDK_AVAILABLE_IN_ALL gboolean gtk_widget_get_focus_on_click (GtkWidget *widget); GDK_AVAILABLE_IN_ALL -void gtk_widget_set_can_pick (GtkWidget *widget, - gboolean can_pick); +void gtk_widget_set_can_target (GtkWidget *widget, + gboolean can_target); GDK_AVAILABLE_IN_ALL -gboolean gtk_widget_get_can_pick (GtkWidget *widget); +gboolean gtk_widget_get_can_target (GtkWidget *widget); GDK_AVAILABLE_IN_ALL diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index 03c9f95923..7409ee047b 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -73,7 +73,7 @@ struct _GtkWidgetPrivate guint shadowed : 1; guint child_visible : 1; guint multidevice : 1; - guint can_pick : 1; + guint can_target : 1; /* Queue-resize related flags */ guint resize_needed : 1; /* queue_resize() has been called but no get_preferred_size() yet */ diff --git a/gtk/inspector/inspect-button.c b/gtk/inspector/inspect-button.c index c39ef5a298..ee3b3c70a4 100644 --- a/gtk/inspector/inspect-button.c +++ b/gtk/inspector/inspect-button.c @@ -55,7 +55,7 @@ find_widget_at_pointer (GdkDevice *device) gdk_surface_get_device_position (gtk_widget_get_surface (widget), device, &x, &y, NULL); - widget = gtk_widget_pick (widget, x, y, GTK_PICK_ALL); + widget = gtk_widget_pick (widget, x, y, GTK_PICK_INSENSITIVE|GTK_PICK_NON_TARGETABLE); } return widget; diff --git a/tests/testoverlay.c b/tests/testoverlay.c index 16835c06fe..b73b0fc783 100644 --- a/tests/testoverlay.c +++ b/tests/testoverlay.c @@ -459,7 +459,7 @@ test_input_stacking (void) vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox); - gtk_widget_set_can_pick (vbox, FALSE); + gtk_widget_set_can_target (vbox, FALSE); gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER); gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER); diff --git a/tests/testwidgettransforms.c b/tests/testwidgettransforms.c index 314d72c01d..91ac1d0d15 100644 --- a/tests/testwidgettransforms.c +++ b/tests/testwidgettransforms.c @@ -187,12 +187,12 @@ gtk_transform_tester_snapshot (GtkWidget *widget, const float py = y; GtkWidget *picked; #if 1 - picked = gtk_widget_pick (widget, px, py, 0); + picked = gtk_widget_pick (widget, px, py, GTK_PICK_DEFAULT); #else { int dx, dy; gtk_widget_translate_coordinates (widget, self->test_widget, px, py, &dx, &dy); - picked = gtk_widget_pick (self->test_widget, dx, dy); + picked = gtk_widget_pick (self->test_widget, dx, dy, GTK_PICK_DEFAULT); } #endif |