diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-02-12 20:26:29 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-02-21 00:47:53 -0500 |
commit | 23c67f8c672ee3c0a3e22afd71ac86f96592dca5 (patch) | |
tree | 140c5974325aa00cd4c4f320a1f0220f6660840e /gtk/gtkeventcontroller.h | |
parent | 9402e335d014e5f1fffafd8bc9af6e049576418b (diff) | |
download | gtk+-23c67f8c672ee3c0a3e22afd71ac86f96592dca5.tar.gz |
New focus change handling
Instead of relying on gdk's antiquated crossing events,
create a new GtkCrossingData struct that contains the
actual widgets, and a new event controller vfunc that
expects this struct. This also saves us from making sense
of X's crossing modes and details, and makes for a
generally simpler api.
The ::focus-in and ::focus-out signals of GtkEventControllerKey
have been replaced by a single ::focus-change signal that
takes GtkCrossingData as an argument. All callers have
been updated.
Diffstat (limited to 'gtk/gtkeventcontroller.h')
-rw-r--r-- | gtk/gtkeventcontroller.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gtk/gtkeventcontroller.h b/gtk/gtkeventcontroller.h index 1f058fb11b..b4694a5f7b 100644 --- a/gtk/gtkeventcontroller.h +++ b/gtk/gtkeventcontroller.h @@ -40,6 +40,36 @@ 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 + * @new_target: the new target + * + * The struct that is passed to gtk_event_controller_handle_crossing() + * and is also passed to #GtkEventControllerKey::focus-change. + * + * 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 *new_target; +}; + +#define GTK_TYPE_CROSSING_DATA (gtk_crossing_data_get_type ()) + +GDK_AVAILABLE_IN_ALL +GType gtk_crossing_data_get_type (void) G_GNUC_CONST; + + GDK_AVAILABLE_IN_ALL GType gtk_event_controller_get_type (void) G_GNUC_CONST; @@ -52,6 +82,11 @@ gboolean gtk_event_controller_handle_event (GtkEventController *controller 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); GDK_AVAILABLE_IN_ALL |