[gtk/readonly-events-1: 25/33] Keep more event controller api private



commit b33905b320d89133f15e2224536ce6ee0785f285
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Feb 20 17:22:03 2020 -0500

    Keep more event controller api private
    
    We don't want to expose the GtkCrossingData struct, and manually
    feeding events to event controllers is not something we want to
    encourage, going forward.

 gtk/gtkenums.h                  | 10 ------
 gtk/gtkeventcontroller.h        | 42 ------------------------
 gtk/gtkeventcontrollerfocus.c   | 72 ++---------------------------------------
 gtk/gtkeventcontrollerfocus.h   |  9 ------
 gtk/gtkeventcontrollermotion.c  | 42 ------------------------
 gtk/gtkeventcontrollermotion.h  |  5 ---
 gtk/gtkeventcontrollerprivate.h | 51 +++++++++++++++++++++++++++++
 gtk/gtkwidgetprivate.h          |  2 +-
 8 files changed, 54 insertions(+), 179 deletions(-)
---
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index 59eb3e17c6..d4c3b4de2b 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -954,16 +954,6 @@ typedef enum
   GTK_EVENT_SEQUENCE_DENIED
 } GtkEventSequenceState;
 
-typedef enum {
-  GTK_CROSSING_FOCUS,
-  GTK_CROSSING_POINTER
-} GtkCrossingType;
-
-typedef enum {
-  GTK_CROSSING_IN,
-  GTK_CROSSING_OUT
-} GtkCrossingDirection;
-
 /**
  * GtkPanDirection:
  * @GTK_PAN_DIRECTION_LEFT: panned towards the left
diff --git a/gtk/gtkeventcontroller.h b/gtk/gtkeventcontroller.h
index 2cd8167c03..6bdcfbb678 100644
--- a/gtk/gtkeventcontroller.h
+++ b/gtk/gtkeventcontroller.h
@@ -40,37 +40,6 @@ G_BEGIN_DECLS
 #define GTK_EVENT_CONTROLLER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_EVENT_CONTROLLER, 
GtkEventControllerClass))
 
 
-typedef struct _GtkCrossingData GtkCrossingData;
-
-/**
- * GtkCrossingData:
- * @type: the type of crossing event
- * @direction: whether this is a focus-in or focus-out event
- * @mode: the crossing mode
- * @old_target: the old target
- * @old_descendent: the direct child of the receiving widget that
- *     is an ancestor of @old_target, or %NULL if @old_target is not
- *     a descendent of the receiving widget
- * @new_target: the new target
- * @new_descendent: the direct child of the receiving widget that
- *     is an ancestor of @new_target, or %NULL if @new_target is not
- *     a descendent of the receiving widget
- *
- * The struct that is passed to gtk_event_controller_handle_crossing().
- *
- * The @old_target and @new_target fields are set to the old or new
- * focus or hover location.
- */
-struct _GtkCrossingData {
-  GtkCrossingType type;
-  GtkCrossingDirection direction;
-  GdkCrossingMode mode;
-  GtkWidget *old_target;
-  GtkWidget *old_descendent;
-  GtkWidget *new_target;
-  GtkWidget *new_descendent;
-};
-
 GDK_AVAILABLE_IN_ALL
 GType               gtk_crossing_data_get_type (void) G_GNUC_CONST;
 
@@ -81,17 +50,6 @@ GType        gtk_event_controller_get_type       (void) G_GNUC_CONST;
 GDK_AVAILABLE_IN_ALL
 GtkWidget  * gtk_event_controller_get_widget     (GtkEventController *controller);
 
-GDK_AVAILABLE_IN_ALL
-gboolean     gtk_event_controller_handle_event   (GtkEventController *controller,
-                                                  GdkEvent           *event,
-                                                  GtkWidget          *target,
-                                                  double              x,
-                                                  double              y);
-GDK_AVAILABLE_IN_ALL
-void         gtk_event_controller_handle_crossing (GtkEventController    *controller,
-                                                   const GtkCrossingData *crossing,
-                                                   double                 x,
-                                                   double                 y);
 GDK_AVAILABLE_IN_ALL
 void         gtk_event_controller_reset          (GtkEventController *controller);
 
diff --git a/gtk/gtkeventcontrollerfocus.c b/gtk/gtkeventcontrollerfocus.c
index 0cec4344e9..a8a6aaa296 100644
--- a/gtk/gtkeventcontrollerfocus.c
+++ b/gtk/gtkeventcontrollerfocus.c
@@ -46,8 +46,6 @@ struct _GtkEventControllerFocus
 {
   GtkEventController parent_instance;
 
-  const GtkCrossingData *current_crossing;
-
   guint is_focus       : 1;
   guint contains_focus : 1;
 };
@@ -148,16 +146,8 @@ gtk_event_controller_focus_handle_crossing (GtkEventController    *controller,
                                             double                 x,
                                             double                 y)
 {
-  GtkEventControllerFocus *focus = GTK_EVENT_CONTROLLER_FOCUS (controller);
-
-  if (crossing->type != GTK_CROSSING_FOCUS)
-    return;
-
-  focus->current_crossing = crossing;
-
-  update_focus (controller, crossing);
-
-  focus->current_crossing = NULL;
+  if (crossing->type == GTK_CROSSING_FOCUS)
+    update_focus (controller, crossing);
 }
 
 static void
@@ -295,64 +285,6 @@ gtk_event_controller_focus_new (void)
   return g_object_new (GTK_TYPE_EVENT_CONTROLLER_FOCUS, NULL);
 }
 
-/**
- * gtk_event_controller_focus_get_focus_origin:
- * @controller: a #GtkEventControllerFocus
- *
- * Returns the widget that was holding focus before.
- *
- * This function can only be used in handlers for the
- * #GtkEventControllerFocus::focus-in and #GtkEventControllerFocus::focus-out signals.
- *
- * Returns: (transfer none): the previous focus
- */
-GtkWidget *
-gtk_event_controller_focus_get_focus_origin (GtkEventControllerFocus *controller)
-{
-  g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_FOCUS (controller), NULL);
-  g_return_val_if_fail (controller->current_crossing != NULL, NULL);
-
-  return controller->current_crossing->old_target;
-}
-
-/**
- * gtk_event_controller_focus_get_focus_target:
- * @controller: a #GtkEventControllerFocus
- *
- * Returns the widget that will be holding focus afterwards.
- *
- * This function can only be used in handlers for the
- * #GtkEventControllerFocus::focus-in and #GtkEventControllerFocus::focus-out signals.
- *
- * Returns: (transfer none): the next focus
- */
-GtkWidget *
-gtk_event_controller_focus_get_focus_target (GtkEventControllerFocus *controller)
-{
-  g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_FOCUS (controller), NULL);
-  g_return_val_if_fail (controller->current_crossing != NULL, NULL);
-
-  return controller->current_crossing->new_target;
-}
-
-GtkWidget *
-gtk_event_controller_focus_get_old_focus_child (GtkEventControllerFocus *controller)
-{
-  g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_FOCUS (controller), NULL);
-  g_return_val_if_fail (controller->current_crossing != NULL, NULL);
-
-  return controller->current_crossing->old_descendent;
-}
-
-GtkWidget *
-gtk_event_controller_focus_get_new_focus_child (GtkEventControllerFocus *controller)
-{
-  g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_FOCUS (controller), NULL);
-  g_return_val_if_fail (controller->current_crossing != NULL, NULL);
-
-  return controller->current_crossing->new_descendent;
-}
-
 /**
  * gtk_event_controller_focus_contains_focus:
  * @self: a #GtkEventControllerFocus
diff --git a/gtk/gtkeventcontrollerfocus.h b/gtk/gtkeventcontrollerfocus.h
index 3a4ae1b7fe..30b7c7d93e 100644
--- a/gtk/gtkeventcontrollerfocus.h
+++ b/gtk/gtkeventcontrollerfocus.h
@@ -46,15 +46,6 @@ GType               gtk_event_controller_focus_get_type  (void) G_GNUC_CONST;
 GDK_AVAILABLE_IN_ALL
 GtkEventController *gtk_event_controller_focus_new (void);
 
-GDK_AVAILABLE_IN_ALL
-GtkWidget *         gtk_event_controller_focus_get_focus_origin   (GtkEventControllerFocus  *controller);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *         gtk_event_controller_focus_get_focus_target   (GtkEventControllerFocus  *controller);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *         gtk_event_controller_focus_get_old_focus_child (GtkEventControllerFocus  *controller);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *         gtk_event_controller_focus_get_new_focus_child (GtkEventControllerFocus  *controller);
-
 GDK_AVAILABLE_IN_ALL
 gboolean            gtk_event_controller_focus_contains_focus     (GtkEventControllerFocus  *self);
 GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkeventcontrollermotion.c b/gtk/gtkeventcontrollermotion.c
index 3adbad42b9..d0182cbcc0 100644
--- a/gtk/gtkeventcontrollermotion.c
+++ b/gtk/gtkeventcontrollermotion.c
@@ -303,48 +303,6 @@ gtk_event_controller_motion_new (void)
                        NULL);
 }
 
-/**
- * gtk_event_controller_motion_get_pointer_origin:
- * @controller: a #GtkEventControllerMotion
- *
- * Returns the widget that contained the pointer before.
- *
- * This function can only be used in handlers for the
- * #GtkEventControllerMotion::enter or
- * #GtkEventControllerMotion::leave signals.
- *
- * Returns: (transfer none): the previous pointer focus
- */
-GtkWidget *
-gtk_event_controller_motion_get_pointer_origin (GtkEventControllerMotion *controller)
-{
-  g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_MOTION (controller), NULL);
-  g_return_val_if_fail (controller->current_crossing != NULL, NULL);
-
-  return controller->current_crossing->old_target;
-}
-
-/**
- * gtk_event_controller_motion_get_pointer_target:
- * @controller: a #GtkEventControllerMotion
- *
- * Returns the widget that will contain the pointer afterwards.
- *
- * This function can only be used in handlers for the
- * #GtkEventControllerMotion::enter or
- * #GtkEventControllerMotion::leave signals.
- *
- * Returns: (transfer none): the next pointer focus
- */
-GtkWidget *
-gtk_event_controller_motion_get_pointer_target (GtkEventControllerMotion *controller)
-{
-  g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_MOTION (controller), NULL);
-  g_return_val_if_fail (controller->current_crossing != NULL, NULL);
-
-  return controller->current_crossing->new_target;
-}
-
 /**
  * gtk_event_controller_motion_contains_pointer:
  * @self: a #GtkEventControllerMotion
diff --git a/gtk/gtkeventcontrollermotion.h b/gtk/gtkeventcontrollermotion.h
index dbbc8c5621..5fbcffe3b6 100644
--- a/gtk/gtkeventcontrollermotion.h
+++ b/gtk/gtkeventcontrollermotion.h
@@ -45,11 +45,6 @@ GType               gtk_event_controller_motion_get_type (void) G_GNUC_CONST;
 GDK_AVAILABLE_IN_ALL
 GtkEventController *gtk_event_controller_motion_new      (void);
 
-GDK_AVAILABLE_IN_ALL
-GtkWidget *         gtk_event_controller_motion_get_pointer_origin (GtkEventControllerMotion *controller);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *         gtk_event_controller_motion_get_pointer_target (GtkEventControllerMotion *controller);
-
 GDK_AVAILABLE_IN_ALL
 gboolean            gtk_event_controller_motion_contains_pointer   (GtkEventControllerMotion *self);
 GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkeventcontrollerprivate.h b/gtk/gtkeventcontrollerprivate.h
index 1ae4808f48..e9e17f14e4 100644
--- a/gtk/gtkeventcontrollerprivate.h
+++ b/gtk/gtkeventcontrollerprivate.h
@@ -22,6 +22,47 @@
 
 #include "gtkeventcontroller.h"
 
+typedef enum {
+  GTK_CROSSING_FOCUS,
+  GTK_CROSSING_POINTER
+} GtkCrossingType;
+
+typedef enum {
+  GTK_CROSSING_IN,
+  GTK_CROSSING_OUT
+} GtkCrossingDirection;
+
+typedef struct _GtkCrossingData GtkCrossingData;
+
+/**
+ * GtkCrossingData:
+ * @type: the type of crossing event
+ * @direction: whether this is a focus-in or focus-out event
+ * @mode: the crossing mode
+ * @old_target: the old target
+ * @old_descendent: the direct child of the receiving widget that
+ *     is an ancestor of @old_target, or %NULL if @old_target is not
+ *     a descendent of the receiving widget
+ * @new_target: the new target
+ * @new_descendent: the direct child of the receiving widget that
+ *     is an ancestor of @new_target, or %NULL if @new_target is not
+ *     a descendent of the receiving widget
+ *
+ * The struct that is passed to gtk_event_controller_handle_crossing().
+ *
+ * The @old_target and @new_target fields are set to the old or new
+ * focus or hover location.
+ */
+struct _GtkCrossingData {
+  GtkCrossingType type;
+  GtkCrossingDirection direction;
+  GdkCrossingMode mode;
+  GtkWidget *old_target;
+  GtkWidget *old_descendent;
+  GtkWidget *new_target;
+  GtkWidget *new_descendent;
+};
+
 struct _GtkEventController
 {
   GObject parent_instance;
@@ -58,4 +99,14 @@ struct _GtkEventControllerClass
 
 GtkWidget *gtk_event_controller_get_target (GtkEventController *controller);
 
+gboolean   gtk_event_controller_handle_event   (GtkEventController *controller,
+                                                GdkEvent           *event,
+                                                GtkWidget          *target,
+                                                double              x,
+                                                double              y);
+void       gtk_event_controller_handle_crossing (GtkEventController    *controller,
+                                                 const GtkCrossingData *crossing,
+                                                 double                 x,
+                                                 double                 y);
+
 #endif /* __GTK_EVENT_CONTROLLER_PRIVATE_H__ */
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index b3519f04b8..21a933606e 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -30,7 +30,7 @@
 #include "gtkactionmuxerprivate.h"
 #include "gtkcontainer.h"
 #include "gtkcsstypesprivate.h"
-#include "gtkeventcontroller.h"
+#include "gtkeventcontrollerprivate.h"
 #include "gtklistlistmodelprivate.h"
 #include "gtkrootprivate.h"
 #include "gtksizerequestcacheprivate.h"


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