vte r2284 - in trunk: . src



Author: behdad
Date: Tue Dec  2 10:10:46 2008
New Revision: 2284
URL: http://svn.gnome.org/viewvc/vte?rev=2284&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_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):
        Simplify mouse event tracking by using a single int instead of five 
        booleans.



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 10:10:46 2008
@@ -329,11 +329,13 @@
 
 	/* Input device options. */
 	time_t last_keypress_time;
-	gboolean mouse_send_xy_on_click;
-	gboolean mouse_send_xy_on_button;
-	gboolean mouse_hilite_tracking;
-	gboolean mouse_cell_motion_tracking;
-	gboolean mouse_all_motion_tracking;
+
+#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;
 	guint mouse_last_button;
 	gdouble 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 10:10:46 2008
@@ -2486,11 +2486,7 @@
                 return;
 
 	if (visible || !terminal->pvt->mouse_autohide) {
-		if (terminal->pvt->mouse_send_xy_on_click ||
-		    terminal->pvt->mouse_send_xy_on_button ||
-		    terminal->pvt->mouse_hilite_tracking ||
-		    terminal->pvt->mouse_cell_motion_tracking ||
-		    terminal->pvt->mouse_all_motion_tracking) {
+		if (terminal->pvt->mouse_event_mode) {
 			_vte_debug_print(VTE_DEBUG_CURSOR,
 					"Setting mousing cursor.\n");
 			gdk_window_set_cursor(terminal->widget.window, terminal->pvt->mouse_mousing_cursor);
@@ -5414,22 +5410,16 @@
 	/* Decide whether or not to do anything. */
 	switch (event->type) {
 	case GDK_BUTTON_PRESS:
-		if (!terminal->pvt->mouse_send_xy_on_button &&
-		    !terminal->pvt->mouse_send_xy_on_click &&
-		    !terminal->pvt->mouse_hilite_tracking &&
-		    !terminal->pvt->mouse_cell_motion_tracking &&
-		    !terminal->pvt->mouse_all_motion_tracking) {
+		if (!terminal->pvt->mouse_event_mode) {
 			return;
 		}
 		break;
-	case GDK_BUTTON_RELEASE:
-		if (!terminal->pvt->mouse_send_xy_on_button &&
-		    !terminal->pvt->mouse_hilite_tracking &&
-		    !terminal->pvt->mouse_cell_motion_tracking &&
-		    !terminal->pvt->mouse_all_motion_tracking) {
+	case GDK_BUTTON_RELEASE: {
+		if (!(terminal->pvt->mouse_event_mode&~MOUSE_EVENT_SEND_XY_ON_CLICK)) {
 			return;
 		}
 		break;
+	}
 	default:
 		return;
 		break;
@@ -5454,11 +5444,11 @@
 	/* First determine if we even want to send notification. */
 	switch (event->type) {
 	case GDK_MOTION_NOTIFY:
-		if (!terminal->pvt->mouse_cell_motion_tracking &&
-		    !terminal->pvt->mouse_all_motion_tracking) {
+		if (!(terminal->pvt->mouse_event_mode &
+		      (MOUSE_EVENT_CELL_MOTION_TRACKING|MOUSE_EVENT_ALL_MOTION_TRACKING))) {
 			return;
 		}
-		if (!terminal->pvt->mouse_all_motion_tracking) {
+		if (!(terminal->pvt->mouse_event_mode & MOUSE_EVENT_ALL_MOTION_TRACKING)) {
 			if (terminal->pvt->mouse_last_button == 0) {
 				return;
 			}
@@ -6794,7 +6784,6 @@
 {
 	VteTerminal *terminal;
 	GdkModifierType modifiers;
-	gboolean event_mode;
 	int width, height;
 	gdouble x, y;
 
@@ -6817,12 +6806,6 @@
 	}
 
 
-	event_mode = terminal->pvt->mouse_send_xy_on_click ||
-		     terminal->pvt->mouse_send_xy_on_button ||
-		     terminal->pvt->mouse_hilite_tracking ||
-		     terminal->pvt->mouse_cell_motion_tracking ||
-		     terminal->pvt->mouse_all_motion_tracking;
-
 	_vte_debug_print(VTE_DEBUG_EVENTS,
 			"Motion notify (%lf,%lf) [%.0f, %.0f].\n",
 			event->x, event->y,
@@ -6866,7 +6849,7 @@
 			}
 
 			if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
-			    !event_mode) {
+			    !terminal->pvt->mouse_event_mode) {
 				vte_terminal_extend_selection(terminal,
 							      x, y, FALSE, FALSE);
 			} else {
@@ -6889,7 +6872,7 @@
 	    event->y >= terminal->row_count * height + VTE_PAD_WIDTH) {
 		switch (terminal->pvt->mouse_last_button) {
 		case 1:
-			if (!event_mode) {
+			if (!terminal->pvt->mouse_event_mode) {
 				/* Give mouse wigglers something. */
 				vte_terminal_autoscroll(terminal);
 				/* Start a timed autoscroll if we're not doing it
@@ -6918,7 +6901,7 @@
 	VteTerminal *terminal;
 	long height, width, delta;
 	GdkModifierType modifiers;
-	gboolean handled = FALSE, event_mode;
+	gboolean handled = FALSE;
 	gboolean start_selecting = FALSE, extend_selecting = FALSE;
 	long cellx, celly;
 	gdouble x,y;
@@ -6935,12 +6918,6 @@
 
 	_vte_terminal_set_pointer_visible(terminal, TRUE);
 
-	event_mode = terminal->pvt->mouse_send_xy_on_click ||
-		     terminal->pvt->mouse_send_xy_on_button ||
-		     terminal->pvt->mouse_hilite_tracking ||
-		     terminal->pvt->mouse_cell_motion_tracking ||
-		     terminal->pvt->mouse_all_motion_tracking;
-
 	/* Read the modifiers. */
 	if (gdk_event_get_state((GdkEvent*)event, &modifiers)) {
 		terminal->pvt->modifiers = modifiers;
@@ -6970,7 +6947,7 @@
 
 			/* If we're in event mode, and the user held down the
 			 * shift key, we start selecting. */
-			if (event_mode) {
+			if (terminal->pvt->mouse_event_mode) {
 				if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
 					start_selecting = TRUE;
 				}
@@ -7015,7 +6992,7 @@
 		 * to the app. */
 		case 2:
 			if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
-			    !event_mode) {
+			    !terminal->pvt->mouse_event_mode) {
 				vte_terminal_paste_primary(terminal);
 				handled = TRUE;
 			}
@@ -7039,7 +7016,7 @@
 		switch (event->button) {
 		case 1:
 			if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
-			    !event_mode) {
+			    !terminal->pvt->mouse_event_mode) {
 				vte_terminal_start_selection(terminal,
 							     event,
 							     selection_type_word);
@@ -7061,7 +7038,7 @@
 		switch (event->button) {
 		case 1:
 			if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
-			    !event_mode) {
+			    !terminal->pvt->mouse_event_mode) {
 				vte_terminal_start_selection(terminal,
 							     event,
 							     selection_type_line);
@@ -7093,7 +7070,6 @@
 	VteTerminal *terminal;
 	GdkModifierType modifiers;
 	gboolean handled = FALSE;
-	gboolean event_mode;
 
 	terminal = VTE_TERMINAL(widget);
 
@@ -7104,12 +7080,6 @@
 
 	_vte_terminal_set_pointer_visible(terminal, TRUE);
 
-	event_mode = terminal->pvt->mouse_send_xy_on_click ||
-		     terminal->pvt->mouse_send_xy_on_button ||
-		     terminal->pvt->mouse_hilite_tracking ||
-		     terminal->pvt->mouse_cell_motion_tracking ||
-		     terminal->pvt->mouse_all_motion_tracking;
-
 	/* Disconnect from autoscroll requests. */
 	vte_terminal_stop_autoscroll(terminal);
 
@@ -7129,7 +7099,7 @@
 		case 1:
 			/* If Shift is held down, or we're not in events mode,
 			 * copy the selected text. */
-			if (terminal->pvt->selecting || !event_mode) {
+			if (terminal->pvt->selecting || !terminal->pvt->mouse_event_mode) {
 				/* Copy only if something was selected. */
 				if (terminal->pvt->has_selection &&
 				    !terminal->pvt->selecting_restart &&
@@ -7144,7 +7114,7 @@
 			break;
 		case 2:
 			if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
-			    !event_mode) {
+			    !terminal->pvt->mouse_event_mode) {
 				handled = TRUE;
 			}
 			break;
@@ -10901,11 +10871,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_send_xy_on_click ||
-	    terminal->pvt->mouse_send_xy_on_button ||
-	    terminal->pvt->mouse_hilite_tracking ||
-	    terminal->pvt->mouse_cell_motion_tracking ||
-	    terminal->pvt->mouse_all_motion_tracking) {
+	if (terminal->pvt->mouse_event_mode) {
 		switch (event->direction) {
 		case GDK_SCROLL_UP:
 			button = 4;
@@ -13281,11 +13247,7 @@
 		       sizeof(&terminal->pvt->selection_end));
 	}
 	/* Reset mouse motion events. */
-	terminal->pvt->mouse_send_xy_on_click = FALSE;
-	terminal->pvt->mouse_send_xy_on_button = FALSE;
-	terminal->pvt->mouse_hilite_tracking = FALSE;
-	terminal->pvt->mouse_cell_motion_tracking = FALSE;
-	terminal->pvt->mouse_all_motion_tracking = FALSE;
+	terminal->pvt->mouse_event_mode = 0;
 	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 10:10:46 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, &terminal->pvt->mouse_send_xy_on_click, NULL, NULL,
-		 GINT_TO_POINTER(FALSE),
-		 GINT_TO_POINTER(TRUE),
+		{9, NULL, &terminal->pvt->mouse_event_mode, NULL,
+		 GINT_TO_POINTER(0),
+		 GINT_TO_POINTER(MOUSE_EVENT_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, &terminal->pvt->mouse_send_xy_on_button, NULL, NULL,
-		 GINT_TO_POINTER(FALSE),
-		 GINT_TO_POINTER(TRUE),
+		{1000, NULL, &terminal->pvt->mouse_event_mode, NULL,
+		 GINT_TO_POINTER(0),
+		 GINT_TO_POINTER(MOUSE_EVENT_SEND_XY_ON_BUTTON),
 		 NULL, NULL,},
 		/* 1001: Hilite tracking. */
-		{1001, &terminal->pvt->mouse_hilite_tracking, NULL, NULL,
-		 GINT_TO_POINTER(FALSE),
-		 GINT_TO_POINTER(TRUE),
+		{1001, NULL, &terminal->pvt->mouse_event_mode, NULL,
+		 GINT_TO_POINTER(0),
+		 GINT_TO_POINTER(MOUSE_EVENT_HILITE_TRACKING),
 		 NULL, NULL,},
 		/* 1002: Cell motion tracking. */
-		{1002, &terminal->pvt->mouse_cell_motion_tracking, NULL, NULL,
-		 GINT_TO_POINTER(FALSE),
-		 GINT_TO_POINTER(TRUE),
+		{1002, NULL, &terminal->pvt->mouse_event_mode, NULL,
+		 GINT_TO_POINTER(0),
+		 GINT_TO_POINTER(MOUSE_EVENT_CELL_MOTION_TRACKING),
 		 NULL, NULL,},
 		/* 1003: All motion tracking. */
-		{1003, &terminal->pvt->mouse_all_motion_tracking, NULL, NULL,
-		 GINT_TO_POINTER(FALSE),
-		 GINT_TO_POINTER(TRUE),
+		{1003, NULL, &terminal->pvt->mouse_event_mode, NULL,
+		 GINT_TO_POINTER(0),
+		 GINT_TO_POINTER(MOUSE_EVENT_ALL_MOTION_TRACKING),
 		 NULL, NULL,},
 		/* 1010/rxvt: disallowed, scroll-on-output is set by user. */
 		{1010, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
@@ -900,40 +900,6 @@
 	case 1001:
 	case 1002:
 	case 1003:
-		/* Reset all of the options except the one which was
-		 * just toggled. */
-		switch (setting) {
-		case 9:
-			terminal->pvt->mouse_send_xy_on_button = FALSE; /* 1000 */
-			terminal->pvt->mouse_hilite_tracking = FALSE; /* 1001 */
-			terminal->pvt->mouse_cell_motion_tracking = FALSE; /* 1002 */
-			terminal->pvt->mouse_all_motion_tracking = FALSE; /* 1003 */
-			break;
-		case 1000:
-			terminal->pvt->mouse_send_xy_on_click = FALSE; /* 9 */
-			terminal->pvt->mouse_hilite_tracking = FALSE; /* 1001 */
-			terminal->pvt->mouse_cell_motion_tracking = FALSE; /* 1002 */
-			terminal->pvt->mouse_all_motion_tracking = FALSE; /* 1003 */
-			break;
-		case 1001:
-			terminal->pvt->mouse_send_xy_on_click = FALSE; /* 9 */
-			terminal->pvt->mouse_send_xy_on_button = FALSE; /* 1000 */
-			terminal->pvt->mouse_cell_motion_tracking = FALSE; /* 1002 */
-			terminal->pvt->mouse_all_motion_tracking = FALSE; /* 1003 */
-			break;
-		case 1002:
-			terminal->pvt->mouse_send_xy_on_click = FALSE; /* 9 */
-			terminal->pvt->mouse_send_xy_on_button = FALSE; /* 1000 */
-			terminal->pvt->mouse_hilite_tracking = FALSE; /* 1001 */
-			terminal->pvt->mouse_all_motion_tracking = FALSE; /* 1003 */
-			break;
-		case 1003:
-			terminal->pvt->mouse_send_xy_on_click = FALSE; /* 9 */
-			terminal->pvt->mouse_send_xy_on_button = FALSE; /* 1000 */
-			terminal->pvt->mouse_hilite_tracking = FALSE; /* 1001 */
-			terminal->pvt->mouse_cell_motion_tracking = FALSE; /* 1002 */
-			break;
-		}
 		/* Make the pointer visible. */
 		_vte_terminal_set_pointer_visible(terminal, TRUE);
 		break;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]