[gtk+/xi2] GtkTextView: Use GTK+ device grabs.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/xi2] GtkTextView: Use GTK+ device grabs.
- Date: Tue, 9 Mar 2010 17:54:08 +0000 (UTC)
commit d13ba9aea721a1c60c93655c855b1e9bc261eb3f
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Mar 9 18:28:16 2010 +0100
GtkTextView: Use GTK+ device grabs.
gtk/gtktextview.c | 36 ++++++++++++++++++++++++++++--------
1 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 5028c22..e6b830c 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -109,6 +109,7 @@ struct _GtkTextViewPrivate
guint blink_time; /* time in msec the cursor has blinked since last user event */
guint im_spot_idle;
gchar *im_module;
+ GdkDevice *grab_device;
};
@@ -4078,7 +4079,12 @@ static void
gtk_text_view_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
{
- if (!was_grabbed)
+ GtkTextViewPrivate *priv;
+
+ priv = GTK_TEXT_VIEW_GET_PRIVATE (widget);
+
+ if (priv->grab_device &&
+ gtk_widget_device_is_shadowed (widget, priv->grab_device))
{
gtk_text_view_end_selection_drag (GTK_TEXT_VIEW (widget));
gtk_text_view_unobscure_mouse_cursor (GTK_TEXT_VIEW (widget));
@@ -6177,7 +6183,6 @@ typedef struct
SelectionGranularity granularity;
GtkTextMark *orig_start;
GtkTextMark *orig_end;
- GdkDevice *device;
} SelectionData;
static void
@@ -6197,9 +6202,12 @@ selection_motion_event_handler (GtkTextView *text_view,
GdkEventMotion *event,
SelectionData *data)
{
+ GtkTextViewPrivate *priv;
+
+ priv = GTK_TEXT_VIEW_GET_PRIVATE (text_view);
gdk_event_request_motions (event);
- if (data->device != event->device)
+ if (priv->grab_device != event->device)
return FALSE;
if (data->granularity == SELECT_CHARACTERS)
@@ -6251,6 +6259,7 @@ gtk_text_view_start_selection_drag (GtkTextView *text_view,
const GtkTextIter *iter,
GdkEventButton *button)
{
+ GtkTextViewPrivate *priv;
GtkTextIter cursor, ins, bound;
GtkTextIter orig_start, orig_end;
GtkTextBuffer *buffer;
@@ -6258,7 +6267,8 @@ gtk_text_view_start_selection_drag (GtkTextView *text_view,
if (text_view->selection_drag_handler != 0)
return;
-
+
+ priv = GTK_TEXT_VIEW_GET_PRIVATE (text_view);
data = g_new0 (SelectionData, 1);
if (button->type == GDK_2BUTTON_PRESS)
@@ -6268,7 +6278,10 @@ gtk_text_view_start_selection_drag (GtkTextView *text_view,
else
data->granularity = SELECT_CHARACTERS;
- gtk_grab_add (GTK_WIDGET (text_view));
+ priv->grab_device = button->device;
+ gtk_device_grab_add (GTK_WIDGET (text_view),
+ priv->grab_device,
+ TRUE);
buffer = get_buffer (text_view);
@@ -6318,8 +6331,6 @@ gtk_text_view_start_selection_drag (GtkTextView *text_view,
&orig_start, TRUE);
data->orig_end = gtk_text_buffer_create_mark (buffer, NULL,
&orig_end, TRUE);
- data->device = button->device;
-
gtk_text_view_check_cursor_blink (text_view);
text_view->selection_drag_handler = g_signal_connect_data (text_view,
@@ -6333,6 +6344,13 @@ gtk_text_view_start_selection_drag (GtkTextView *text_view,
static gboolean
gtk_text_view_end_selection_drag (GtkTextView *text_view)
{
+ GtkTextViewPrivate *priv;
+
+ priv = GTK_TEXT_VIEW_GET_PRIVATE (text_view);
+
+ if (!priv->grab_device)
+ return FALSE;
+
if (text_view->selection_drag_handler == 0)
return FALSE;
@@ -6345,7 +6363,9 @@ gtk_text_view_end_selection_drag (GtkTextView *text_view)
text_view->scroll_timeout = 0;
}
- gtk_grab_remove (GTK_WIDGET (text_view));
+ gtk_device_grab_remove (GTK_WIDGET (text_view),
+ priv->grab_device);
+ priv->grab_device = NULL;
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]