Pass mode and detail to focus-in/out signals

This information is useful when maintaining a
'last focus' field.

Update all users.
This commit is contained in:
Matthias Clasen 2019-03-07 00:14:26 -05:00
parent 888b92674f
commit 921eccb459
5 changed files with 35 additions and 9 deletions

View File

@ -295,6 +295,8 @@ static gboolean gtk_calendar_key_controller_key_pressed (GtkEventControllerKey *
GdkModifierType state,
GtkWidget *widget);
static void gtk_calendar_key_controller_focus (GtkEventControllerKey *controller,
GdkCrossingMode mode,
GdkNotifyType detail,
GtkWidget *widget);
static void gtk_calendar_grab_notify (GtkWidget *widget,
gboolean was_grabbed);
@ -2854,6 +2856,8 @@ gtk_calendar_key_controller_key_pressed (GtkEventControllerKey *controller,
static void
gtk_calendar_key_controller_focus (GtkEventControllerKey *key,
GdkCrossingMode mode,
GdkNotifyType detail,
GtkWidget *widget)
{
GtkCalendar *calendar = GTK_CALENDAR (widget);

View File

@ -93,11 +93,16 @@ gtk_event_controller_key_handle_event (GtkEventController *controller,
if (event_type == GDK_FOCUS_CHANGE)
{
gboolean focus_in;
GdkCrossingMode mode;
GdkNotifyType detail;
gdk_event_get_crossing_mode (event, &mode);
gdk_event_get_crossing_detail (event, &detail);
if (gdk_event_get_focus_in (event, &focus_in) && focus_in)
g_signal_emit (controller, signals[FOCUS_IN], 0);
g_signal_emit (controller, signals[FOCUS_IN], 0, mode, detail);
else
g_signal_emit (controller, signals[FOCUS_OUT], 0);
g_signal_emit (controller, signals[FOCUS_OUT], 0, mode, detail);
return FALSE;
}
@ -233,12 +238,14 @@ gtk_event_controller_key_class_init (GtkEventControllerKeyClass *klass)
GTK_TYPE_EVENT_CONTROLLER_KEY,
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
NULL,
G_TYPE_NONE, 0);
/**
* GtkEventControllerKey::focus-in:
* @controller: the object which received the signal.
* @mode: crossing mode indicating what caused this change
* @detail: detail indication where the focus is coming from
*
* This signal is emitted whenever the #GtkEventController:widget controlled
* by the @controller is given the keyboard focus.
@ -248,12 +255,17 @@ gtk_event_controller_key_class_init (GtkEventControllerKeyClass *klass)
GTK_TYPE_EVENT_CONTROLLER_KEY,
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
NULL,
G_TYPE_NONE,
2,
GDK_TYPE_CROSSING_MODE,
GDK_TYPE_NOTIFY_TYPE);
/**
* GtkEventControllerKey::focus-out:
* @controller: the object which received the signal.
* @mode: crossing mode indicating what caused this change
* @detail: detail indication where the focus is going
*
* This signal is emitted whenever the #GtkEventController:widget controlled
* by the @controller loses the keyboard focus.
@ -263,8 +275,11 @@ gtk_event_controller_key_class_init (GtkEventControllerKeyClass *klass)
GTK_TYPE_EVENT_CONTROLLER_KEY,
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
NULL,
G_TYPE_NONE,
2,
GDK_TYPE_CROSSING_MODE,
GDK_TYPE_NOTIFY_TYPE);
}
static void
@ -283,8 +298,7 @@ gtk_event_controller_key_init (GtkEventControllerKey *controller)
GtkEventController *
gtk_event_controller_key_new (void)
{
return g_object_new (GTK_TYPE_EVENT_CONTROLLER_KEY,
NULL);
return g_object_new (GTK_TYPE_EVENT_CONTROLLER_KEY, NULL);
}
/**

View File

@ -824,6 +824,8 @@ key_controller_key_released (GtkEventControllerKey *key,
static void
key_controller_focus_out (GtkEventControllerKey *key,
GdkCrossingMode mode,
GdkNotifyType detail,
GtkSpinButton *spin_button)
{
GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button);

View File

@ -614,6 +614,8 @@ static void gtk_tree_view_key_controller_key_released (GtkEventControllerKey
GdkModifierType state,
GtkTreeView *tree_view);
static void gtk_tree_view_key_controller_focus_out (GtkEventControllerKey *key,
GdkCrossingMode mode,
GdkNotifyType detail,
GtkTreeView *tree_view);
static gint gtk_tree_view_focus (GtkWidget *widget,
@ -5475,6 +5477,8 @@ gtk_tree_view_motion_controller_leave (GtkEventControllerMotion *controller,
static void
gtk_tree_view_key_controller_focus_out (GtkEventControllerKey *key,
GdkCrossingMode mode,
GdkNotifyType detail,
GtkTreeView *tree_view)
{
gtk_widget_queue_draw (GTK_WIDGET (tree_view));

View File

@ -814,6 +814,8 @@ gtk_tree_view_column_cell_layout_get_area (GtkCellLayout *cell_layout)
static void
focus_in (GtkEventControllerKey *controller,
GdkCrossingMode mode,
GdkNotifyType detail,
GtkTreeViewColumn *column)
{
_gtk_tree_view_set_focus_column (GTK_TREE_VIEW (column->priv->tree_view), column);