Merge branch 'current-event-apis' into 'master'

Current event apis

See merge request GNOME/gtk!1668
This commit is contained in:
Matthias Clasen 2020-04-12 00:24:14 +00:00
commit 4da82bde7b
28 changed files with 299 additions and 442 deletions

View File

@ -4287,12 +4287,6 @@ gtk_init_check
<SUBSECTION> <SUBSECTION>
GTK_PRIORITY_RESIZE GTK_PRIORITY_RESIZE
<SUBSECTION>
gtk_get_current_event
gtk_get_current_event_time
gtk_get_current_event_state
gtk_get_current_event_device
<SUBSECTION Private> <SUBSECTION Private>
gtk_init_abi_check gtk_init_abi_check
gtk_init_check_abi_check gtk_init_check_abi_check
@ -5815,6 +5809,12 @@ gtk_event_controller_set_propagation_limit
gtk_event_controller_get_widget gtk_event_controller_get_widget
gtk_event_controller_reset gtk_event_controller_reset
<SUBSECTION>
gtk_event_controller_get_current_event
gtk_event_controller_get_current_event_device
gtk_event_controller_get_current_event_state
gtk_event_controller_get_current_event_time
<SUBSECTION Standard> <SUBSECTION Standard>
GTK_TYPE_EVENT_CONTROLLER GTK_TYPE_EVENT_CONTROLLER
GTK_EVENT_CONTROLLER GTK_EVENT_CONTROLLER

View File

@ -339,6 +339,15 @@
</para> </para>
</section> </section>
<section>
<title>Stop using gtk_get_current_... APIs</title>
<para>
The function gtk_get_current_event() and its variants have been
replaced by equivalent event controller APIs:
gtk_event_controller_get_current_event(), etc.
</para>
</section>
<section> <section>
<title>Adapt to surface API changes</title> <title>Adapt to surface API changes</title>
<para> <para>

View File

@ -981,7 +981,7 @@ gtk_about_dialog_activate_link (GtkAboutDialog *about,
{ {
GError *error = NULL; GError *error = NULL;
if (!gtk_show_uri_on_window (GTK_WINDOW (about), uri, gtk_get_current_event_time (), &error)) if (!gtk_show_uri_on_window (GTK_WINDOW (about), uri, GDK_CURRENT_TIME, &error))
{ {
GtkWidget *dialog; GtkWidget *dialog;

View File

@ -309,29 +309,25 @@ click_pressed_cb (GtkGestureClick *gesture,
} }
static gboolean static gboolean
touch_release_in_button (GtkButton *button, touch_release_in_button (GtkGestureClick *gesture,
double x, GtkWidget *widget,
double y) double x,
double y)
{ {
GdkEvent *event; GdkEvent *event;
event = gtk_get_current_event (); event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
if (!event) if (!event)
return FALSE; return FALSE;
if (gdk_event_get_event_type (event) != GDK_TOUCH_END) if (gdk_event_get_event_type (event) != GDK_TOUCH_END)
{ return FALSE;
gdk_event_unref (event);
return FALSE;
}
gdk_event_unref (event); if (!gtk_widget_contains (widget, x, y))
return FALSE;
if (gtk_widget_contains (GTK_WIDGET (button), x, y)) return TRUE;
return TRUE;
return FALSE;
} }
static void static void
@ -348,7 +344,7 @@ click_released_cb (GtkGestureClick *gesture,
gtk_button_do_release (button, gtk_button_do_release (button,
gtk_widget_is_sensitive (GTK_WIDGET (button)) && gtk_widget_is_sensitive (GTK_WIDGET (button)) &&
(priv->in_button || (priv->in_button ||
touch_release_in_button (button, x, y))); touch_release_in_button (gesture, widget, x, y)));
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)); sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));

View File

@ -539,8 +539,10 @@ key_controller_key_pressed (GtkEventControllerKey *key,
gboolean cleared = FALSE; gboolean cleared = FALSE;
GdkModifierType accel_mods = 0; GdkModifierType accel_mods = 0;
guint accel_key; guint accel_key;
GdkEvent *event;
if (!gdk_key_event_get_match (gtk_get_current_event (), &accel_key, &accel_mods)) event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (key));
if (!gdk_key_event_get_match (event, &accel_key, &accel_mods))
return FALSE; return FALSE;
if (accel_mods == 0) if (accel_mods == 0)

View File

@ -2233,7 +2233,6 @@ gtk_entry_completion_changed (GtkWidget *widget,
gpointer user_data) gpointer user_data)
{ {
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data); GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
GdkDevice *device;
if (!completion->priv->popup_completion) if (!completion->priv->popup_completion)
return; return;
@ -2257,14 +2256,6 @@ gtk_entry_completion_changed (GtkWidget *widget,
return; return;
} }
device = gtk_get_current_event_device ();
if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
device = gdk_device_get_associated_device (device);
if (device)
completion->priv->device = device;
completion->priv->completion_timeout = completion->priv->completion_timeout =
g_timeout_add (COMPLETION_TIMEOUT, g_timeout_add (COMPLETION_TIMEOUT,
gtk_entry_completion_timeout, gtk_entry_completion_timeout,

View File

@ -104,8 +104,6 @@ struct _GtkEntryCompletionPrivate
gchar *completion_prefix; gchar *completion_prefix;
GSource *check_completion_idle; GSource *check_completion_idle;
GdkDevice *device;
}; };
void _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion); void _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion);

View File

@ -59,6 +59,7 @@ struct _GtkEventControllerPrivate
GtkPropagationLimit limit; GtkPropagationLimit limit;
char *name; char *name;
GtkWidget *target; GtkWidget *target;
GdkEvent *event;
}; };
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkEventController, gtk_event_controller, G_TYPE_OBJECT) G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkEventController, gtk_event_controller, G_TYPE_OBJECT)
@ -337,13 +338,15 @@ gtk_event_controller_handle_event (GtkEventController *controller,
controller_class = GTK_EVENT_CONTROLLER_GET_CLASS (controller); controller_class = GTK_EVENT_CONTROLLER_GET_CLASS (controller);
priv->target = target; priv->target = g_object_ref (target);
priv->event = gdk_event_ref (event);
g_object_ref (controller); g_object_ref (controller);
retval = controller_class->handle_event (controller, event, x, y); retval = controller_class->handle_event (controller, event, x, y);
g_object_unref (controller); g_object_unref (controller);
priv->target = NULL; g_clear_object (&priv->target);
g_clear_pointer (&priv->event, gdk_event_unref);
return retval; return retval;
} }
@ -532,6 +535,83 @@ gtk_event_controller_get_target (GtkEventController *controller)
return priv->target; return priv->target;
} }
/**
* gtk_event_controller_get_current_event:
* @controller: a #GtkEventController
*
* Returns the event that is currently being handled by the
* controller, and %NULL at other times.
*
* Returns: (nullable) the event is current handled by @controller
*/
GdkEvent *
gtk_event_controller_get_current_event (GtkEventController *controller)
{
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (controller);
return priv->event;
}
/**
* gtk_event_controller_get_current_event_time:
* @controller: a #GtkEventController
*
* Returns the timestamp of the event that is currently being
* handled by the controller, and 0 otherwise.
*
* Returns: timestamp of the event is current handled by @controller
*/
guint32
gtk_event_controller_get_current_event_time (GtkEventController *controller)
{
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (controller);
if (priv->event)
return gdk_event_get_time (priv->event);
return 0;
}
/**
* gtk_event_controller_get_current_event_device:
* @controller: a #GtkEventController
*
* Returns the device of the event that is currently being
* handled by the controller, and %NULL otherwise.
*
* Returns: (nullable): device of the event is current handled by @controller
*/
GdkDevice *
gtk_event_controller_get_current_event_device (GtkEventController *controller)
{
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (controller);
if (priv->event)
return gdk_event_get_device (priv->event);
return NULL;
}
/**
* gtk_event_controller_get_current_event_device:
* @controller: a #GtkEventController
*
* Returns the modifier state of the event that is currently being
* handled by the controller, and 0 otherwise.
*
* Returns: (nullable): modifier state of the event is current handled by @controller
*/
GdkModifierType
gtk_event_controller_get_current_event_state (GtkEventController *controller)
{
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (controller);
if (priv->event)
return gdk_event_get_modifier_state (priv->event);
return 0;
}
static GtkCrossingData * static GtkCrossingData *
gtk_crossing_data_copy (GtkCrossingData *crossing) gtk_crossing_data_copy (GtkCrossingData *crossing)
{ {

View File

@ -72,6 +72,15 @@ GDK_AVAILABLE_IN_ALL
void gtk_event_controller_set_name (GtkEventController *controller, void gtk_event_controller_set_name (GtkEventController *controller,
const char *name); const char *name);
GDK_AVAILABLE_IN_ALL
GdkEvent * gtk_event_controller_get_current_event (GtkEventController *controller);
GDK_AVAILABLE_IN_ALL
guint32 gtk_event_controller_get_current_event_time (GtkEventController *controller);
GDK_AVAILABLE_IN_ALL
GdkDevice * gtk_event_controller_get_current_event_device (GtkEventController *controller);
GDK_AVAILABLE_IN_ALL
GdkModifierType gtk_event_controller_get_current_event_state (GtkEventController *controller);
G_END_DECLS G_END_DECLS
#endif /* __GTK_EVENT_CONTROLLER_H__ */ #endif /* __GTK_EVENT_CONTROLLER_H__ */

View File

@ -100,7 +100,8 @@ struct _GtkEventControllerClass
gpointer padding[10]; gpointer padding[10];
}; };
GtkWidget *gtk_event_controller_get_target (GtkEventController *controller); GtkWidget * gtk_event_controller_get_target (GtkEventController *controller);
gboolean gtk_event_controller_handle_event (GtkEventController *controller, gboolean gtk_event_controller_handle_event (GtkEventController *controller,
GdkEvent *event, GdkEvent *event,

View File

@ -1502,7 +1502,7 @@ open_folder_cb (GSimpleAction *action,
gchar *uri; gchar *uri;
uri = g_file_get_uri (file); uri = g_file_get_uri (file);
gtk_show_uri_on_window (GTK_WINDOW (toplevel), uri, gtk_get_current_event_time (), NULL); gtk_show_uri_on_window (GTK_WINDOW (toplevel), uri, GDK_CURRENT_TIME, NULL);
g_free (uri); g_free (uri);
} }

View File

@ -129,28 +129,6 @@ static void gtk_flow_box_set_accept_unpaired_release (GtkFlowBox *box,
static void gtk_flow_box_check_model_compat (GtkFlowBox *box); static void gtk_flow_box_check_model_compat (GtkFlowBox *box);
static void
get_current_selection_modifiers (GtkWidget *widget,
gboolean *modify,
gboolean *extend)
{
GdkModifierType state = 0;
GdkModifierType mask;
*modify = FALSE;
*extend = FALSE;
if (gtk_get_current_event_state (&state))
{
mask = GDK_CONTROL_MASK;
if ((state & mask) == mask)
*modify = TRUE;
mask = GDK_SHIFT_MASK;
if ((state & mask) == mask)
*extend = TRUE;
}
}
static void static void
path_from_horizontal_line_rects (cairo_t *cr, path_from_horizontal_line_rects (cairo_t *cr,
GdkRectangle *lines, GdkRectangle *lines,
@ -307,15 +285,8 @@ static void
gtk_flow_box_child_set_focus (GtkFlowBoxChild *child) gtk_flow_box_child_set_focus (GtkFlowBoxChild *child)
{ {
GtkFlowBox *box = gtk_flow_box_child_get_box (child); GtkFlowBox *box = gtk_flow_box_child_get_box (child);
gboolean modify;
gboolean extend;
get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend); gtk_flow_box_update_selection (box, child, FALSE, FALSE);
if (modify)
gtk_flow_box_update_cursor (box, child);
else
gtk_flow_box_update_selection (box, child, FALSE, FALSE);
} }
/* GtkWidget implementation {{{2 */ /* GtkWidget implementation {{{2 */
@ -613,7 +584,9 @@ struct _GtkFlowBoxClass
void (*toggle_cursor_child) (GtkFlowBox *box); void (*toggle_cursor_child) (GtkFlowBox *box);
gboolean (*move_cursor) (GtkFlowBox *box, gboolean (*move_cursor) (GtkFlowBox *box,
GtkMovementStep step, GtkMovementStep step,
gint count); gint count,
gboolean extend,
gboolean modify);
void (*select_all) (GtkFlowBox *box); void (*select_all) (GtkFlowBox *box);
void (*unselect_all) (GtkFlowBox *box); void (*unselect_all) (GtkFlowBox *box);
}; };
@ -2708,10 +2681,13 @@ gtk_flow_box_click_gesture_released (GtkGestureClick *gesture,
GdkEventSequence *sequence; GdkEventSequence *sequence;
GdkInputSource source; GdkInputSource source;
GdkEvent *event; GdkEvent *event;
GdkModifierType state;
gboolean modify; gboolean modify;
gboolean extend; gboolean extend;
get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend); state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (gesture));
modify = (state & GDK_CONTROL_MASK) != 0;
extend = (state & GDK_SHIFT_MASK) != 0;
/* With touch, we default to modifying the selection. /* With touch, we default to modifying the selection.
* You can still clear the selection and start over * You can still clear the selection and start over
@ -2747,6 +2723,7 @@ gtk_flow_box_drag_gesture_begin (GtkGestureDrag *gesture,
GtkWidget *widget) GtkWidget *widget)
{ {
GtkFlowBoxPrivate *priv = BOX_PRIV (widget); GtkFlowBoxPrivate *priv = BOX_PRIV (widget);
GdkModifierType state;
if (priv->selection_mode != GTK_SELECTION_MULTIPLE) if (priv->selection_mode != GTK_SELECTION_MULTIPLE)
{ {
@ -2757,7 +2734,10 @@ gtk_flow_box_drag_gesture_begin (GtkGestureDrag *gesture,
priv->rubberband_select = FALSE; priv->rubberband_select = FALSE;
priv->rubberband_first = NULL; priv->rubberband_first = NULL;
priv->rubberband_last = NULL; priv->rubberband_last = NULL;
get_current_selection_modifiers (widget, &priv->rubberband_modify, &priv->rubberband_extend);
state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (gesture));
priv->rubberband_modify = (state & GDK_CONTROL_MASK) != 0;
priv->rubberband_extend = (state & GDK_SHIFT_MASK) != 0;
} }
static void static void
@ -2992,25 +2972,22 @@ gtk_flow_box_add_move_binding (GtkWidgetClass *widget_class,
GtkMovementStep step, GtkMovementStep step,
gint count) gint count)
{ {
GdkModifierType extend_mod_mask = GDK_SHIFT_MASK;
GdkModifierType modify_mod_mask = GDK_CONTROL_MASK;
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask, keyval, modmask,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, FALSE, FALSE);
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask | extend_mod_mask, keyval, modmask | GDK_SHIFT_MASK,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, TRUE, FALSE);
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask | modify_mod_mask, keyval, modmask | GDK_CONTROL_MASK,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, FALSE, TRUE);
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask | extend_mod_mask | modify_mod_mask, keyval, modmask | GDK_SHIFT_MASK | GDK_CONTROL_MASK,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, TRUE, TRUE);
} }
static void static void
@ -3038,11 +3015,11 @@ gtk_flow_box_toggle_cursor_child (GtkFlowBox *box)
static gboolean static gboolean
gtk_flow_box_move_cursor (GtkFlowBox *box, gtk_flow_box_move_cursor (GtkFlowBox *box,
GtkMovementStep step, GtkMovementStep step,
gint count) gint count,
gboolean extend,
gboolean modify)
{ {
GtkFlowBoxPrivate *priv = BOX_PRIV (box); GtkFlowBoxPrivate *priv = BOX_PRIV (box);
gboolean modify;
gboolean extend;
GtkFlowBoxChild *child; GtkFlowBoxChild *child;
GtkFlowBoxChild *prev; GtkFlowBoxChild *prev;
GtkFlowBoxChild *next; GtkFlowBoxChild *next;
@ -3227,8 +3204,6 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
} }
} }
get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
gtk_flow_box_update_cursor (box, child); gtk_flow_box_update_cursor (box, child);
if (!modify) if (!modify)
gtk_flow_box_update_selection (box, child, FALSE, extend); gtk_flow_box_update_selection (box, child, FALSE, extend);
@ -3577,6 +3552,8 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
* @box: the #GtkFlowBox on which the signal is emitted * @box: the #GtkFlowBox on which the signal is emitted
* @step: the granularity fo the move, as a #GtkMovementStep * @step: the granularity fo the move, as a #GtkMovementStep
* @count: the number of @step units to move * @count: the number of @step units to move
* @extend: whether to extend the selection
* @modify: whether to modify the selection
* *
* The ::move-cursor signal is a * The ::move-cursor signal is a
* [keybinding signal][GtkBindingSignal] * [keybinding signal][GtkBindingSignal]
@ -3602,12 +3579,12 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkFlowBoxClass, move_cursor), G_STRUCT_OFFSET (GtkFlowBoxClass, move_cursor),
NULL, NULL, NULL, NULL,
_gtk_marshal_BOOLEAN__ENUM_INT, _gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEAN,
G_TYPE_BOOLEAN, 2, G_TYPE_BOOLEAN, 4,
GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT); GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
g_signal_set_va_marshaller (signals[MOVE_CURSOR], g_signal_set_va_marshaller (signals[MOVE_CURSOR],
G_TYPE_FROM_CLASS (class), G_TYPE_FROM_CLASS (class),
_gtk_marshal_BOOLEAN__ENUM_INTv); _gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEANv);
/** /**
* GtkFlowBox::select-all: * GtkFlowBox::select-all:
* @box: the #GtkFlowBox on which the signal is emitted * @box: the #GtkFlowBox on which the signal is emitted

View File

@ -241,7 +241,9 @@ static void gtk_icon_view_add_move_binding (GtkWid
gint count); gint count);
static gboolean gtk_icon_view_real_move_cursor (GtkIconView *icon_view, static gboolean gtk_icon_view_real_move_cursor (GtkIconView *icon_view,
GtkMovementStep step, GtkMovementStep step,
gint count); gint count,
gboolean extend,
gboolean modify);
static void gtk_icon_view_move_cursor_up_down (GtkIconView *icon_view, static void gtk_icon_view_move_cursor_up_down (GtkIconView *icon_view,
gint count); gint count);
static void gtk_icon_view_move_cursor_page_up_down (GtkIconView *icon_view, static void gtk_icon_view_move_cursor_page_up_down (GtkIconView *icon_view,
@ -776,6 +778,8 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
* @iconview: the object which received the signal * @iconview: the object which received the signal
* @step: the granularity of the move, as a #GtkMovementStep * @step: the granularity of the move, as a #GtkMovementStep
* @count: the number of @step units to move * @count: the number of @step units to move
* @extend: whether to extend the selection
* @modify: whether to modify the selection
* *
* The ::move-cursor signal is a * The ::move-cursor signal is a
* [keybinding signal][GtkBindingSignal] * [keybinding signal][GtkBindingSignal]
@ -798,13 +802,15 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkIconViewClass, move_cursor), G_STRUCT_OFFSET (GtkIconViewClass, move_cursor),
NULL, NULL, NULL, NULL,
_gtk_marshal_BOOLEAN__ENUM_INT, _gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEAN,
G_TYPE_BOOLEAN, 2, G_TYPE_BOOLEAN, 4,
GTK_TYPE_MOVEMENT_STEP, GTK_TYPE_MOVEMENT_STEP,
G_TYPE_INT); G_TYPE_INT,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN);
g_signal_set_va_marshaller (icon_view_signals[MOVE_CURSOR], g_signal_set_va_marshaller (icon_view_signals[MOVE_CURSOR],
G_TYPE_FROM_CLASS (klass), G_TYPE_FROM_CLASS (klass),
_gtk_marshal_BOOLEAN__ENUM_INTv); _gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEANv);
/* Key bindings */ /* Key bindings */
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
@ -1823,7 +1829,7 @@ gtk_icon_view_motion (GtkEventController *controller,
icon_view->priv->mouse_x = x; icon_view->priv->mouse_x = x;
icon_view->priv->mouse_y = y; icon_view->priv->mouse_y = y;
device = gtk_get_current_event_device (); /* FIXME: controller device */ device = gtk_event_controller_get_current_event_device (controller);
gtk_icon_view_maybe_begin_drag (icon_view, x, y, device); gtk_icon_view_maybe_begin_drag (icon_view, x, y, device);
if (icon_view->priv->doing_rubberband) if (icon_view->priv->doing_rubberband)
@ -3421,12 +3427,12 @@ gtk_icon_view_add_move_binding (GtkWidgetClass *widget_class,
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask, keyval, modmask,
I_("move-cursor"), I_("move-cursor"),
"(ii)", step, count); "(iibb)", step, count, FALSE, FALSE);
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, GDK_SHIFT_MASK, keyval, GDK_SHIFT_MASK,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, TRUE, FALSE);
if ((modmask & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) if ((modmask & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
return; return;
@ -3434,21 +3440,21 @@ gtk_icon_view_add_move_binding (GtkWidgetClass *widget_class,
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, GDK_CONTROL_MASK | GDK_SHIFT_MASK, keyval, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, TRUE, TRUE);
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, GDK_CONTROL_MASK, keyval, GDK_CONTROL_MASK,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, FALSE, TRUE);
} }
static gboolean static gboolean
gtk_icon_view_real_move_cursor (GtkIconView *icon_view, gtk_icon_view_real_move_cursor (GtkIconView *icon_view,
GtkMovementStep step, GtkMovementStep step,
gint count) gint count,
gboolean extend,
gboolean modify)
{ {
GdkModifierType state;
g_return_val_if_fail (GTK_ICON_VIEW (icon_view), FALSE); g_return_val_if_fail (GTK_ICON_VIEW (icon_view), FALSE);
g_return_val_if_fail (step == GTK_MOVEMENT_LOGICAL_POSITIONS || g_return_val_if_fail (step == GTK_MOVEMENT_LOGICAL_POSITIONS ||
step == GTK_MOVEMENT_VISUAL_POSITIONS || step == GTK_MOVEMENT_VISUAL_POSITIONS ||
@ -3462,17 +3468,8 @@ gtk_icon_view_real_move_cursor (GtkIconView *icon_view,
gtk_cell_area_stop_editing (icon_view->priv->cell_area, FALSE); gtk_cell_area_stop_editing (icon_view->priv->cell_area, FALSE);
gtk_widget_grab_focus (GTK_WIDGET (icon_view)); gtk_widget_grab_focus (GTK_WIDGET (icon_view));
if (gtk_get_current_event_state (&state)) icon_view->priv->extend_selection_pressed = extend;
{ icon_view->priv->modify_selection_pressed = modify;
GdkModifierType extend_mod_mask = GDK_SHIFT_MASK;
GdkModifierType modify_mod_mask = GDK_CONTROL_MASK;
if ((state & modify_mod_mask) == modify_mod_mask)
icon_view->priv->modify_selection_pressed = TRUE;
if ((state & extend_mod_mask) == extend_mod_mask)
icon_view->priv->extend_selection_pressed = TRUE;
}
/* else we assume not pressed */
switch (step) switch (step)
{ {

View File

@ -63,7 +63,9 @@ struct _GtkIconViewClass
void (* toggle_cursor_item) (GtkIconView *icon_view); void (* toggle_cursor_item) (GtkIconView *icon_view);
gboolean (* move_cursor) (GtkIconView *icon_view, gboolean (* move_cursor) (GtkIconView *icon_view,
GtkMovementStep step, GtkMovementStep step,
gint count); gint count,
gboolean extend,
gboolean modify);
gboolean (* activate_cursor_item) (GtkIconView *icon_view); gboolean (* activate_cursor_item) (GtkIconView *icon_view);
}; };

View File

@ -5816,13 +5816,12 @@ gtk_label_activate_link (GtkLabel *label,
{ {
GtkWidget *widget = GTK_WIDGET (label); GtkWidget *widget = GTK_WIDGET (label);
GtkWidget *toplevel = GTK_WIDGET (gtk_widget_get_root (widget)); GtkWidget *toplevel = GTK_WIDGET (gtk_widget_get_root (widget));
guint32 timestamp = gtk_get_current_event_time ();
GError *error = NULL; GError *error = NULL;
if (!GTK_IS_WINDOW (toplevel)) if (!GTK_IS_WINDOW (toplevel))
return FALSE; return FALSE;
if (!gtk_show_uri_on_window (GTK_WINDOW (toplevel), uri, timestamp, &error)) if (!gtk_show_uri_on_window (GTK_WINDOW (toplevel), uri, GDK_CURRENT_TIME, &error))
{ {
g_warning ("Unable to show '%s': %s", uri, error->message); g_warning ("Unable to show '%s': %s", uri, error->message);
g_error_free (error); g_error_free (error);

View File

@ -147,7 +147,9 @@ struct _GtkListBoxClass
void (*toggle_cursor_row) (GtkListBox *box); void (*toggle_cursor_row) (GtkListBox *box);
void (*move_cursor) (GtkListBox *box, void (*move_cursor) (GtkListBox *box,
GtkMovementStep step, GtkMovementStep step,
gint count); gint count,
gboolean extend,
gboolean modify);
void (*selected_rows_changed) (GtkListBox *box); void (*selected_rows_changed) (GtkListBox *box);
void (*select_all) (GtkListBox *box); void (*select_all) (GtkListBox *box);
void (*unselect_all) (GtkListBox *box); void (*unselect_all) (GtkListBox *box);
@ -261,7 +263,9 @@ static void gtk_list_box_activate_cursor_row (GtkListBo
static void gtk_list_box_toggle_cursor_row (GtkListBox *box); static void gtk_list_box_toggle_cursor_row (GtkListBox *box);
static void gtk_list_box_move_cursor (GtkListBox *box, static void gtk_list_box_move_cursor (GtkListBox *box,
GtkMovementStep step, GtkMovementStep step,
gint count); gint count,
gboolean extend,
gboolean modify);
static void gtk_list_box_finalize (GObject *obj); static void gtk_list_box_finalize (GObject *obj);
static void gtk_list_box_parent_cb (GObject *object, static void gtk_list_box_parent_cb (GObject *object,
GParamSpec *pspec, GParamSpec *pspec,
@ -594,12 +598,12 @@ gtk_list_box_class_init (GtkListBoxClass *klass)
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkListBoxClass, move_cursor), G_STRUCT_OFFSET (GtkListBoxClass, move_cursor),
NULL, NULL, NULL, NULL,
_gtk_marshal_VOID__ENUM_INT, _gtk_marshal_VOID__ENUM_INT_BOOLEAN_BOOLEAN,
G_TYPE_NONE, 2, G_TYPE_NONE, 4,
GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT); GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
g_signal_set_va_marshaller (signals[MOVE_CURSOR], g_signal_set_va_marshaller (signals[MOVE_CURSOR],
G_TYPE_FROM_CLASS (klass), G_TYPE_FROM_CLASS (klass),
_gtk_marshal_VOID__ENUM_INTv); _gtk_marshal_VOID__ENUM_INT_BOOLEAN_BOOLEANv);
widget_class->activate_signal = signals[ACTIVATE_CURSOR_ROW]; widget_class->activate_signal = signals[ACTIVATE_CURSOR_ROW];
@ -1426,25 +1430,22 @@ gtk_list_box_add_move_binding (GtkWidgetClass *widget_class,
GtkMovementStep step, GtkMovementStep step,
gint count) gint count)
{ {
GdkModifierType extend_mod_mask = GDK_SHIFT_MASK;
GdkModifierType modify_mod_mask = GDK_CONTROL_MASK;
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask, keyval, modmask,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, FALSE, FALSE);
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask | extend_mod_mask, keyval, modmask | GDK_SHIFT_MASK,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, TRUE, FALSE);
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask | modify_mod_mask, keyval, modmask | GDK_CONTROL_MASK,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, FALSE, TRUE);
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask | extend_mod_mask | modify_mod_mask, keyval, modmask | GDK_SHIFT_MASK | GDK_CONTROL_MASK,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, TRUE, TRUE);
} }
static void static void
@ -1764,28 +1765,6 @@ gtk_list_box_click_gesture_pressed (GtkGestureClick *gesture,
} }
} }
static void
get_current_selection_modifiers (GtkWidget *widget,
gboolean *modify,
gboolean *extend)
{
GdkModifierType state = 0;
GdkModifierType mask;
*modify = FALSE;
*extend = FALSE;
if (gtk_get_current_event_state (&state))
{
mask = GDK_CONTROL_MASK;
if ((state & mask) == mask)
*modify = TRUE;
mask = GDK_SHIFT_MASK;
if ((state & mask) == mask)
*extend = TRUE;
}
}
static void static void
gtk_list_box_click_unpaired_release (GtkGestureClick *gesture, gtk_list_box_click_unpaired_release (GtkGestureClick *gesture,
gdouble x, gdouble x,
@ -1829,16 +1808,19 @@ gtk_list_box_click_gesture_released (GtkGestureClick *gesture,
GdkEventSequence *sequence; GdkEventSequence *sequence;
GdkInputSource source; GdkInputSource source;
GdkEvent *event; GdkEvent *event;
gboolean modify; GdkModifierType state;
gboolean extend; gboolean extend;
gboolean modify;
get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
/* With touch, we default to modifying the selection. /* With touch, we default to modifying the selection.
* You can still clear the selection and start over * You can still clear the selection and start over
* by holding Ctrl. * by holding Ctrl.
*/ */
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)); sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence); event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
state = gdk_event_get_modifier_state (event);
extend = (state & GDK_SHIFT_MASK) != 0;
modify = (state & GDK_CONTROL_MASK) != 0;
source = gdk_device_get_source (gdk_event_get_source_device (event)); source = gdk_device_get_source (gdk_event_get_source_device (event));
if (source == GDK_SOURCE_TOUCHSCREEN) if (source == GDK_SOURCE_TOUCHSCREEN)
@ -2730,10 +2712,10 @@ gtk_list_box_toggle_cursor_row (GtkListBox *box)
static void static void
gtk_list_box_move_cursor (GtkListBox *box, gtk_list_box_move_cursor (GtkListBox *box,
GtkMovementStep step, GtkMovementStep step,
gint count) gint count,
gboolean extend,
gboolean modify)
{ {
gboolean modify;
gboolean extend;
GtkListBoxRow *row; GtkListBoxRow *row;
gint page_size; gint page_size;
GSequenceIter *iter; GSequenceIter *iter;
@ -2851,8 +2833,6 @@ gtk_list_box_move_cursor (GtkListBox *box,
return; return;
} }
get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
gtk_list_box_update_cursor (box, row, TRUE); gtk_list_box_update_cursor (box, row, TRUE);
if (!modify) if (!modify)
gtk_list_box_update_selection (box, row, FALSE, extend); gtk_list_box_update_selection (box, row, FALSE, extend);
@ -2876,18 +2856,11 @@ static void
gtk_list_box_row_set_focus (GtkListBoxRow *row) gtk_list_box_row_set_focus (GtkListBoxRow *row)
{ {
GtkListBox *box = gtk_list_box_row_get_box (row); GtkListBox *box = gtk_list_box_row_get_box (row);
gboolean modify;
gboolean extend;
if (!box) if (!box)
return; return;
get_current_selection_modifiers (GTK_WIDGET (row), &modify, &extend); gtk_list_box_update_selection (box, row, FALSE, FALSE);
if (modify)
gtk_list_box_update_cursor (box, row, TRUE);
else
gtk_list_box_update_selection (box, row, FALSE, FALSE);
} }
static gboolean static gboolean

View File

@ -2014,37 +2014,6 @@ gtk_grab_remove (GtkWidget *widget)
} }
} }
/**
* gtk_get_current_event:
*
* Obtains a reference of the event currently being processed by GTK.
*
* For example, if you are handling a #GtkButton::clicked signal,
* the current event will be the #GdkEventButton that triggered
* the ::clicked signal.
*
* Returns: (transfer full) (nullable): a reference of the current event, or
* %NULL if there is no current event. The returned event must be
* freed with g_object_unref().
*/
GdkEvent*
gtk_get_current_event (void)
{
if (current_events)
return gdk_event_ref (current_events->data);
else
return NULL;
}
/**
* gtk_get_current_event_time:
*
* If there is a current event and it has a timestamp,
* return that timestamp, otherwise return %GDK_CURRENT_TIME.
*
* Returns: the timestamp from the current event,
* or %GDK_CURRENT_TIME.
*/
guint32 guint32
gtk_get_current_event_time (void) gtk_get_current_event_time (void)
{ {
@ -2054,51 +2023,6 @@ gtk_get_current_event_time (void)
return GDK_CURRENT_TIME; return GDK_CURRENT_TIME;
} }
/**
* gtk_get_current_event_state:
* @state: (out): a location to store the state of the current event
*
* If there is a current event and it has a state field, place
* that state field in @state and return %TRUE, otherwise return
* %FALSE.
*
* Returns: %TRUE if there was a current event and it
* had a state field
*/
gboolean
gtk_get_current_event_state (GdkModifierType *state)
{
g_return_val_if_fail (state != NULL, FALSE);
if (current_events)
{
*state = gdk_event_get_modifier_state (current_events->data);
return TRUE;
}
else
{
*state = 0;
return FALSE;
}
}
/**
* gtk_get_current_event_device:
*
* If there is a current event and it has a device, return that
* device, otherwise return %NULL.
*
* Returns: (transfer none) (nullable): a #GdkDevice, or %NULL
*/
GdkDevice *
gtk_get_current_event_device (void)
{
if (current_events)
return gdk_event_get_device (current_events->data);
else
return NULL;
}
/** /**
* gtk_get_event_widget: * gtk_get_event_widget:
* @event: a #GdkEvent * @event: a #GdkEvent

View File

@ -107,15 +107,6 @@ PangoLanguage *gtk_get_default_language (void);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GtkTextDirection gtk_get_locale_direction (void); GtkTextDirection gtk_get_locale_direction (void);
GDK_AVAILABLE_IN_ALL
GdkEvent * gtk_get_current_event (void);
GDK_AVAILABLE_IN_ALL
guint32 gtk_get_current_event_time (void);
GDK_AVAILABLE_IN_ALL
gboolean gtk_get_current_event_state (GdkModifierType *state);
GDK_AVAILABLE_IN_ALL
GdkDevice *gtk_get_current_event_device (void);
G_END_DECLS G_END_DECLS

View File

@ -29,6 +29,7 @@ BOOLEAN:ENUM,BOOLEAN
BOOLEAN:ENUM,BOXED,BOXED,BOXED BOOLEAN:ENUM,BOXED,BOXED,BOXED
BOOLEAN:ENUM,DOUBLE BOOLEAN:ENUM,DOUBLE
BOOLEAN:ENUM,INT BOOLEAN:ENUM,INT
BOOLEAN:ENUM,INT,BOOLEAN,BOOLEAN
BOOLEAN:FLAGS BOOLEAN:FLAGS
BOOLEAN:OBJECT BOOLEAN:OBJECT
BOOLEAN:OBJECT,UINT,FLAGS BOOLEAN:OBJECT,UINT,FLAGS
@ -76,6 +77,7 @@ VOID:ENUM,FLOAT
VOID:ENUM,FLOAT,BOOLEAN VOID:ENUM,FLOAT,BOOLEAN
VOID:ENUM,INT VOID:ENUM,INT
VOID:ENUM,INT,BOOLEAN VOID:ENUM,INT,BOOLEAN
VOID:ENUM,INT,BOOLEAN,BOOLEAN
VOID:ENUM,INT,INT VOID:ENUM,INT,INT
VOID:ENUM,OBJECT VOID:ENUM,OBJECT
VOID:ENUM,STRING VOID:ENUM,STRING

View File

@ -2877,8 +2877,7 @@ gtk_notebook_motion (GtkEventController *controller,
if (!page) if (!page)
return; return;
if (!gtk_get_current_event_state (&state)) state = gtk_event_controller_get_current_event_state (controller);
return;
if (!(state & GDK_BUTTON1_MASK) && if (!(state & GDK_BUTTON1_MASK) &&
notebook->pressed_button != 0) notebook->pressed_button != 0)
@ -2905,7 +2904,7 @@ gtk_notebook_motion (GtkEventController *controller,
notebook->detached_tab = notebook->cur_page; notebook->detached_tab = notebook->cur_page;
surface = gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET (notebook))); surface = gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET (notebook)));
device = gtk_get_current_event_device (); device = gtk_event_controller_get_current_event_device (controller);
content = gdk_content_provider_new_union ((GdkContentProvider *[2]) { content = gdk_content_provider_new_union ((GdkContentProvider *[2]) {
gtk_notebook_root_content_new (notebook), gtk_notebook_root_content_new (notebook),

View File

@ -3420,7 +3420,7 @@ on_row_released (GtkGestureClick *gesture,
NULL); NULL);
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)); button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
gtk_get_current_event_state (&state); state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (gesture));
if (row) if (row)
{ {

View File

@ -91,6 +91,8 @@ void gtk_main_do_event (GdkEvent *event);
GtkWidget *gtk_get_event_widget (GdkEvent *event); GtkWidget *gtk_get_event_widget (GdkEvent *event);
guint32 gtk_get_current_event_time (void);
void check_crossing_invariants (GtkWidget *widget, void check_crossing_invariants (GtkWidget *widget,
GtkCrossingData *crossing); GtkCrossingData *crossing);

View File

@ -30,6 +30,7 @@
#include "gtkadjustmentprivate.h" #include "gtkadjustmentprivate.h"
#include "gtkeventcontrollermotion.h" #include "gtkeventcontrollermotion.h"
#include "gtkeventcontrollerscroll.h" #include "gtkeventcontrollerscroll.h"
#include "gtkeventcontrollerprivate.h"
#include "gtkgesturedrag.h" #include "gtkgesturedrag.h"
#include "gtkgesturelongpress.h" #include "gtkgesturelongpress.h"
#include "gtkgesturepan.h" #include "gtkgesturepan.h"
@ -1171,9 +1172,10 @@ captured_scroll_cb (GtkEventControllerScroll *scroll,
} }
static void static void
captured_motion (GtkScrolledWindow *sw, captured_motion (GtkEventController *controller,
gdouble x, double x,
gdouble y) double y,
GtkScrolledWindow *sw)
{ {
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw); GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw);
GdkDevice *source_device; GdkDevice *source_device;
@ -1185,7 +1187,10 @@ captured_motion (GtkScrolledWindow *sw,
if (!priv->use_indicators) if (!priv->use_indicators)
return; return;
event = gtk_get_current_event (); target = gtk_event_controller_get_target (controller);
state = gtk_event_controller_get_current_event_state (controller);
event = gtk_event_controller_get_current_event (controller);
source_device = gdk_event_get_source_device (event); source_device = gdk_event_get_source_device (event);
input_source = gdk_device_get_source (source_device); input_source = gdk_device_get_source (source_device);
@ -1194,10 +1199,6 @@ captured_motion (GtkScrolledWindow *sw,
if (priv->vscrollbar_visible) if (priv->vscrollbar_visible)
indicator_start_fade (&priv->vindicator, 1.0); indicator_start_fade (&priv->vindicator, 1.0);
state = gdk_event_get_modifier_state (event);
target = gtk_widget_pick (GTK_WIDGET (sw), x, y, GTK_PICK_DEFAULT);
if (!target && if (!target &&
(state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) != 0) (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) != 0)
{ {
@ -1218,8 +1219,6 @@ captured_motion (GtkScrolledWindow *sw,
else else
indicator_set_over (&priv->hindicator, FALSE); indicator_set_over (&priv->hindicator, FALSE);
} }
gdk_event_unref (event);
} }
static gboolean static gboolean
@ -1259,9 +1258,7 @@ scroll_controller_scroll (GtkEventControllerScroll *scroll,
gboolean shifted; gboolean shifted;
GdkModifierType state; GdkModifierType state;
if (!gtk_get_current_event_state (&state)) state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (scroll));
return GDK_EVENT_PROPAGATE;
shifted = (state & GDK_SHIFT_MASK) != 0; shifted = (state & GDK_SHIFT_MASK) != 0;
gtk_scrolled_window_invalidate_overshoot (scrolled_window); gtk_scrolled_window_invalidate_overshoot (scrolled_window);
@ -1343,8 +1340,8 @@ scroll_controller_decelerate (GtkEventControllerScroll *scroll,
gboolean shifted; gboolean shifted;
GdkModifierType state; GdkModifierType state;
if (!gtk_get_current_event_state (&state))
return; state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (scroll));
shifted = (state & GDK_SHIFT_MASK) != 0; shifted = (state & GDK_SHIFT_MASK) != 0;
@ -1970,8 +1967,8 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
controller = gtk_event_controller_motion_new (); controller = gtk_event_controller_motion_new ();
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
g_signal_connect_swapped (controller, "motion", g_signal_connect (controller, "motion",
G_CALLBACK (captured_motion), scrolled_window); G_CALLBACK (captured_motion), scrolled_window);
gtk_widget_add_controller (widget, controller); gtk_widget_add_controller (widget, controller);
widget_node = gtk_widget_get_css_node (widget); widget_node = gtk_widget_get_css_node (widget);

View File

@ -8142,7 +8142,7 @@ gtk_text_view_value_changed (GtkAdjustment *adjustment,
if (gtk_gesture_is_active (priv->drag_gesture)) if (gtk_gesture_is_active (priv->drag_gesture))
{ {
GdkEvent *current_event; GdkEvent *current_event;
current_event = gtk_get_current_event (); current_event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (priv->drag_gesture));
if (current_event != NULL) if (current_event != NULL)
{ {
if (gdk_event_get_event_type (current_event) == GDK_SCROLL) if (gdk_event_get_event_type (current_event) == GDK_SCROLL)
@ -8621,20 +8621,14 @@ gtk_text_view_get_menu_model (GtkTextView *text_view)
} }
static void static void
gtk_text_view_do_popup (GtkTextView *text_view, gtk_text_view_do_popup (GtkTextView *text_view,
GdkEvent *event) GdkEvent *trigger_event)
{ {
GtkTextViewPrivate *priv = text_view->priv; GtkTextViewPrivate *priv = text_view->priv;
GdkEvent *trigger_event;
if (!gtk_widget_get_realized (GTK_WIDGET (text_view))) if (!gtk_widget_get_realized (GTK_WIDGET (text_view)))
return; return;
if (event)
trigger_event = (GdkEvent *)event;
else
trigger_event = gtk_get_current_event ();
gtk_text_view_update_clipboard_actions (text_view); gtk_text_view_update_clipboard_actions (text_view);
if (!priv->popup_menu) if (!priv->popup_menu)
@ -8709,9 +8703,6 @@ gtk_text_view_do_popup (GtkTextView *text_view,
} }
gtk_popover_popup (GTK_POPOVER (priv->popup_menu)); gtk_popover_popup (GTK_POPOVER (priv->popup_menu));
if (trigger_event && trigger_event != event)
gdk_event_unref (trigger_event);
} }
static void static void

View File

@ -345,7 +345,9 @@ struct _GtkTreeViewClass
/* Key Binding signals */ /* Key Binding signals */
gboolean (* move_cursor) (GtkTreeView *tree_view, gboolean (* move_cursor) (GtkTreeView *tree_view,
GtkMovementStep step, GtkMovementStep step,
gint count); gint count,
gboolean extend,
gboolean modify);
gboolean (* select_all) (GtkTreeView *tree_view); gboolean (* select_all) (GtkTreeView *tree_view);
gboolean (* unselect_all) (GtkTreeView *tree_view); gboolean (* unselect_all) (GtkTreeView *tree_view);
gboolean (* select_cursor_row) (GtkTreeView *tree_view, gboolean (* select_cursor_row) (GtkTreeView *tree_view,
@ -715,7 +717,9 @@ static void gtk_tree_view_drag_data_received (GObject
/* tree_model signals */ /* tree_model signals */
static gboolean gtk_tree_view_real_move_cursor (GtkTreeView *tree_view, static gboolean gtk_tree_view_real_move_cursor (GtkTreeView *tree_view,
GtkMovementStep step, GtkMovementStep step,
gint count); gint count,
gboolean extend,
gboolean modify);
static gboolean gtk_tree_view_real_select_all (GtkTreeView *tree_view); static gboolean gtk_tree_view_real_select_all (GtkTreeView *tree_view);
static gboolean gtk_tree_view_real_unselect_all (GtkTreeView *tree_view); static gboolean gtk_tree_view_real_unselect_all (GtkTreeView *tree_view);
static gboolean gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, static gboolean gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view,
@ -850,8 +854,7 @@ static TreeViewDragInfo* get_info (GtkTreeView *tree_view);
/* interactive search */ /* interactive search */
static void gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view); static void gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view);
static void gtk_tree_view_search_popover_hide (GtkWidget *search_popover, static void gtk_tree_view_search_popover_hide (GtkWidget *search_popover,
GtkTreeView *tree_view, GtkTreeView *tree_view);
GdkDevice *device);
static void gtk_tree_view_search_preedit_changed (GtkText *text, static void gtk_tree_view_search_preedit_changed (GtkText *text,
const char *preedit, const char *preedit,
GtkTreeView *tree_view); GtkTreeView *tree_view);
@ -900,7 +903,6 @@ static gboolean gtk_tree_view_start_editing (GtkTreeView *tree_
static void gtk_tree_view_stop_editing (GtkTreeView *tree_view, static void gtk_tree_view_stop_editing (GtkTreeView *tree_view,
gboolean cancel_editing); gboolean cancel_editing);
static gboolean gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view, static gboolean gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view,
GdkDevice *device,
gboolean keybinding); gboolean keybinding);
static gboolean gtk_tree_view_start_interactive_search (GtkTreeView *tree_view); static gboolean gtk_tree_view_start_interactive_search (GtkTreeView *tree_view);
static GtkTreeViewColumn *gtk_tree_view_get_drop_column (GtkTreeView *tree_view, static GtkTreeViewColumn *gtk_tree_view_get_drop_column (GtkTreeView *tree_view,
@ -1376,15 +1378,16 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
/** /**
* GtkTreeView::move-cursor: * GtkTreeView::move-cursor:
* @tree_view: the object on which the signal is emitted. * @tree_view: the object on which the signal is emitted.
* @step: the granularity of the move, as a * @step: the granularity of the move, as a #GtkMovementStep.
* #GtkMovementStep. %GTK_MOVEMENT_LOGICAL_POSITIONS, * %GTK_MOVEMENT_LOGICAL_POSITIONS, %GTK_MOVEMENT_VISUAL_POSITIONS,
* %GTK_MOVEMENT_VISUAL_POSITIONS, %GTK_MOVEMENT_DISPLAY_LINES, * %GTK_MOVEMENT_DISPLAY_LINES, %GTK_MOVEMENT_PAGES and
* %GTK_MOVEMENT_PAGES and %GTK_MOVEMENT_BUFFER_ENDS are * %GTK_MOVEMENT_BUFFER_ENDS are supported.
* supported. %GTK_MOVEMENT_LOGICAL_POSITIONS and * %GTK_MOVEMENT_LOGICAL_POSITIONS and %GTK_MOVEMENT_VISUAL_POSITIONS
* %GTK_MOVEMENT_VISUAL_POSITIONS are treated identically. * are treated identically.
* @direction: the direction to move: +1 to move forwards; * @direction: the direction to move: +1 to move forwards; -1 to move
* -1 to move backwards. The resulting movement is * backwards. The resulting movement is undefined for all other values.
* undefined for all other values. * @extend: whether to extend the selection
* @modify: whether to modify the selection
* *
* The #GtkTreeView::move-cursor signal is a [keybinding * The #GtkTreeView::move-cursor signal is a [keybinding
* signal][GtkBindingSignal] which gets emitted when the user * signal][GtkBindingSignal] which gets emitted when the user
@ -1404,13 +1407,15 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkTreeViewClass, move_cursor), G_STRUCT_OFFSET (GtkTreeViewClass, move_cursor),
NULL, NULL, NULL, NULL,
_gtk_marshal_BOOLEAN__ENUM_INT, _gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEAN,
G_TYPE_BOOLEAN, 2, G_TYPE_BOOLEAN, 4,
GTK_TYPE_MOVEMENT_STEP, GTK_TYPE_MOVEMENT_STEP,
G_TYPE_INT); G_TYPE_INT,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN);
g_signal_set_va_marshaller (tree_view_signals[MOVE_CURSOR], g_signal_set_va_marshaller (tree_view_signals[MOVE_CURSOR],
G_TYPE_FROM_CLASS (o_class), G_TYPE_FROM_CLASS (o_class),
_gtk_marshal_BOOLEAN__ENUM_INTv); _gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEANv);
tree_view_signals[SELECT_ALL] = tree_view_signals[SELECT_ALL] =
g_signal_new (I_("select-all"), g_signal_new (I_("select-all"),
@ -1537,46 +1542,15 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Page_Down, 0, TRUE, gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Page_Down, 0, TRUE,
GTK_MOVEMENT_PAGES, 1); GTK_MOVEMENT_PAGES, 1);
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Right, 0, FALSE,
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Left, 0, FALSE,
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
gtk_widget_class_add_binding_signal (widget_class, gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Right, 0, FALSE,
GDK_KEY_Right, 0, GTK_MOVEMENT_VISUAL_POSITIONS, 1);
"move-cursor", gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Left, 0, FALSE,
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1); GTK_MOVEMENT_VISUAL_POSITIONS, -1);
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_Left, 0,
"move-cursor",
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1);
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_KP_Right, 0,
"move-cursor",
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1);
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_KP_Left, 0,
"move-cursor",
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1);
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_Right, GDK_CONTROL_MASK,
"move-cursor",
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1);
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_Left, GDK_CONTROL_MASK,
"move-cursor",
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1);
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_KP_Right, GDK_CONTROL_MASK,
"move-cursor",
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1);
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_KP_Left, GDK_CONTROL_MASK,
"move-cursor",
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1);
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, GDK_CONTROL_MASK, "toggle-cursor-row", NULL); gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, GDK_CONTROL_MASK, "toggle-cursor-row", NULL);
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, GDK_CONTROL_MASK, "toggle-cursor-row", NULL); gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, GDK_CONTROL_MASK, "toggle-cursor-row", NULL);
@ -2778,33 +2752,23 @@ gtk_tree_view_get_expander_size (GtkTreeView *tree_view)
} }
static void static void
get_current_selection_modifiers (GtkWidget *widget, get_current_selection_modifiers (GtkEventController *controller,
gboolean *modify, gboolean *modify,
gboolean *extend) gboolean *extend)
{ {
GdkModifierType state = 0; GdkModifierType state;
GdkModifierType mask;
*modify = FALSE; state = gtk_event_controller_get_current_event_state (controller);
*extend = FALSE; *modify = (state & GDK_CONTROL_MASK) != 0;
*extend = (state & GDK_SHIFT_MASK) != 0;
if (gtk_get_current_event_state (&state))
{
mask = GDK_CONTROL_MASK;
if ((state & mask) == mask)
*modify = TRUE;
mask = GDK_SHIFT_MASK;
if ((state & mask) == mask)
*extend = TRUE;
}
} }
static void static void
gtk_tree_view_click_gesture_pressed (GtkGestureClick *gesture, gtk_tree_view_click_gesture_pressed (GtkGestureClick *gesture,
gint n_press, int n_press,
gdouble x, double x,
gdouble y, double y,
GtkTreeView *tree_view) GtkTreeView *tree_view)
{ {
GtkWidget *widget = GTK_WIDGET (tree_view); GtkWidget *widget = GTK_WIDGET (tree_view);
GdkRectangle background_area, cell_area; GdkRectangle background_area, cell_area;
@ -3006,7 +2970,7 @@ gtk_tree_view_click_gesture_pressed (GtkGestureClick *gesture,
GtkCellRenderer *focus_cell; GtkCellRenderer *focus_cell;
gboolean modify, extend; gboolean modify, extend;
get_current_selection_modifiers (widget, &modify, &extend); get_current_selection_modifiers (GTK_EVENT_CONTROLLER (gesture), &modify, &extend);
tree_view->modify_selection_pressed = modify; tree_view->modify_selection_pressed = modify;
tree_view->extend_selection_pressed = extend; tree_view->extend_selection_pressed = extend;
@ -3094,7 +3058,7 @@ gtk_tree_view_drag_gesture_begin (GtkGestureDrag *gesture,
tree_view->rubber_band_y += tree_view->dy; tree_view->rubber_band_y += tree_view->dy;
tree_view->rubber_band_status = RUBBER_BAND_MAYBE_START; tree_view->rubber_band_status = RUBBER_BAND_MAYBE_START;
get_current_selection_modifiers (GTK_WIDGET (tree_view), &modify, &extend); get_current_selection_modifiers (GTK_EVENT_CONTROLLER (gesture), &modify, &extend);
tree_view->rubber_band_modify = modify; tree_view->rubber_band_modify = modify;
tree_view->rubber_band_extend = extend; tree_view->rubber_band_extend = extend;
} }
@ -3316,7 +3280,7 @@ gtk_tree_view_click_gesture_released (GtkGestureClick *gesture,
tree_view->button_pressed_node != tree_view->prelight_node) tree_view->button_pressed_node != tree_view->prelight_node)
return; return;
get_current_selection_modifiers (GTK_WIDGET (tree_view), &modify, &extend); get_current_selection_modifiers (GTK_EVENT_CONTROLLER (gesture), &modify, &extend);
if (tree_view->arrow_prelit) if (tree_view->arrow_prelit)
{ {
@ -5466,12 +5430,7 @@ gtk_tree_view_forward_controller_key_pressed (GtkEventControllerKey *key,
gtk_event_controller_key_forward (key, tree_view->search_entry); gtk_event_controller_key_forward (key, tree_view->search_entry);
if (tree_view->imcontext_changed) if (tree_view->imcontext_changed)
{ return gtk_tree_view_real_start_interactive_search (tree_view, FALSE);
GdkDevice *device;
device = gtk_get_current_event_device ();
return gtk_tree_view_real_start_interactive_search (tree_view, device, FALSE);
}
} }
} }
@ -5537,8 +5496,7 @@ gtk_tree_view_focus_controller_focus_out (GtkEventController *focus,
if (tree_view->search_popover && if (tree_view->search_popover &&
!gtk_event_controller_focus_contains_focus (GTK_EVENT_CONTROLLER_FOCUS (focus))) !gtk_event_controller_focus_contains_focus (GTK_EVENT_CONTROLLER_FOCUS (focus)))
gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view, gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view);
gtk_get_current_event_device ());
} }
/* Incremental Reflow /* Incremental Reflow
@ -7937,10 +7895,10 @@ gtk_tree_view_css_changed (GtkWidget *widget,
static gboolean static gboolean
gtk_tree_view_real_move_cursor (GtkTreeView *tree_view, gtk_tree_view_real_move_cursor (GtkTreeView *tree_view,
GtkMovementStep step, GtkMovementStep step,
gint count) gint count,
gboolean extend,
gboolean modify)
{ {
GdkModifierType state;
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE); g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE);
g_return_val_if_fail (step == GTK_MOVEMENT_LOGICAL_POSITIONS || g_return_val_if_fail (step == GTK_MOVEMENT_LOGICAL_POSITIONS ||
step == GTK_MOVEMENT_VISUAL_POSITIONS || step == GTK_MOVEMENT_VISUAL_POSITIONS ||
@ -7957,20 +7915,8 @@ gtk_tree_view_real_move_cursor (GtkTreeView *tree_view,
tree_view->draw_keyfocus = TRUE; tree_view->draw_keyfocus = TRUE;
gtk_widget_grab_focus (GTK_WIDGET (tree_view)); gtk_widget_grab_focus (GTK_WIDGET (tree_view));
if (gtk_get_current_event_state (&state)) tree_view->modify_selection_pressed = modify;
{ tree_view->extend_selection_pressed = extend;
GdkModifierType extend_mod_mask;
GdkModifierType modify_mod_mask;
extend_mod_mask = GDK_SHIFT_MASK;
modify_mod_mask = GDK_CONTROL_MASK;
if ((state & modify_mod_mask) == modify_mod_mask)
tree_view->modify_selection_pressed = TRUE;
if ((state & extend_mod_mask) == extend_mod_mask)
tree_view->extend_selection_pressed = TRUE;
}
/* else we assume not pressed */
switch (step) switch (step)
{ {
@ -8902,30 +8848,30 @@ gtk_tree_view_add_move_binding (GtkWidgetClass *widget_class,
GtkMovementStep step, GtkMovementStep step,
gint count) gint count)
{ {
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask, keyval, modmask,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, FALSE, FALSE);
if (add_shifted_binding) if (add_shifted_binding)
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, GDK_SHIFT_MASK, keyval, GDK_SHIFT_MASK,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, TRUE, FALSE);
if ((modmask & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) if ((modmask & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
return; return;
gtk_widget_class_add_binding_signal (widget_class, keyval,
GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"move-cursor",
"(ii)", step, count);
gtk_widget_class_add_binding_signal (widget_class, gtk_widget_class_add_binding_signal (widget_class,
keyval, GDK_CONTROL_MASK, keyval, GDK_CONTROL_MASK,
"move-cursor", "move-cursor",
"(ii)", step, count); "(iibb)", step, count, FALSE, TRUE);
if (add_shifted_binding)
gtk_widget_class_add_binding_signal (widget_class, keyval,
GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"move-cursor",
"(iibb)", step, count, TRUE, TRUE);
} }
static gint static gint
@ -9960,7 +9906,6 @@ static gboolean
gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view) gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view)
{ {
GtkTreePath *cursor_path = NULL; GtkTreePath *cursor_path = NULL;
GdkModifierType state;
if (!gtk_widget_has_focus (GTK_WIDGET (tree_view))) if (!gtk_widget_has_focus (GTK_WIDGET (tree_view)))
goto out; goto out;
@ -9977,23 +9922,11 @@ gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view)
gtk_tree_path_up (cursor_path); gtk_tree_path_up (cursor_path);
if (gtk_get_current_event_state (&state))
{
GdkModifierType modify_mod_mask;
modify_mod_mask = GDK_CONTROL_MASK;
if ((state & modify_mod_mask) == modify_mod_mask)
tree_view->modify_selection_pressed = TRUE;
}
gtk_tree_view_real_set_cursor (tree_view, cursor_path, CLEAR_AND_SELECT | CLAMP_NODE); gtk_tree_view_real_set_cursor (tree_view, cursor_path, CLEAR_AND_SELECT | CLAMP_NODE);
gtk_tree_path_free (cursor_path); gtk_tree_path_free (cursor_path);
gtk_widget_grab_focus (GTK_WIDGET (tree_view)); gtk_widget_grab_focus (GTK_WIDGET (tree_view));
tree_view->modify_selection_pressed = FALSE;
return TRUE; return TRUE;
} }
@ -10006,7 +9939,7 @@ gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view)
static gboolean static gboolean
gtk_tree_view_search_entry_flush_timeout (GtkTreeView *tree_view) gtk_tree_view_search_entry_flush_timeout (GtkTreeView *tree_view)
{ {
gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view, NULL); gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view);
tree_view->typeselect_flush_timeout = 0; tree_view->typeselect_flush_timeout = 0;
return FALSE; return FALSE;
@ -10067,7 +10000,6 @@ gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view)
*/ */
static gboolean static gboolean
gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view, gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view,
GdkDevice *device,
gboolean keybinding) gboolean keybinding)
{ {
/* We only start interactive search if we have focus or the columns /* We only start interactive search if we have focus or the columns
@ -10148,9 +10080,7 @@ gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view,
static gboolean static gboolean
gtk_tree_view_start_interactive_search (GtkTreeView *tree_view) gtk_tree_view_start_interactive_search (GtkTreeView *tree_view)
{ {
return gtk_tree_view_real_start_interactive_search (tree_view, return gtk_tree_view_real_start_interactive_search (tree_view, TRUE);
gtk_get_current_event_device (),
TRUE);
} }
/* Callbacks */ /* Callbacks */
@ -13527,8 +13457,7 @@ gtk_tree_view_set_search_entry (GtkTreeView *tree_view,
static void static void
gtk_tree_view_search_popover_hide (GtkWidget *search_popover, gtk_tree_view_search_popover_hide (GtkWidget *search_popover,
GtkTreeView *tree_view, GtkTreeView *tree_view)
GdkDevice *device)
{ {
if (tree_view->disable_popdown) if (tree_view->disable_popdown)
return; return;
@ -13587,9 +13516,7 @@ gtk_tree_view_search_activate (GtkEntry *entry,
{ {
GtkTreePath *path; GtkTreePath *path;
gtk_tree_view_search_popover_hide (tree_view->search_popover, gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view);
tree_view,
gtk_get_current_event_device ());
/* If we have a row selected and it's the cursor row, we activate /* If we have a row selected and it's the cursor row, we activate
* the row XXX */ * the row XXX */
@ -13612,14 +13539,7 @@ gtk_tree_view_search_pressed_cb (GtkGesture *gesture,
double y, double y,
GtkTreeView *tree_view) GtkTreeView *tree_view)
{ {
GdkDevice *keyb_device; gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view);
GdkEventSequence *sequence;
GdkEvent *event;
sequence = gtk_gesture_get_last_updated_sequence (gesture);
event = gtk_gesture_get_last_event (gesture, sequence);
keyb_device = gdk_device_get_associated_device (gdk_event_get_device (event));
gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view, keyb_device);
} }
static gboolean static gboolean
@ -13670,8 +13590,7 @@ gtk_tree_view_search_key_pressed (GtkEventControllerKey *key,
if (!tree_view->search_custom_entry_set if (!tree_view->search_custom_entry_set
&& gtk_tree_view_search_key_cancels_search (keyval)) && gtk_tree_view_search_key_cancels_search (keyval))
{ {
gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view, gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view);
gtk_get_current_event_device ());
return TRUE; return TRUE;
} }

View File

@ -1425,7 +1425,7 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
gtk_gesture_get_device (GTK_GESTURE (gesture)), gtk_gesture_get_device (GTK_GESTURE (gesture)),
gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)), gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)),
(int)start_x, (int)start_y, (int)start_x, (int)start_y,
gtk_get_current_event_time ()); gdk_event_get_time (gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture))));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture)); gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (priv->click_gesture)); gtk_event_controller_reset (GTK_EVENT_CONTROLLER (priv->click_gesture));

View File

@ -40,7 +40,6 @@ static void
on_button_toggle (GtkWidget *button, gpointer data) on_button_toggle (GtkWidget *button, gpointer data)
{ {
GdkSurface *surface = GDK_SURFACE (data); GdkSurface *surface = GDK_SURFACE (data);
GdkEvent *event;
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
{ {
@ -49,8 +48,7 @@ on_button_toggle (GtkWidget *button, gpointer data)
} }
gtk_check_button_set_inconsistent (GTK_CHECK_BUTTON (button), TRUE); gtk_check_button_set_inconsistent (GTK_CHECK_BUTTON (button), TRUE);
event = gtk_get_current_event (); gdk_toplevel_inhibit_system_shortcuts (GDK_TOPLEVEL (surface), NULL);
gdk_toplevel_inhibit_system_shortcuts (GDK_TOPLEVEL (surface), event);
} }
static void static void

View File

@ -19,7 +19,7 @@ start_resize (GtkGestureClick *gesture,
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED); gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
surface = gtk_native_get_surface (gtk_widget_get_native (widget)); surface = gtk_native_get_surface (gtk_widget_get_native (widget));
event = gtk_get_current_event (); event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
if (gdk_event_get_event_type (event) == GDK_BUTTON_PRESS) if (gdk_event_get_event_type (event) == GDK_BUTTON_PRESS)
button = gdk_button_event_get_button (event); button = gdk_button_event_get_button (event);
else else
@ -67,7 +67,7 @@ start_move (GtkGestureClick *gesture,
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED); gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
surface = gtk_native_get_surface (gtk_widget_get_native (widget)); surface = gtk_native_get_surface (gtk_widget_get_native (widget));
event = gtk_get_current_event (); event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
if (gdk_event_get_event_type (event) == GDK_BUTTON_PRESS) if (gdk_event_get_event_type (event) == GDK_BUTTON_PRESS)
button = gdk_button_event_get_button (event); button = gdk_button_event_get_button (event);
else else