[vte/vte-0-32] Add urxvt extended mouse tracking mode support
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-0-32] Add urxvt extended mouse tracking mode support
- Date: Wed, 9 Nov 2011 21:57:09 +0000 (UTC)
commit 60e0ce9ff6b27787c47c266e779d80e3389babe9
Author: Egmont Koblinger <egmont gmail com>
Date: Wed Nov 9 22:47:37 2011 +0100
Add urxvt extended mouse tracking mode support
https://bugzilla.gnome.org/show_bug.cgi?id=662423
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 930e931..fae0c56 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -306,6 +306,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 163256a..fa30e6c 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -5820,10 +5820,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) {
@@ -5859,11 +5860,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;
@@ -5871,14 +5872,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;
@@ -5887,10 +5908,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. */
@@ -5926,9 +5944,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;
@@ -5962,9 +5979,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. */
@@ -14123,6 +14138,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 7ef4c8c..d850929 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]