[gtk/overlay-cleanup] Make gtk_widget_set/get_can_pick public



commit 2e5ccce088a790b861e79b3f9c58e02630c8eca3
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Feb 21 21:53:34 2019 -0500

    Make gtk_widget_set/get_can_pick public
    
    This is a generally useful property to make widgets
    'transparent' for input purposes.

 docs/reference/gtk/gtk4-sections.txt |  2 ++
 gtk/gtkwidget.c                      | 38 ++++++++++++++++++++++++++++--------
 gtk/gtkwidget.h                      |  7 +++++++
 gtk/gtkwidgetprivate.h               |  6 +-----
 4 files changed, 40 insertions(+), 13 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 176d25325d..6a0cc0b852 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -4568,6 +4568,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_has_surface
 gtk_widget_set_has_surface
 gtk_widget_get_sensitive
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index edade0538e..c620b51f7b 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -518,6 +518,7 @@ enum {
   PROP_CAN_FOCUS,
   PROP_HAS_FOCUS,
   PROP_IS_FOCUS,
+  PROP_CAN_PICK,
   PROP_FOCUS_ON_CLICK,
   PROP_CAN_DEFAULT,
   PROP_HAS_DEFAULT,
@@ -1036,6 +1037,13 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                             FALSE,
                             GTK_PARAM_READWRITE);
 
+  widget_props[PROP_CAN_PICK] =
+      g_param_spec_boolean ("can-pick",
+                            P_("Can pick"),
+                            P_("Whether the widget can receive pointer events"),
+                            FALSE,
+                            GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
   /**
    * GtkWidget:focus-on-click:
    *
@@ -2262,6 +2270,9 @@ 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));
+      break;
     case PROP_FOCUS_ON_CLICK:
       gtk_widget_set_focus_on_click (widget, g_value_get_boolean (value));
       break;
@@ -2437,6 +2448,9 @@ 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));
+      break;
     case PROP_FOCUS_ON_CLICK:
       g_value_set_boolean (value, gtk_widget_get_focus_on_click (widget));
       break;
@@ -2871,6 +2885,7 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
 #ifdef G_ENABLE_DEBUG
   priv->highlight_resize = FALSE;
 #endif
+  priv->can_pick = TRUE;
 
   switch (_gtk_widget_get_direction (widget))
     {
@@ -11206,7 +11221,7 @@ gtk_widget_get_allocation (GtkWidget     *widget,
  *
  * Pass-through widgets and insensitive widgets do never respond to
  * input and will therefor always return %FALSE here. See
- * gtk_widget_set_pass_through() and gtk_widget_set_sensitive() for
+ * gtk_widget_set_can_pick() and gtk_widget_set_sensitive() for
  * details about those functions.
  *
  * Returns: %TRUE if @widget contains (@x, @y).
@@ -11218,7 +11233,7 @@ gtk_widget_contains (GtkWidget  *widget,
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  if (gtk_widget_get_pass_through (widget) ||
+  if (!gtk_widget_get_can_pick (widget) ||
       !_gtk_widget_is_sensitive (widget) ||
       !_gtk_widget_is_drawable (widget))
     return FALSE;
@@ -11257,7 +11272,7 @@ gtk_widget_pick (GtkWidget *widget,
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
 
-  if (gtk_widget_get_pass_through (widget) ||
+  if (!gtk_widget_get_can_pick (widget) ||
       !_gtk_widget_is_sensitive (widget) ||
       !_gtk_widget_is_drawable (widget))
     return NULL;
@@ -13700,20 +13715,27 @@ gtk_widget_get_cursor (GtkWidget *widget)
 }
 
 void
-gtk_widget_set_pass_through (GtkWidget *widget,
-                             gboolean   pass_through)
+gtk_widget_set_can_pick (GtkWidget *widget,
+                         gboolean   can_pick)
 {
   GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
 
-  priv->pass_through = !!pass_through;
+  can_pick = !!can_pick;
+
+  if (priv->can_pick == can_pick)
+    return;
+
+  priv->can_pick = can_pick;
+
+  g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CAN_PICK]);
 }
 
 gboolean
-gtk_widget_get_pass_through (GtkWidget *widget)
+gtk_widget_get_can_pick (GtkWidget *widget)
 {
   GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
 
-  return priv->pass_through;
+  return priv->can_pick;
 }
 
 /**
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 0098c424d3..85495f4431 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -494,6 +494,13 @@ void       gtk_widget_set_focus_on_click  (GtkWidget           *widget,
 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);
+GDK_AVAILABLE_IN_ALL
+gboolean   gtk_widget_get_can_pick        (GtkWidget           *widget);
+
+
 GDK_AVAILABLE_IN_ALL
 void       gtk_widget_set_can_default     (GtkWidget           *widget,
                                            gboolean             can_default);
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 8b4bf94e67..16fe80878d 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -75,7 +75,7 @@ struct _GtkWidgetPrivate
   guint shadowed              : 1;
   guint child_visible         : 1;
   guint multidevice           : 1;
-  guint pass_through          : 1;
+  guint can_pick              : 1;
 
   /* Queue-resize related flags */
   guint resize_needed         : 1; /* queue_resize() has been called but no get_preferred_size() yet */
@@ -332,10 +332,6 @@ void              gtk_widget_get_surface_allocation         (GtkWidget *widget,
 GtkWidget *       gtk_widget_common_ancestor               (GtkWidget *widget_a,
                                                             GtkWidget *widget_b);
 
-void              gtk_widget_set_pass_through              (GtkWidget *widget,
-                                                            gboolean   pass_through);
-gboolean          gtk_widget_get_pass_through              (GtkWidget *widget);
-
 void              gtk_widget_cancel_event_sequence         (GtkWidget             *widget,
                                                             GtkGesture            *gesture,
                                                             GdkEventSequence      *sequence,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]