[vte/vte-0-34] Revert "Revert "Add urxvt extended mouse tracking mode support""
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-0-34] Revert "Revert "Add urxvt extended mouse tracking mode support""
- Date: Tue, 21 Aug 2012 17:54:41 +0000 (UTC)
commit f89b42ef37fc20944e3c17d41581c6fe3c004e6e
Author: Christian Persch <chpe gnome org>
Date: Tue Aug 21 19:54:17 2012 +0200
Revert "Revert "Add urxvt extended mouse tracking mode support""
This reverts commit 580bc054a083c020ab658183864ab44ba8589c85.
src/vte-private.h | 1 +
src/vte.c | 58 +++++++++++++++++++++++++++++++++-------------------
src/vteseq.c | 5 ++++
3 files changed, 43 insertions(+), 21 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index 2e1f9cc..d2cc6a3 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -305,6 +305,7 @@ struct _VteTerminalPrivate {
long mouse_last_x, mouse_last_y;
gboolean mouse_autohide;
guint mouse_autoscroll_tag;
+ gboolean mouse_urxvt_extension;
/* State variables for handling match checks. */
char *match_contents;
diff --git a/src/vte.c b/src/vte.c
index 35fa597..3801f74 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -5838,10 +5838,11 @@ vte_terminal_get_mouse_tracking_info (VteTerminal *terminal,
long col,
long row,
unsigned char *pb,
- unsigned char *px,
- unsigned char *py)
+ long *px,
+ long *py)
{
- unsigned char cb = 0, cx = 0, cy = 0;
+ unsigned char cb = 0;
+ long cx, cy;
/* Encode the button information in cb. */
switch (button) {
@@ -5877,11 +5878,11 @@ vte_terminal_get_mouse_tracking_info (VteTerminal *terminal,
cb |= 16;
}
- /* Encode the cursor coordinates. */
- cx = 32 + CLAMP(1 + col,
- 1, terminal->column_count);
- cy = 32 + CLAMP(1 + row,
- 1, terminal->row_count);;
+ /* Clamp the cursor coordinates. */
+ cx = CLAMP(1 + col,
+ 1, terminal->column_count);
+ cy = CLAMP(1 + row,
+ 1, terminal->row_count);
*pb = cb;
*px = cx;
@@ -5889,14 +5890,34 @@ vte_terminal_get_mouse_tracking_info (VteTerminal *terminal,
}
static void
+vte_terminal_feed_mouse_event(VteTerminal *terminal,
+ int cb,
+ long cx,
+ long cy)
+{
+ char buf[LINE_MAX];
+ gint len = 0;
+
+ if (terminal->pvt->mouse_urxvt_extension) {
+ /* urxvt's extended mode (1015) */
+ len = g_snprintf(buf, sizeof(buf), _VTE_CAP_CSI "%d;%ld;%ldM", cb, cx, cy);
+ } else if (cx <= 231 && cy <= 231) {
+ /* legacy mode */
+ len = g_snprintf(buf, sizeof(buf), _VTE_CAP_CSI "M%c%c%c", cb, 32 + (guchar)cx, 32 + (guchar)cy);
+ }
+
+ /* Send event direct to the child, this is binary not text data */
+ vte_terminal_feed_child_binary(terminal, buf, len);
+}
+
+static void
vte_terminal_send_mouse_button_internal(VteTerminal *terminal,
int button,
long x,
long y)
{
- unsigned char cb, cx, cy;
- char buf[LINE_MAX];
- gint len;
+ unsigned char cb;
+ long cx, cy;
int width = terminal->char_width;
int height = terminal->char_height;
long col = (x - terminal->pvt->inner_border.left) / width;
@@ -5905,10 +5926,7 @@ vte_terminal_send_mouse_button_internal(VteTerminal *terminal,
vte_terminal_get_mouse_tracking_info (terminal,
button, col, row,
&cb, &cx, &cy);
-
- /* Send event direct to the child, this is binary not text data */
- len = g_snprintf(buf, sizeof(buf), _VTE_CAP_CSI "M%c%c%c", cb, cx, cy);
- vte_terminal_feed_child_binary(terminal, buf, len);
+ vte_terminal_feed_mouse_event(terminal, cb, cx, cy);
}
/* Send a mouse button click/release notification. */
@@ -5944,9 +5962,8 @@ vte_terminal_maybe_send_mouse_button(VteTerminal *terminal,
static void
vte_terminal_maybe_send_mouse_drag(VteTerminal *terminal, GdkEventMotion *event)
{
- unsigned char cb, cx, cy;
- char buf[LINE_MAX];
- gint len;
+ unsigned char cb;
+ long cx, cy;
int width = terminal->char_width;
int height = terminal->char_height;
long col = ((long) event->x - terminal->pvt->inner_border.left) / width;
@@ -5980,9 +5997,7 @@ vte_terminal_maybe_send_mouse_drag(VteTerminal *terminal, GdkEventMotion *event)
&cb, &cx, &cy);
cb += 32; /* for movement */
- /* Send event direct to the child, this is binary not text data */
- len = g_snprintf(buf, sizeof(buf), _VTE_CAP_CSI "M%c%c%c", cb, cx, cy);
- vte_terminal_feed_child_binary(terminal, buf, len);
+ vte_terminal_feed_mouse_event(terminal, cb, cx, cy);
}
/* Clear all match hilites. */
@@ -14194,6 +14209,7 @@ vte_terminal_reset(VteTerminal *terminal,
pvt->mouse_last_button = 0;
pvt->mouse_last_x = 0;
pvt->mouse_last_y = 0;
+ pvt->mouse_urxvt_extension = FALSE;
/* Clear modifiers. */
pvt->modifiers = 0;
/* Cause everything to be redrawn (or cleared). */
diff --git a/src/vteseq.c b/src/vteseq.c
index 07b1524..23745a1 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -689,6 +689,11 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal,
{1010, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
/* 1011/rxvt: disallowed, scroll-on-keypress is set by user. */
{1011, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
+ /* 1015/urxvt: Extended mouse coordinates. */
+ {1015, &terminal->pvt->mouse_urxvt_extension, NULL, NULL,
+ GINT_TO_POINTER(FALSE),
+ GINT_TO_POINTER(TRUE),
+ NULL, NULL,},
/* 1035: disallowed, don't know what to do with it. */
{1035, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
/* 1036: Meta-sends-escape. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]