[gtk+/multitouch: 38/48] entry: Handle ::grab-notify
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/multitouch: 38/48] entry: Handle ::grab-notify
- Date: Wed, 2 Nov 2011 13:24:34 +0000 (UTC)
commit f7ee2ead3c34a9ac00d3256c4fd365e23dd25513
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Nov 1 02:54:03 2011 +0100
entry: Handle ::grab-notify
Store the device, and unset private fields whenever the device
is shadowed by another GTK+ grab, so popping up menus while
selecting (i.e. press-and-hold) doesn't leave it in a confused
state.
gtk/gtkentry.c | 38 ++++++++++++++++++++++++++++++++++----
1 files changed, 34 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 1806464..af39fea 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -146,6 +146,8 @@ struct _GtkEntryPrivate
GtkShadowType shadow_type;
GtkWidget *popup_menu;
+ GdkDevice *device;
+
GdkDevice *completion_device;
GdkWindow *text_area;
@@ -553,6 +555,8 @@ static void gtk_entry_do_popup (GtkEntry *entry,
GdkEventButton *event);
static gboolean gtk_entry_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
+static void gtk_entry_grab_notify (GtkWidget *widget,
+ gboolean was_grabbed);
static void gtk_entry_check_cursor_blink (GtkEntry *entry);
static void gtk_entry_pend_cursor_blink (GtkEntry *entry);
static void gtk_entry_reset_blink_time (GtkEntry *entry);
@@ -697,6 +701,7 @@ gtk_entry_class_init (GtkEntryClass *class)
widget_class->state_flags_changed = gtk_entry_state_flags_changed;
widget_class->screen_changed = gtk_entry_screen_changed;
widget_class->mnemonic_activate = gtk_entry_mnemonic_activate;
+ widget_class->grab_notify = gtk_entry_grab_notify;
widget_class->drag_drop = gtk_entry_drag_drop;
widget_class->drag_motion = gtk_entry_drag_motion;
@@ -3727,6 +3732,7 @@ gtk_entry_button_press (GtkWidget *widget,
GtkEditable *editable = GTK_EDITABLE (widget);
GtkEntryPrivate *priv = entry->priv;
EntryIconInfo *icon_info = NULL;
+ GdkDevice *device;
gint tmp_pos;
gint sel_start, sel_end;
gint i;
@@ -3764,7 +3770,8 @@ gtk_entry_button_press (GtkWidget *widget,
gtk_entry_reset_blink_time (entry);
priv->button = event->button;
-
+ priv->device = gdk_event_get_device ((GdkEvent *) event);
+
if (!gtk_widget_has_focus (widget))
{
priv->in_click = TRUE;
@@ -3778,6 +3785,7 @@ gtk_entry_button_press (GtkWidget *widget,
{
gtk_entry_do_popup (entry, event);
priv->button = 0; /* Don't wait for release, since the menu will gtk_grab_add */
+ priv->device = NULL;
return TRUE;
}
@@ -3955,9 +3963,10 @@ gtk_entry_button_release (GtkWidget *widget,
priv->in_drag = 0;
}
-
+
priv->button = 0;
-
+ priv->device = NULL;
+
gtk_entry_update_primary_selection (entry);
return TRUE;
@@ -4066,7 +4075,8 @@ gtk_entry_motion_notify (GtkWidget *widget,
priv->in_drag = FALSE;
priv->button = 0;
-
+ priv->device = NULL;
+
gtk_target_list_unref (target_list);
}
}
@@ -8789,6 +8799,26 @@ gtk_entry_mnemonic_activate (GtkWidget *widget,
}
static void
+gtk_entry_grab_notify (GtkWidget *widget,
+ gboolean was_grabbed)
+{
+ GtkEntryPrivate *priv;
+
+ priv = GTK_ENTRY (widget)->priv;
+
+ if (priv->device &&
+ gtk_widget_device_is_shadowed (widget, priv->device))
+ {
+ /* Unset button so we don't expect
+ * a button release anymore
+ */
+ priv->button = 0;
+ priv->device = NULL;
+ priv->in_drag = FALSE;
+ }
+}
+
+static void
append_action_signal (GtkEntry *entry,
GtkWidget *menu,
const gchar *stock_id,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]