[gtk+/gtk-3-16] entry: Improve cursor hiding logic
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-16] entry: Improve cursor hiding logic
- Date: Fri, 18 Sep 2015 01:11:57 +0000 (UTC)
commit bf7fc2fc59c7cb84660997454fd5f71a2bc223d3
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Sep 3 13:16:02 2015 -0400
entry: Improve cursor hiding logic
Previously, we just hid the cursor if a key event was adding text,
but not when you used backspace, or Ctrl-V. Rearrange things so that
we obscure the cursor whenever the buffer contents change while we
are handling key events.
https://bugzilla.gnome.org/show_bug.cgi?id=754535
gtk/gtkentry.c | 35 +++++++++++++++++++++++++++--------
1 files changed, 27 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 6668da6..9074b61 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -230,6 +230,7 @@ struct _GtkEntryPrivate
guint cursor_handle_dragged : 1;
guint selection_handle_dragged : 1;
guint populate_all : 1;
+ guint handling_key_event : 1;
};
struct _EntryIconInfo
@@ -4838,6 +4839,9 @@ gtk_entry_key_press (GtkWidget *widget,
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
+ gboolean retval = FALSE;
+
+ priv->handling_key_event = TRUE;
gtk_entry_reset_blink_time (entry);
gtk_entry_pend_cursor_blink (entry);
@@ -4852,9 +4856,9 @@ gtk_entry_key_press (GtkWidget *widget,
{
if (gtk_im_context_filter_keypress (priv->im_context, event))
{
- gtk_entry_obscure_mouse_cursor (entry);
priv->need_im_reset = TRUE;
- return TRUE;
+ retval = TRUE;
+ goto out;
}
}
@@ -4865,14 +4869,19 @@ gtk_entry_key_press (GtkWidget *widget,
gtk_entry_reset_im_context (entry);
if (GTK_WIDGET_CLASS (gtk_entry_parent_class)->key_press_event (widget, event))
- /* Activate key bindings
- */
- return TRUE;
+ {
+ /* Activate key bindings */
+ retval = TRUE;
+ goto out;
+ }
if (!priv->editable && event->length)
gtk_widget_error_bell (widget);
- return FALSE;
+out:
+ priv->handling_key_event = FALSE;
+
+ return retval;
}
static gint
@@ -4881,17 +4890,25 @@ gtk_entry_key_release (GtkWidget *widget,
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
+ gboolean retval = FALSE;
+
+ priv->handling_key_event = TRUE;
if (priv->editable)
{
if (gtk_im_context_filter_keypress (priv->im_context, event))
{
priv->need_im_reset = TRUE;
- return TRUE;
+ retval = TRUE;
+ goto out;
}
}
- return GTK_WIDGET_CLASS (gtk_entry_parent_class)->key_release_event (widget, event);
+ retval = GTK_WIDGET_CLASS (gtk_entry_parent_class)->key_release_event (widget, event);
+
+out:
+ priv->handling_key_event = FALSE;
+ return retval;
}
static gint
@@ -5469,6 +5486,8 @@ buffer_notify_text (GtkEntryBuffer *buffer,
GParamSpec *spec,
GtkEntry *entry)
{
+ if (entry->priv->handling_key_event)
+ gtk_entry_obscure_mouse_cursor (entry);
gtk_entry_recompute (entry);
emit_changed (entry);
g_object_notify (G_OBJECT (entry), "text");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]