[vte/vte-0-32] vte: use gtk_drag_check_threshold()
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-0-32] vte: use gtk_drag_check_threshold()
- Date: Fri, 28 Oct 2011 12:59:51 +0000 (UTC)
commit f91e8adbbdee5dccf61fc594c58b954d12bb0356
Author: Dan Winship <danw gnome org>
Date: Fri Jul 15 13:36:45 2011 -0400
vte: use gtk_drag_check_threshold()
When processing motion events, don't start selecting until the pointer
has moved at least the gtk drag threshold distance.
Fixes the problem where, when clicking to select a terminal, you often
end up selecting a bit of text where you clicked, which is especially
annoying when you were planning to middle-button-paste something from
another window.
https://bugzilla.gnome.org/show_bug.cgi?id=654691
src/vte-private.h | 1 +
src/vte.c | 34 ++++++++++++++++++++++++++--------
2 files changed, 27 insertions(+), 8 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index 86d4f8e..930e931 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -246,6 +246,7 @@ struct _VteTerminalPrivate {
GArray *word_chars;
gboolean has_selection;
gboolean selecting;
+ gboolean selecting_after_threshold;
gboolean selecting_restart;
gboolean selecting_had_delta;
gboolean selection_block_mode;
diff --git a/src/vte.c b/src/vte.c
index 037144a..73dc90b 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -6598,7 +6598,7 @@ vte_terminal_invalidate_selection (VteTerminal *terminal)
/* Start selection at the location of the event. */
static void
-vte_terminal_start_selection(VteTerminal *terminal, GdkEventButton *event,
+vte_terminal_start_selection(VteTerminal *terminal, gdouble x, gdouble y,
enum vte_selection_type selection_type)
{
long delta;
@@ -6611,8 +6611,8 @@ vte_terminal_start_selection(VteTerminal *terminal, GdkEventButton *event,
/* Record that we have the selection, and where it started. */
delta = terminal->pvt->screen->scroll_delta;
terminal->pvt->has_selection = TRUE;
- terminal->pvt->selection_last.x = event->x - terminal->pvt->inner_border.left;
- terminal->pvt->selection_last.y = event->y - terminal->pvt->inner_border.top +
+ terminal->pvt->selection_last.x = x - terminal->pvt->inner_border.left;
+ terminal->pvt->selection_last.y = y - terminal->pvt->inner_border.top +
(terminal->char_height * delta);
/* Decide whether or not to restart on the next drag. */
@@ -6637,6 +6637,7 @@ vte_terminal_start_selection(VteTerminal *terminal, GdkEventButton *event,
/* Record the selection type. */
terminal->pvt->selection_type = selection_type;
terminal->pvt->selecting = TRUE;
+ terminal->pvt->selecting_after_threshold = FALSE;
_vte_debug_print(VTE_DEBUG_SELECTION,
"Selection started at (%ld,%ld).\n",
@@ -7287,6 +7288,19 @@ vte_terminal_motion_notify(GtkWidget *widget, GdkEventMotion *event)
switch (event->type) {
case GDK_MOTION_NOTIFY:
+ if (terminal->pvt->selecting_after_threshold) {
+ if (!gtk_drag_check_threshold (widget,
+ terminal->pvt->mouse_last_x,
+ terminal->pvt->mouse_last_y,
+ x, y))
+ return TRUE;
+
+ vte_terminal_start_selection(terminal,
+ terminal->pvt->mouse_last_x,
+ terminal->pvt->mouse_last_y,
+ selection_type_char);
+ }
+
if (terminal->pvt->selecting &&
((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
!terminal->pvt->mouse_tracking_mode))
@@ -7393,9 +7407,7 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
}
if (start_selecting) {
vte_terminal_deselect_all(terminal);
- vte_terminal_start_selection(terminal,
- event,
- selection_type_char);
+ terminal->pvt->selecting_after_threshold = TRUE;
handled = TRUE;
}
if (extend_selecting) {
@@ -7436,10 +7448,15 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
x, y + (terminal->char_height * delta));
switch (event->button) {
case 1:
+ if (terminal->pvt->selecting_after_threshold) {
+ vte_terminal_start_selection(terminal,
+ x, y,
+ selection_type_char);
+ }
if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
!terminal->pvt->mouse_tracking_mode) {
vte_terminal_start_selection(terminal,
- event,
+ x, y,
selection_type_word);
vte_terminal_extend_selection(terminal,
x, y, FALSE, TRUE);
@@ -7461,7 +7478,7 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
!terminal->pvt->mouse_tracking_mode) {
vte_terminal_start_selection(terminal,
- event,
+ x, y,
selection_type_line);
vte_terminal_extend_selection(terminal,
x, y, FALSE, TRUE);
@@ -7541,6 +7558,7 @@ vte_terminal_button_release(GtkWidget *widget, GdkEventButton *event)
terminal->pvt->mouse_last_button = 0;
terminal->pvt->mouse_last_x = x;
terminal->pvt->mouse_last_y = y;
+ terminal->pvt->selecting_after_threshold = FALSE;
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]