Merge branch 'kill-key-events' into 'master'

Kill key events

See merge request GNOME/gtk!160
This commit is contained in:
Matthias Clasen 2018-05-23 01:55:05 +00:00
commit 4bb3ac3e81
9 changed files with 108 additions and 232 deletions

View File

@ -136,7 +136,7 @@ static void gtk_button_get_property (GObject *object,
static void gtk_button_display_changed (GtkWidget *widget, static void gtk_button_display_changed (GtkWidget *widget,
GdkDisplay *previous_display); GdkDisplay *previous_display);
static void gtk_button_unrealize (GtkWidget * widget); static void gtk_button_unrealize (GtkWidget * widget);
static gint gtk_button_key_release (GtkWidget * widget, GdkEventKey * event); static gint gtk_button_event (GtkWidget * widget, GdkEvent * event);
static void gtk_real_button_clicked (GtkButton * button); static void gtk_real_button_clicked (GtkButton * button);
static void gtk_real_button_activate (GtkButton *button); static void gtk_real_button_activate (GtkButton *button);
static void gtk_button_update_state (GtkButton *button); static void gtk_button_update_state (GtkButton *button);
@ -220,7 +220,7 @@ gtk_button_class_init (GtkButtonClass *klass)
widget_class->measure = gtk_button_measure_; widget_class->measure = gtk_button_measure_;
widget_class->display_changed = gtk_button_display_changed; widget_class->display_changed = gtk_button_display_changed;
widget_class->unrealize = gtk_button_unrealize; widget_class->unrealize = gtk_button_unrealize;
widget_class->key_release_event = gtk_button_key_release; widget_class->event = gtk_button_event;
widget_class->state_flags_changed = gtk_button_state_flags_changed; widget_class->state_flags_changed = gtk_button_state_flags_changed;
widget_class->grab_notify = gtk_button_grab_notify; widget_class->grab_notify = gtk_button_grab_notify;
widget_class->unmap = gtk_button_unmap; widget_class->unmap = gtk_button_unmap;
@ -762,21 +762,24 @@ gtk_button_do_release (GtkButton *button,
} }
static gboolean static gboolean
gtk_button_key_release (GtkWidget *widget, gtk_button_event (GtkWidget *widget,
GdkEventKey *event) GdkEvent *event)
{ {
GtkButton *button = GTK_BUTTON (widget); GtkButton *button = GTK_BUTTON (widget);
GtkButtonPrivate *priv = gtk_button_get_instance_private (button); GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
if (gdk_event_get_event_type (event) != GDK_KEY_RELEASE)
return GDK_EVENT_PROPAGATE;
if (priv->activate_timeout) if (priv->activate_timeout)
{ {
gtk_button_finish_activate (button, TRUE); gtk_button_finish_activate (button, TRUE);
return TRUE; return GDK_EVENT_STOP;
} }
else if (GTK_WIDGET_CLASS (gtk_button_parent_class)->key_release_event) else if (GTK_WIDGET_CLASS (gtk_button_parent_class)->event)
return GTK_WIDGET_CLASS (gtk_button_parent_class)->key_release_event (widget, event); return GTK_WIDGET_CLASS (gtk_button_parent_class)->event (widget, event);
else else
return FALSE; return GDK_EVENT_PROPAGATE;
} }
static void static void

View File

@ -4432,14 +4432,17 @@ gtk_cell_editable_entry_activated (GtkEntry *entry, gpointer data)
} }
static gboolean static gboolean
gtk_cell_editable_key_press_event (GtkEntry *entry, gtk_cell_editable_event (GtkEntry *entry,
GdkEventKey *key_event, GdkEvent *event,
gpointer data) gpointer data)
{ {
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry); GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
guint keyval; guint keyval;
if (!gdk_event_get_keyval ((GdkEvent *) key_event, &keyval)) if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
return GDK_EVENT_PROPAGATE;
if (!gdk_event_get_keyval (event, &keyval))
return GDK_EVENT_PROPAGATE; return GDK_EVENT_PROPAGATE;
if (keyval == GDK_KEY_Escape) if (keyval == GDK_KEY_Escape)
@ -4469,8 +4472,8 @@ gtk_entry_start_editing (GtkCellEditable *cell_editable,
{ {
g_signal_connect (cell_editable, "activate", g_signal_connect (cell_editable, "activate",
G_CALLBACK (gtk_cell_editable_entry_activated), NULL); G_CALLBACK (gtk_cell_editable_entry_activated), NULL);
g_signal_connect (cell_editable, "key-press-event", g_signal_connect (cell_editable, "event",
G_CALLBACK (gtk_cell_editable_key_press_event), NULL); G_CALLBACK (gtk_cell_editable_event), NULL);
} }
static void static void

View File

@ -85,7 +85,7 @@ static void gtk_file_chooser_entry_finalize (GObject *object)
static void gtk_file_chooser_entry_dispose (GObject *object); static void gtk_file_chooser_entry_dispose (GObject *object);
static void gtk_file_chooser_entry_grab_focus (GtkWidget *widget); static void gtk_file_chooser_entry_grab_focus (GtkWidget *widget);
static gboolean gtk_file_chooser_entry_tab_handler (GtkWidget *widget, static gboolean gtk_file_chooser_entry_tab_handler (GtkWidget *widget,
GdkEventKey *event); GdkEvent *event);
static gboolean gtk_file_chooser_entry_event (GtkWidget *widget, static gboolean gtk_file_chooser_entry_event (GtkWidget *widget,
GdkEvent *event); GdkEvent *event);
@ -295,7 +295,7 @@ _gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry)
g_object_unref (comp); g_object_unref (comp);
/* NB: This needs to happen after the completion is set, so this handler /* NB: This needs to happen after the completion is set, so this handler
* runs before the handler installed by entrycompletion */ * runs before the handler installed by entrycompletion */
g_signal_connect (chooser_entry, "key-press-event", g_signal_connect (chooser_entry, "event",
G_CALLBACK (gtk_file_chooser_entry_tab_handler), NULL); G_CALLBACK (gtk_file_chooser_entry_tab_handler), NULL);
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
@ -497,7 +497,7 @@ start_explicit_completion (GtkFileChooserEntry *chooser_entry)
static gboolean static gboolean
gtk_file_chooser_entry_tab_handler (GtkWidget *widget, gtk_file_chooser_entry_tab_handler (GtkWidget *widget,
GdkEventKey *event) GdkEvent *event)
{ {
GtkFileChooserEntry *chooser_entry; GtkFileChooserEntry *chooser_entry;
GtkEditable *editable; GtkEditable *editable;
@ -508,25 +508,28 @@ gtk_file_chooser_entry_tab_handler (GtkWidget *widget,
chooser_entry = GTK_FILE_CHOOSER_ENTRY (widget); chooser_entry = GTK_FILE_CHOOSER_ENTRY (widget);
editable = GTK_EDITABLE (widget); editable = GTK_EDITABLE (widget);
if (!gdk_event_get_keyval ((GdkEvent *) event, &keyval)) if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
return GDK_EVENT_PROPAGATE;
if (!gdk_event_get_keyval (event, &keyval))
return GDK_EVENT_PROPAGATE; return GDK_EVENT_PROPAGATE;
if (keyval == GDK_KEY_Escape && if (keyval == GDK_KEY_Escape &&
chooser_entry->eat_escape) chooser_entry->eat_escape)
{ {
g_signal_emit (widget, signals[HIDE_ENTRY], 0); g_signal_emit (widget, signals[HIDE_ENTRY], 0);
return TRUE; return GDK_EVENT_STOP;
} }
if (!chooser_entry->eat_tabs) if (!chooser_entry->eat_tabs)
return FALSE; return GDK_EVENT_PROPAGATE;
if (keyval != GDK_KEY_Tab) if (keyval != GDK_KEY_Tab)
return FALSE; return GDK_EVENT_PROPAGATE;
if (gtk_get_current_event_state (&state) && if (gtk_get_current_event_state (&state) &&
(state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) (state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
return FALSE; return GDK_EVENT_PROPAGATE;
/* This is a bit evil -- it makes Tab never leave the entry. It basically /* This is a bit evil -- it makes Tab never leave the entry. It basically
* makes it 'safe' for people to hit. */ * makes it 'safe' for people to hit. */
@ -537,7 +540,7 @@ gtk_file_chooser_entry_tab_handler (GtkWidget *widget,
else else
start_explicit_completion (chooser_entry); start_explicit_completion (chooser_entry);
return TRUE; return GDK_EVENT_STOP;
} }
static gboolean static gboolean

View File

@ -456,8 +456,8 @@ static void gtk_file_chooser_widget_hierarchy_changed (GtkWidget *w
static void gtk_file_chooser_widget_style_updated (GtkWidget *widget); static void gtk_file_chooser_widget_style_updated (GtkWidget *widget);
static void gtk_file_chooser_widget_display_changed (GtkWidget *widget, static void gtk_file_chooser_widget_display_changed (GtkWidget *widget,
GdkDisplay *previous_display); GdkDisplay *previous_display);
static gboolean gtk_file_chooser_widget_key_press_event (GtkWidget *widget, static gboolean gtk_file_chooser_widget_event (GtkWidget *widget,
GdkEventKey *event); GdkEvent *event);
static gboolean gtk_file_chooser_widget_set_current_folder (GtkFileChooser *chooser, static gboolean gtk_file_chooser_widget_set_current_folder (GtkFileChooser *chooser,
GFile *folder, GFile *folder,
@ -1382,15 +1382,18 @@ key_press_cb (GtkEventController *controller,
} }
static gboolean static gboolean
gtk_file_chooser_widget_key_press_event (GtkWidget *widget, gtk_file_chooser_widget_event (GtkWidget *widget,
GdkEventKey *event) GdkEvent *event)
{ {
GtkFileChooserWidget *impl = (GtkFileChooserWidget *) widget; GtkFileChooserWidget *impl = (GtkFileChooserWidget *) widget;
GtkFileChooserWidgetPrivate *priv = impl->priv; GtkFileChooserWidgetPrivate *priv = impl->priv;
guint keyval, state; guint keyval, state;
gdk_event_get_keyval ((GdkEvent *)event, &keyval); if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
gdk_event_get_state ((GdkEvent *)event, &state); return GDK_EVENT_PROPAGATE;
gdk_event_get_keyval (event, &keyval);
gdk_event_get_state (event, &state);
if (should_trigger_location_entry (impl, keyval, state)) if (should_trigger_location_entry (impl, keyval, state))
{ {
@ -1399,22 +1402,22 @@ gtk_file_chooser_widget_key_press_event (GtkWidget *widget,
{ {
const char *string; const char *string;
gdk_event_get_string ((GdkEvent *)event, &string); gdk_event_get_string (event, &string);
location_popup_handler (impl, string); location_popup_handler (impl, string);
return TRUE; return GDK_EVENT_STOP;
} }
} }
else if (gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (priv->search_entry), (GdkEvent *)event)) else if (gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (priv->search_entry), event))
{ {
if (priv->operation_mode != OPERATION_MODE_SEARCH) if (priv->operation_mode != OPERATION_MODE_SEARCH)
operation_mode_set (impl, OPERATION_MODE_SEARCH); operation_mode_set (impl, OPERATION_MODE_SEARCH);
return TRUE; return GDK_EVENT_STOP;
} }
if (GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->key_press_event (widget, event)) if (GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->event (widget, event))
return TRUE; return GDK_EVENT_STOP;
return FALSE; return GDK_EVENT_PROPAGATE;
} }
/* Callback used from gtk_tree_selection_selected_foreach(); adds a bookmark for /* Callback used from gtk_tree_selection_selected_foreach(); adds a bookmark for
@ -2537,14 +2540,17 @@ location_entry_create (GtkFileChooserWidget *impl)
} }
static gboolean static gboolean
external_entry_key_press (GtkWidget *entry, external_entry_event (GtkWidget *entry,
GdkEventKey *event, GdkEvent *event,
GtkFileChooserWidget *impl) GtkFileChooserWidget *impl)
{ {
/* Since the entry is not a descendent of the file chooser widget /* Since the entry is not a descendent of the file chooser widget
* in this case, we need to manually make our bindings apply. * in this case, we need to manually make our bindings apply.
*/ */
return gtk_bindings_activate_event (G_OBJECT (impl), event); if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
return GDK_EVENT_PROPAGATE;
return gtk_bindings_activate_event (G_OBJECT (impl), (GdkEventKey *)event);
} }
/* Creates the widgets specific to Save mode */ /* Creates the widgets specific to Save mode */
@ -2569,8 +2575,8 @@ save_widgets_create (GtkFileChooserWidget *impl)
priv->location_entry = priv->external_entry; priv->location_entry = priv->external_entry;
location_entry_setup (impl); location_entry_setup (impl);
g_signal_connect_after (priv->external_entry, "key-press-event", g_signal_connect_after (priv->external_entry, "event",
G_CALLBACK (external_entry_key_press), impl); G_CALLBACK (external_entry_event), impl);
return; return;
} }
@ -2611,7 +2617,7 @@ save_widgets_destroy (GtkFileChooserWidget *impl)
if (priv->external_entry && priv->external_entry == priv->location_entry) if (priv->external_entry && priv->external_entry == priv->location_entry)
{ {
g_signal_handlers_disconnect_by_func (priv->external_entry, external_entry_key_press, impl); g_signal_handlers_disconnect_by_func (priv->external_entry, external_entry_event, impl);
location_entry_disconnect (impl); location_entry_disconnect (impl);
priv->location_entry = NULL; priv->location_entry = NULL;
@ -7980,7 +7986,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
widget_class->hierarchy_changed = gtk_file_chooser_widget_hierarchy_changed; widget_class->hierarchy_changed = gtk_file_chooser_widget_hierarchy_changed;
widget_class->style_updated = gtk_file_chooser_widget_style_updated; widget_class->style_updated = gtk_file_chooser_widget_style_updated;
widget_class->display_changed = gtk_file_chooser_widget_display_changed; widget_class->display_changed = gtk_file_chooser_widget_display_changed;
widget_class->key_press_event = gtk_file_chooser_widget_key_press_event; widget_class->event = gtk_file_chooser_widget_event;
widget_class->measure = gtk_file_chooser_widget_measure; widget_class->measure = gtk_file_chooser_widget_measure;
widget_class->size_allocate = gtk_file_chooser_widget_size_allocate; widget_class->size_allocate = gtk_file_chooser_widget_size_allocate;
widget_class->snapshot = gtk_file_chooser_widget_snapshot; widget_class->snapshot = gtk_file_chooser_widget_snapshot;

View File

@ -124,16 +124,19 @@ font_activated_cb (GtkFontChooser *fontchooser,
} }
static gboolean static gboolean
gtk_font_chooser_dialog_key_press_event (GtkWidget *dialog, gtk_font_chooser_dialog_event (GtkWidget *dialog,
GdkEventKey *event) GdkEvent *event)
{ {
GtkFontChooserDialog *fdialog = GTK_FONT_CHOOSER_DIALOG (dialog); GtkFontChooserDialog *fdialog = GTK_FONT_CHOOSER_DIALOG (dialog);
gboolean handled = FALSE; gboolean handled = FALSE;
handled = GTK_WIDGET_CLASS (gtk_font_chooser_dialog_parent_class)->key_press_event (dialog, event); if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
return GDK_EVENT_PROPAGATE;
handled = GTK_WIDGET_CLASS (gtk_font_chooser_dialog_parent_class)->event (dialog, event);
if (!handled) if (!handled)
handled = gtk_font_chooser_widget_handle_event (fdialog->priv->fontchooser, event); handled = gtk_font_chooser_widget_handle_event (fdialog->priv->fontchooser, (GdkEventKey *)event);
return handled; return handled;
} }
@ -205,7 +208,7 @@ gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
gobject_class->get_property = gtk_font_chooser_dialog_get_property; gobject_class->get_property = gtk_font_chooser_dialog_get_property;
gobject_class->set_property = gtk_font_chooser_dialog_set_property; gobject_class->set_property = gtk_font_chooser_dialog_set_property;
widget_class->key_press_event = gtk_font_chooser_dialog_key_press_event; widget_class->event = gtk_font_chooser_dialog_event;
widget_class->map = gtk_font_chooser_dialog_map; widget_class->map = gtk_font_chooser_dialog_map;
_gtk_font_chooser_install_properties (gobject_class); _gtk_font_chooser_install_properties (gobject_class);

View File

@ -268,8 +268,6 @@ static gboolean gtk_spin_button_timer (GtkSpinButton *spin_button)
static gboolean gtk_spin_button_stop_spinning (GtkSpinButton *spin); static gboolean gtk_spin_button_stop_spinning (GtkSpinButton *spin);
static void gtk_spin_button_value_changed (GtkAdjustment *adjustment, static void gtk_spin_button_value_changed (GtkAdjustment *adjustment,
GtkSpinButton *spin_button); GtkSpinButton *spin_button);
static gint gtk_spin_button_key_release (GtkWidget *widget,
GdkEventKey *event);
static void gtk_spin_button_activate (GtkEntry *entry, static void gtk_spin_button_activate (GtkEntry *entry,
gpointer user_data); gpointer user_data);
@ -320,7 +318,6 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
widget_class->realize = gtk_spin_button_realize; widget_class->realize = gtk_spin_button_realize;
widget_class->measure = gtk_spin_button_measure; widget_class->measure = gtk_spin_button_measure;
widget_class->size_allocate = gtk_spin_button_size_allocate; widget_class->size_allocate = gtk_spin_button_size_allocate;
widget_class->key_release_event = gtk_spin_button_key_release;
widget_class->event = gtk_spin_button_event; widget_class->event = gtk_spin_button_event;
widget_class->grab_notify = gtk_spin_button_grab_notify; widget_class->grab_notify = gtk_spin_button_grab_notify;
widget_class->state_flags_changed = gtk_spin_button_state_flags_changed; widget_class->state_flags_changed = gtk_spin_button_state_flags_changed;
@ -1089,6 +1086,14 @@ gtk_spin_button_event (GtkWidget *widget,
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget); GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button); GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button);
if (gdk_event_get_event_type (event) == GDK_KEY_RELEASE)
{
/* We only get a release at the end of a key repeat run, so reset the timer_step */
priv->timer_step = gtk_adjustment_get_step_increment (priv->adjustment);
priv->timer_calls = 0;
return GDK_EVENT_STOP;
}
if (gdk_event_get_event_type (event) == GDK_FOCUS_CHANGE) if (gdk_event_get_event_type (event) == GDK_FOCUS_CHANGE)
{ {
gboolean focus_in; gboolean focus_in;
@ -1298,20 +1303,6 @@ gtk_spin_button_real_change_value (GtkSpinButton *spin,
gtk_widget_error_bell (GTK_WIDGET (spin)); gtk_widget_error_bell (GTK_WIDGET (spin));
} }
static gint
gtk_spin_button_key_release (GtkWidget *widget,
GdkEventKey *event)
{
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin);
/* We only get a release at the end of a key repeat run, so reset the timer_step */
priv->timer_step = gtk_adjustment_get_step_increment (priv->adjustment);
priv->timer_calls = 0;
return TRUE;
}
static void static void
gtk_spin_button_snap (GtkSpinButton *spin_button, gtk_spin_button_snap (GtkSpinButton *spin_button,
gdouble val) gdouble val)

View File

@ -599,10 +599,6 @@ static void gtk_tree_view_size_allocate (GtkWidget *widget,
int baseline); int baseline);
static void gtk_tree_view_snapshot (GtkWidget *widget, static void gtk_tree_view_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot); GtkSnapshot *snapshot);
static gboolean gtk_tree_view_key_press (GtkWidget *widget,
GdkEventKey *event);
static gboolean gtk_tree_view_key_release (GtkWidget *widget,
GdkEventKey *event);
static void gtk_tree_view_set_focus_child (GtkContainer *container, static void gtk_tree_view_set_focus_child (GtkContainer *container,
GtkWidget *child); GtkWidget *child);
@ -815,8 +811,8 @@ static void gtk_tree_view_search_scroll_event (GtkWidget *entry
gdouble dx, gdouble dx,
gdouble dy, gdouble dy,
GtkTreeView *tree_view); GtkTreeView *tree_view);
static gboolean gtk_tree_view_search_key_press_event (GtkWidget *entry, static gboolean gtk_tree_view_search_event (GtkWidget *entry,
GdkEventKey *event, GdkEvent *event,
GtkTreeView *tree_view); GtkTreeView *tree_view);
static gboolean gtk_tree_view_search_move (GtkWidget *window, static gboolean gtk_tree_view_search_move (GtkWidget *window,
GtkTreeView *tree_view, GtkTreeView *tree_view,
@ -972,8 +968,6 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
widget_class->measure = gtk_tree_view_measure; widget_class->measure = gtk_tree_view_measure;
widget_class->size_allocate = gtk_tree_view_size_allocate; widget_class->size_allocate = gtk_tree_view_size_allocate;
widget_class->snapshot = gtk_tree_view_snapshot; widget_class->snapshot = gtk_tree_view_snapshot;
widget_class->key_press_event = gtk_tree_view_key_press;
widget_class->key_release_event = gtk_tree_view_key_release;
widget_class->event = gtk_tree_view_event; widget_class->event = gtk_tree_view_event;
widget_class->drag_begin = gtk_tree_view_drag_begin; widget_class->drag_begin = gtk_tree_view_drag_begin;
widget_class->drag_end = gtk_tree_view_drag_end; widget_class->drag_end = gtk_tree_view_drag_end;
@ -2101,7 +2095,7 @@ gtk_tree_view_destroy (GtkWidget *widget)
G_CALLBACK (gtk_tree_view_search_init), G_CALLBACK (gtk_tree_view_search_init),
tree_view); tree_view);
g_signal_handlers_disconnect_by_func (tree_view->priv->search_entry, g_signal_handlers_disconnect_by_func (tree_view->priv->search_entry,
G_CALLBACK (gtk_tree_view_search_key_press_event), G_CALLBACK (gtk_tree_view_search_event),
tree_view); tree_view);
g_object_unref (tree_view->priv->search_entry); g_object_unref (tree_view->priv->search_entry);
@ -5593,8 +5587,11 @@ gtk_tree_view_key_press (GtkWidget *widget,
} }
/* Chain up to the parent class. It handles the keybindings. */ /* Chain up to the parent class. It handles the keybindings. */
if (GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->key_press_event (widget, event)) if (GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->event)
return TRUE; {
if (GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->event (widget, (GdkEvent *)event))
return TRUE;
}
if (tree_view->priv->search_entry_avoid_unhandled_binding) if (tree_view->priv->search_entry_avoid_unhandled_binding)
{ {
@ -5680,9 +5677,13 @@ gtk_tree_view_key_release (GtkWidget *widget,
GtkTreeView *tree_view = GTK_TREE_VIEW (widget); GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
if (tree_view->priv->rubber_band_status) if (tree_view->priv->rubber_band_status)
return TRUE; return GDK_EVENT_STOP;
return GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->key_release_event (widget, event); /* Chain up to the parent class. It handles the keybindings. */
if (GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->event)
return GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->event (widget, (GdkEvent *)event);
return GDK_EVENT_PROPAGATE;
} }
static void static void
@ -5736,7 +5737,11 @@ gtk_tree_view_event (GtkWidget *widget,
tree_view = GTK_TREE_VIEW (widget); tree_view = GTK_TREE_VIEW (widget);
if (gdk_event_get_event_type (event) == GDK_FOCUS_CHANGE) if (gdk_event_get_event_type (event) == GDK_KEY_PRESS)
return gtk_tree_view_key_press (widget, (GdkEventKey *)event);
else if (gdk_event_get_event_type (event) == GDK_KEY_RELEASE)
return gtk_tree_view_key_release (widget, (GdkEventKey *)event);
else if (gdk_event_get_event_type (event) == GDK_FOCUS_CHANGE)
{ {
gboolean focus_in; gboolean focus_in;
@ -10514,8 +10519,8 @@ gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view)
gtk_window_set_transient_for (GTK_WINDOW (tree_view->priv->search_window), gtk_window_set_transient_for (GTK_WINDOW (tree_view->priv->search_window),
GTK_WINDOW (toplevel)); GTK_WINDOW (toplevel));
g_signal_connect (tree_view->priv->search_window, "key-press-event", g_signal_connect (tree_view->priv->search_window, "event",
G_CALLBACK (gtk_tree_view_search_key_press_event), G_CALLBACK (gtk_tree_view_search_event),
tree_view); tree_view);
gesture = gtk_gesture_multi_press_new (); gesture = gtk_gesture_multi_press_new ();
g_signal_connect (gesture, "pressed", g_signal_connect (gesture, "pressed",
@ -13976,7 +13981,7 @@ gtk_tree_view_set_search_entry (GtkTreeView *tree_view,
tree_view->priv->search_entry_changed_id = 0; tree_view->priv->search_entry_changed_id = 0;
} }
g_signal_handlers_disconnect_by_func (tree_view->priv->search_entry, g_signal_handlers_disconnect_by_func (tree_view->priv->search_entry,
G_CALLBACK (gtk_tree_view_search_key_press_event), G_CALLBACK (gtk_tree_view_search_event),
tree_view); tree_view);
g_object_unref (tree_view->priv->search_entry); g_object_unref (tree_view->priv->search_entry);
@ -13999,8 +14004,8 @@ gtk_tree_view_set_search_entry (GtkTreeView *tree_view,
tree_view); tree_view);
} }
g_signal_connect (tree_view->priv->search_entry, "key-press-event", g_signal_connect (tree_view->priv->search_entry, "event",
G_CALLBACK (gtk_tree_view_search_key_press_event), G_CALLBACK (gtk_tree_view_search_event),
tree_view); tree_view);
gtk_tree_view_search_init (tree_view->priv->search_entry, tree_view); gtk_tree_view_search_init (tree_view->priv->search_entry, tree_view);
@ -14260,9 +14265,9 @@ gtk_tree_view_search_scroll_event (GtkWidget *widget,
} }
static gboolean static gboolean
gtk_tree_view_search_key_press_event (GtkWidget *widget, gtk_tree_view_search_event (GtkWidget *widget,
GdkEventKey *event, GdkEvent *event,
GtkTreeView *tree_view) GtkTreeView *tree_view)
{ {
GdkModifierType default_accel; GdkModifierType default_accel;
gboolean retval = FALSE; gboolean retval = FALSE;
@ -14271,8 +14276,11 @@ gtk_tree_view_search_key_press_event (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE); g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE);
if (!gdk_event_get_keyval ((GdkEvent *) event, &keyval) || if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
!gdk_event_get_state ((GdkEvent *) event, &state)) return GDK_EVENT_PROPAGATE;
if (!gdk_event_get_keyval (event, &keyval) ||
!gdk_event_get_state (event, &state))
return GDK_EVENT_PROPAGATE; return GDK_EVENT_PROPAGATE;
/* close window and cancel the search */ /* close window and cancel the search */
@ -14280,7 +14288,7 @@ gtk_tree_view_search_key_press_event (GtkWidget *widget,
&& gtk_tree_view_search_key_cancels_search (keyval)) && gtk_tree_view_search_key_cancels_search (keyval))
{ {
gtk_tree_view_search_window_hide (widget, tree_view, gtk_tree_view_search_window_hide (widget, tree_view,
gdk_event_get_device ((GdkEvent *) event)); gdk_event_get_device (event));
return TRUE; return TRUE;
} }

View File

@ -483,8 +483,6 @@ enum {
MOVE_FOCUS, MOVE_FOCUS,
KEYNAV_FAILED, KEYNAV_FAILED,
EVENT, EVENT,
KEY_PRESS_EVENT,
KEY_RELEASE_EVENT,
DRAG_BEGIN, DRAG_BEGIN,
DRAG_END, DRAG_END,
DRAG_DATA_DELETE, DRAG_DATA_DELETE,
@ -594,10 +592,6 @@ static void gtk_widget_real_style_updated (GtkWidget *widget);
static void gtk_widget_dispatch_child_properties_changed (GtkWidget *object, static void gtk_widget_dispatch_child_properties_changed (GtkWidget *object,
guint n_pspecs, guint n_pspecs,
GParamSpec **pspecs); GParamSpec **pspecs);
static gboolean gtk_widget_real_key_press_event (GtkWidget *widget,
GdkEventKey *event);
static gboolean gtk_widget_real_key_release_event (GtkWidget *widget,
GdkEventKey *event);
static gboolean gtk_widget_real_focus (GtkWidget *widget, static gboolean gtk_widget_real_focus (GtkWidget *widget,
GtkDirectionType direction); GtkDirectionType direction);
static void gtk_widget_real_move_focus (GtkWidget *widget, static void gtk_widget_real_move_focus (GtkWidget *widget,
@ -922,8 +916,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->move_focus = gtk_widget_real_move_focus; klass->move_focus = gtk_widget_real_move_focus;
klass->keynav_failed = gtk_widget_real_keynav_failed; klass->keynav_failed = gtk_widget_real_keynav_failed;
klass->event = NULL; klass->event = NULL;
klass->key_press_event = gtk_widget_real_key_press_event;
klass->key_release_event = gtk_widget_real_key_release_event;
klass->drag_begin = NULL; klass->drag_begin = NULL;
klass->drag_end = NULL; klass->drag_end = NULL;
klass->drag_data_delete = NULL; klass->drag_data_delete = NULL;
@ -1722,61 +1714,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
g_signal_set_va_marshaller (widget_signals[EVENT], G_TYPE_FROM_CLASS (klass), g_signal_set_va_marshaller (widget_signals[EVENT], G_TYPE_FROM_CLASS (klass),
_gtk_marshal_BOOLEAN__OBJECTv); _gtk_marshal_BOOLEAN__OBJECTv);
/**
* GtkWidget::key-press-event:
* @widget: the object which received the signal
* @event: (type Gdk.EventKey): the #GdkEventKey which triggered this signal.
*
* The ::key-press-event signal is emitted when a key is pressed. The signal
* emission will reoccur at the key-repeat rate when the key is kept pressed.
*
* To receive this signal, the #GdkSurface associated to the widget needs
* to enable the #GDK_KEY_PRESS_MASK mask.
*
* This signal will be sent to the grab widget if there is one.
*
* Returns: %TRUE to stop other handlers from being invoked for the event.
* %FALSE to propagate the event further.
*/
widget_signals[KEY_PRESS_EVENT] =
g_signal_new (I_("key-press-event"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, key_press_event),
_gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__OBJECT,
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT);
g_signal_set_va_marshaller (widget_signals[KEY_PRESS_EVENT], G_TYPE_FROM_CLASS (klass),
_gtk_marshal_BOOLEAN__OBJECTv);
/**
* GtkWidget::key-release-event:
* @widget: the object which received the signal
* @event: (type Gdk.EventKey): the #GdkEventKey which triggered this signal.
*
* The ::key-release-event signal is emitted when a key is released.
*
* To receive this signal, the #GdkSurface associated to the widget needs
* to enable the #GDK_KEY_RELEASE_MASK mask.
*
* This signal will be sent to the grab widget if there is one.
*
* Returns: %TRUE to stop other handlers from being invoked for the event.
* %FALSE to propagate the event further.
*/
widget_signals[KEY_RELEASE_EVENT] =
g_signal_new (I_("key-release-event"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, key_release_event),
_gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__OBJECT,
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT);
g_signal_set_va_marshaller (widget_signals[KEY_RELEASE_EVENT], G_TYPE_FROM_CLASS (klass),
_gtk_marshal_BOOLEAN__OBJECTv);
/** /**
* GtkWidget::drag-leave: * GtkWidget::drag-leave:
* @widget: the object which received the signal. * @widget: the object which received the signal.
@ -5123,20 +5060,6 @@ gtk_widget_get_renderer (GtkWidget *widget)
return NULL; return NULL;
} }
static gboolean
gtk_widget_real_key_press_event (GtkWidget *widget,
GdkEventKey *event)
{
return FALSE;
}
static gboolean
gtk_widget_real_key_release_event (GtkWidget *widget,
GdkEventKey *event)
{
return FALSE;
}
#define WIDGET_REALIZED_FOR_EVENT(widget, event) \ #define WIDGET_REALIZED_FOR_EVENT(widget, event) \
(event->any.type == GDK_FOCUS_CHANGE || _gtk_widget_get_realized(widget)) (event->any.type == GDK_FOCUS_CHANGE || _gtk_widget_get_realized(widget))
@ -5405,64 +5328,6 @@ gtk_widget_emit_event_signals (GtkWidget *widget,
g_signal_emit (widget, widget_signals[EVENT], 0, event, &handled); g_signal_emit (widget, widget_signals[EVENT], 0, event, &handled);
return_val |= handled | !WIDGET_REALIZED_FOR_EVENT (widget, event); return_val |= handled | !WIDGET_REALIZED_FOR_EVENT (widget, event);
if (!return_val)
{
gint signal_num;
switch (event->any.type)
{
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
case GDK_DRAG_MOTION:
case GDK_DROP_START:
case GDK_EVENT_LAST:
case GDK_TOUCHPAD_SWIPE:
case GDK_TOUCHPAD_PINCH:
case GDK_PAD_BUTTON_PRESS:
case GDK_PAD_BUTTON_RELEASE:
case GDK_PAD_RING:
case GDK_PAD_STRIP:
case GDK_PAD_GROUP_MODE:
case GDK_PROXIMITY_IN:
case GDK_PROXIMITY_OUT:
case GDK_SCROLL:
case GDK_TOUCH_BEGIN:
case GDK_TOUCH_UPDATE:
case GDK_TOUCH_END:
case GDK_TOUCH_CANCEL:
case GDK_EXPOSE:
case GDK_DELETE:
case GDK_DESTROY:
case GDK_MAP:
case GDK_UNMAP:
case GDK_CONFIGURE:
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
case GDK_GRAB_BROKEN:
case GDK_FOCUS_CHANGE:
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
case GDK_NOTHING:
signal_num = -1;
break;
case GDK_KEY_PRESS:
signal_num = KEY_PRESS_EVENT;
break;
case GDK_KEY_RELEASE:
signal_num = KEY_RELEASE_EVENT;
break;
default:
g_warning ("gtk_widget_event(): unhandled event type: %d", event->any.type);
signal_num = -1;
break;
}
if (signal_num != -1)
{
g_signal_emit (widget, widget_signals[signal_num], 0, event, &handled);
return_val |= handled;
}
}
g_object_unref (widget); g_object_unref (widget);

View File

@ -190,8 +190,6 @@ struct _GtkWidget
* @keynav_failed: Signal emitted if keyboard navigation fails. * @keynav_failed: Signal emitted if keyboard navigation fails.
* @event: The GTK+ main loop will emit this signal for each GDK * @event: The GTK+ main loop will emit this signal for each GDK
* event delivered to a widget. * event delivered to a widget.
* @key_press_event: Signal emitted when a key is pressed.
* @key_release_event: Signal is emitted when a key is released.
* @drag_begin: Signal emitted on the drag source when a drag is * @drag_begin: Signal emitted on the drag source when a drag is
* started. * started.
* @drag_end: Signal emitted on the drag source when a drag is * @drag_end: Signal emitted on the drag source when a drag is
@ -293,10 +291,6 @@ struct _GtkWidgetClass
/* events */ /* events */
gboolean (* event) (GtkWidget *widget, gboolean (* event) (GtkWidget *widget,
GdkEvent *event); GdkEvent *event);
gboolean (* key_press_event) (GtkWidget *widget,
GdkEventKey *event);
gboolean (* key_release_event) (GtkWidget *widget,
GdkEventKey *event);
/* Source side drag signals */ /* Source side drag signals */
void (* drag_begin) (GtkWidget *widget, void (* drag_begin) (GtkWidget *widget,