vte r2305 - in trunk: . src
- From: behdad svn gnome org
- To: svn-commits-list gnome org
- Subject: vte r2305 - in trunk: . src
- Date: Tue, 2 Dec 2008 15:40:12 +0000 (UTC)
Author: behdad
Date: Tue Dec 2 15:40:12 2008
New Revision: 2305
URL: http://svn.gnome.org/viewvc/vte?rev=2305&view=rev
Log:
2008-12-02 Behdad Esfahbod <behdad gnome org>
* src/vte-private.h:
* src/vte.c (_vte_terminal_set_pointer_visible),
(vte_terminal_get_mouse_tracking_info),
(vte_terminal_send_mouse_button_internal),
(vte_terminal_maybe_send_mouse_button),
(vte_terminal_maybe_send_mouse_drag), (vte_terminal_motion_notify),
(vte_terminal_button_press), (vte_terminal_button_release),
(vte_terminal_scroll), (vte_terminal_reset):
* src/vteseq.c (vte_sequence_handler_decset_internal):
Mouse tracking cleanup.
Modified:
trunk/ChangeLog
trunk/src/vte-private.h
trunk/src/vte.c
trunk/src/vteseq.c
Modified: trunk/src/vte-private.h
==============================================================================
--- trunk/src/vte-private.h (original)
+++ trunk/src/vte-private.h Tue Dec 2 15:40:12 2008
@@ -140,6 +140,16 @@
VTE_REGEX_CURSOR_NAME
} VteRegexCursorMode;
+/* The order is important */
+typedef enum {
+ MOUSE_TRACKING_NONE,
+ MOUSE_TRACKING_SEND_XY_ON_CLICK,
+ MOUSE_TRACKING_SEND_XY_ON_BUTTON,
+ MOUSE_TRACKING_HILITE_TRACKING,
+ MOUSE_TRACKING_CELL_MOTION_TRACKING,
+ MOUSE_TRACKING_ALL_MOTION_TRACKING
+} MouseTrackingMode;
+
/* A match regex, with a tag. */
struct vte_match_regex {
gint tag;
@@ -335,12 +345,8 @@
/* Input device options. */
time_t last_keypress_time;
-#define MOUSE_EVENT_SEND_XY_ON_CLICK 0x0001
-#define MOUSE_EVENT_SEND_XY_ON_BUTTON 0x0002
-#define MOUSE_EVENT_HILITE_TRACKING 0x0004
-#define MOUSE_EVENT_CELL_MOTION_TRACKING 0x0008
-#define MOUSE_EVENT_ALL_MOTION_TRACKING 0x0010
- gint mouse_event_mode;
+ int mouse_tracking_mode; /* this is of type MouseTrackingMode,
+ but we need to guarantee its type. */
guint mouse_last_button;
long mouse_last_x, mouse_last_y;
gboolean mouse_autohide;
Modified: trunk/src/vte.c
==============================================================================
--- trunk/src/vte.c (original)
+++ trunk/src/vte.c Tue Dec 2 15:40:12 2008
@@ -2486,7 +2486,7 @@
return;
if (visible || !terminal->pvt->mouse_autohide) {
- if (terminal->pvt->mouse_event_mode) {
+ if (terminal->pvt->mouse_tracking_mode) {
_vte_debug_print(VTE_DEBUG_CURSOR,
"Setting mousing cursor.\n");
gdk_window_set_cursor(terminal->widget.window, terminal->pvt->mouse_mousing_cursor);
@@ -5340,15 +5340,16 @@
}
}
-/* Send a button down or up notification. */
static void
-vte_terminal_send_mouse_button_internal(VteTerminal *terminal,
- int button,
- long x, long y)
+vte_terminal_get_mouse_tracking_info (VteTerminal *terminal,
+ int button,
+ long col,
+ long row,
+ unsigned char *pb,
+ unsigned char *px,
+ unsigned char *py)
{
unsigned char cb = 0, cx = 0, cy = 0;
- char buf[LINE_MAX];
- gint len;
/* Encode the button information in cb. */
switch (button) {
@@ -5365,10 +5366,10 @@
cb = 2;
break;
case 4:
- cb = 64; /* Scroll up. FIXME: check */
+ cb = 64; /* Scroll up. */
break;
case 5:
- cb = 65; /* Scroll down. FIXME: check */
+ cb = 65; /* Scroll down. */
break;
}
cb += 32; /* 32 for normal */
@@ -5385,11 +5386,34 @@
}
/* Encode the cursor coordinates. */
- cx = 32 + CLAMP(1 + (x / terminal->char_width),
+ cx = 32 + CLAMP(1 + col,
1, terminal->column_count);
- cy = 32 + CLAMP(1 + (y / terminal->char_height),
+ cy = 32 + CLAMP(1 + row,
1, terminal->row_count);;
+ *pb = cb;
+ *px = cx;
+ *py = cy;
+}
+
+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;
+ int width = terminal->char_width;
+ int height = terminal->char_height;
+ long col = (x - VTE_PAD_WIDTH) / width;
+ long row = (y - VTE_PAD_WIDTH) / height;
+
+ 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);
@@ -5410,12 +5434,12 @@
/* Decide whether or not to do anything. */
switch (event->type) {
case GDK_BUTTON_PRESS:
- if (!terminal->pvt->mouse_event_mode) {
+ if (terminal->pvt->mouse_tracking_mode < MOUSE_TRACKING_SEND_XY_ON_CLICK) {
return;
}
break;
case GDK_BUTTON_RELEASE: {
- if (!(terminal->pvt->mouse_event_mode&~MOUSE_EVENT_SEND_XY_ON_CLICK)) {
+ if (terminal->pvt->mouse_tracking_mode < MOUSE_TRACKING_SEND_XY_ON_BUTTON) {
return;
}
break;
@@ -5425,43 +5449,39 @@
break;
}
- /* Encode the parameters and send them to the app. */
vte_terminal_send_mouse_button_internal(terminal,
- (event->type == GDK_BUTTON_PRESS) ?
- event->button : 0,
- event->x - VTE_PAD_WIDTH,
- event->y - VTE_PAD_WIDTH);
+ (event->type == GDK_BUTTON_PRESS) ? event->button : 0,
+ event->x, event->y);
}
/* Send a mouse motion notification. */
static void
vte_terminal_maybe_send_mouse_drag(VteTerminal *terminal, GdkEventMotion *event)
{
- unsigned char cb = 0, cx = 0, cy = 0;
+ unsigned char cb, cx, cy;
char buf[LINE_MAX];
gint len;
- long x, y;
-
- x = event->x - VTE_PAD_WIDTH;
- y = event->y - VTE_PAD_WIDTH;
+ int width = terminal->char_width;
+ int height = terminal->char_height;
+ long col = ((long) event->x - VTE_PAD_WIDTH) / width;
+ long row = ((long) event->y - VTE_PAD_WIDTH) / height;
/* First determine if we even want to send notification. */
switch (event->type) {
case GDK_MOTION_NOTIFY:
- if (!(terminal->pvt->mouse_event_mode &
- (MOUSE_EVENT_CELL_MOTION_TRACKING|MOUSE_EVENT_ALL_MOTION_TRACKING))) {
+ if (terminal->pvt->mouse_tracking_mode < MOUSE_TRACKING_CELL_MOTION_TRACKING)
return;
- }
- if (!(terminal->pvt->mouse_event_mode & MOUSE_EVENT_ALL_MOTION_TRACKING)) {
- int width = terminal->char_width;
- int height = terminal->char_height;
+
+ if (terminal->pvt->mouse_tracking_mode < MOUSE_TRACKING_ALL_MOTION_TRACKING) {
+
if (terminal->pvt->mouse_last_button == 0) {
return;
}
- if (x / width == terminal->pvt->mouse_last_x / width &&
- y / height == terminal->pvt->mouse_last_y / height) {
+ /* the xterm doc is not clear as to whether
+ * all-tracking also sends degenerate same-cell events */
+ if (col == terminal->pvt->mouse_last_x / width &&
+ row == terminal->pvt->mouse_last_y / height)
return;
- }
}
break;
default:
@@ -5469,45 +5489,10 @@
break;
}
- /* Encode which button we're being dragged with. */
- switch (terminal->pvt->mouse_last_button) {
- case 0:
- cb = 3;
- break;
- case 1:
- cb = 0;
- break;
- case 2:
- cb = 1;
- break;
- case 3:
- cb = 2;
- break;
- case 4:
- cb = 64; /* FIXME: check */
- break;
- case 5:
- cb = 65; /* FIXME: check */
- break;
- }
- cb += 64; /* 32 for normal, 32 for movement */
-
- /* Encode the modifiers. */
- if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
- cb |= 4;
- }
- if (terminal->pvt->modifiers & VTE_META_MASK) {
- cb |= 8;
- }
- if (terminal->pvt->modifiers & GDK_CONTROL_MASK) {
- cb |= 16;
- }
-
- /* Encode the cursor coordinates. */
- cx = 32 + CLAMP(1 + (x / terminal->char_width),
- 1, terminal->column_count);
- cy = 32 + CLAMP(1 + (y / terminal->char_height),
- 1, terminal->row_count);;
+ vte_terminal_get_mouse_tracking_info (terminal,
+ terminal->pvt->mouse_last_button, col, row,
+ &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);
@@ -6871,7 +6856,7 @@
}
if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
- !terminal->pvt->mouse_event_mode) {
+ !terminal->pvt->mouse_tracking_mode) {
vte_terminal_extend_selection(terminal,
x, y, FALSE, FALSE);
} else {
@@ -6893,7 +6878,7 @@
event->y >= terminal->row_count * height + VTE_PAD_WIDTH) {
switch (terminal->pvt->mouse_last_button) {
case 1:
- if (!terminal->pvt->mouse_event_mode) {
+ if (!terminal->pvt->mouse_tracking_mode) {
/* Give mouse wigglers something. */
vte_terminal_autoscroll(terminal);
/* Start a timed autoscroll if we're not doing it
@@ -6967,7 +6952,7 @@
/* If we're in event mode, and the user held down the
* shift key, we start selecting. */
- if (terminal->pvt->mouse_event_mode) {
+ if (terminal->pvt->mouse_tracking_mode) {
if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
start_selecting = TRUE;
}
@@ -7012,7 +6997,7 @@
* to the app. */
case 2:
if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
- !terminal->pvt->mouse_event_mode) {
+ !terminal->pvt->mouse_tracking_mode) {
vte_terminal_paste_primary(terminal);
handled = TRUE;
}
@@ -7036,7 +7021,7 @@
switch (event->button) {
case 1:
if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
- !terminal->pvt->mouse_event_mode) {
+ !terminal->pvt->mouse_tracking_mode) {
vte_terminal_start_selection(terminal,
event,
selection_type_word);
@@ -7058,7 +7043,7 @@
switch (event->button) {
case 1:
if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
- !terminal->pvt->mouse_event_mode) {
+ !terminal->pvt->mouse_tracking_mode) {
vte_terminal_start_selection(terminal,
event,
selection_type_line);
@@ -7119,7 +7104,7 @@
case 1:
/* If Shift is held down, or we're not in events mode,
* copy the selected text. */
- if (terminal->pvt->selecting || !terminal->pvt->mouse_event_mode) {
+ if (terminal->pvt->selecting || !terminal->pvt->mouse_tracking_mode) {
/* Copy only if something was selected. */
if (terminal->pvt->has_selection &&
!terminal->pvt->selecting_restart &&
@@ -7134,7 +7119,7 @@
break;
case 2:
if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
- !terminal->pvt->mouse_event_mode) {
+ !terminal->pvt->mouse_tracking_mode) {
handled = TRUE;
}
break;
@@ -10894,7 +10879,7 @@
/* If we're running a mouse-aware application, map the scroll event
* to a button press on buttons four and five. */
- if (terminal->pvt->mouse_event_mode) {
+ if (terminal->pvt->mouse_tracking_mode) {
switch (event->direction) {
case GDK_SCROLL_UP:
button = 4;
@@ -10910,8 +10895,8 @@
/* Encode the parameters and send them to the app. */
vte_terminal_send_mouse_button_internal(terminal,
button,
- event->x - VTE_PAD_WIDTH,
- event->y - VTE_PAD_WIDTH);
+ event->x,
+ event->y);
}
return TRUE;
}
@@ -13270,7 +13255,7 @@
sizeof(&terminal->pvt->selection_end));
}
/* Reset mouse motion events. */
- terminal->pvt->mouse_event_mode = 0;
+ terminal->pvt->mouse_tracking_mode = MOUSE_TRACKING_NONE;
terminal->pvt->mouse_last_button = 0;
terminal->pvt->mouse_last_x = 0;
terminal->pvt->mouse_last_y = 0;
Modified: trunk/src/vteseq.c
==============================================================================
--- trunk/src/vteseq.c (original)
+++ trunk/src/vteseq.c Tue Dec 2 15:40:12 2008
@@ -667,9 +667,9 @@
/* 8: disallowed, keyboard repeat is set by user. */
{8, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
/* 9: Send-coords-on-click. */
- {9, NULL, &terminal->pvt->mouse_event_mode, NULL,
+ {9, NULL, &terminal->pvt->mouse_tracking_mode, NULL,
GINT_TO_POINTER(0),
- GINT_TO_POINTER(MOUSE_EVENT_SEND_XY_ON_CLICK),
+ GINT_TO_POINTER(MOUSE_TRACKING_SEND_XY_ON_CLICK),
NULL, NULL,},
/* 12: disallowed, cursor blinks is set by user. */
{12, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
@@ -711,24 +711,24 @@
/* 67: disallowed, backspace key policy is set by user. */
{67, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
/* 1000: Send-coords-on-button. */
- {1000, NULL, &terminal->pvt->mouse_event_mode, NULL,
+ {1000, NULL, &terminal->pvt->mouse_tracking_mode, NULL,
GINT_TO_POINTER(0),
- GINT_TO_POINTER(MOUSE_EVENT_SEND_XY_ON_BUTTON),
+ GINT_TO_POINTER(MOUSE_TRACKING_SEND_XY_ON_BUTTON),
NULL, NULL,},
/* 1001: Hilite tracking. */
- {1001, NULL, &terminal->pvt->mouse_event_mode, NULL,
+ {1001, NULL, &terminal->pvt->mouse_tracking_mode, NULL,
GINT_TO_POINTER(0),
- GINT_TO_POINTER(MOUSE_EVENT_HILITE_TRACKING),
+ GINT_TO_POINTER(MOUSE_TRACKING_HILITE_TRACKING),
NULL, NULL,},
/* 1002: Cell motion tracking. */
- {1002, NULL, &terminal->pvt->mouse_event_mode, NULL,
+ {1002, NULL, &terminal->pvt->mouse_tracking_mode, NULL,
GINT_TO_POINTER(0),
- GINT_TO_POINTER(MOUSE_EVENT_CELL_MOTION_TRACKING),
+ GINT_TO_POINTER(MOUSE_TRACKING_CELL_MOTION_TRACKING),
NULL, NULL,},
/* 1003: All motion tracking. */
- {1003, NULL, &terminal->pvt->mouse_event_mode, NULL,
+ {1003, NULL, &terminal->pvt->mouse_tracking_mode, NULL,
GINT_TO_POINTER(0),
- GINT_TO_POINTER(MOUSE_EVENT_ALL_MOTION_TRACKING),
+ GINT_TO_POINTER(MOUSE_TRACKING_ALL_MOTION_TRACKING),
NULL, NULL,},
/* 1010/rxvt: disallowed, scroll-on-output is set by user. */
{1010, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]