[vte/vte-next] Also store last mouse position in grid coordinates



commit 7402bbb10f5c2b7053a03b3435bf69dfaa60129e
Author: Christian Persch <chpe gnome org>
Date:   Sat May 7 22:11:00 2011 +0200

    Also store last mouse position in grid coordinates
    
    This is in preparation to making the event handling grid based.

 src/vte-private.h |    1 +
 src/vte.c         |   34 +++++++++++++++++++++++-----------
 2 files changed, 24 insertions(+), 11 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index d4cd5b6..91c3abf 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -297,6 +297,7 @@ struct _VteTerminalPrivate {
 				    but we need to guarantee its type. */
 	guint mouse_last_button;
 	long mouse_last_x, mouse_last_y;
+        long mouse_last_cell_x, mouse_last_cell_y;
 	gboolean mouse_autohide;
 	guint mouse_autoscroll_tag;
 
diff --git a/src/vte.c b/src/vte.c
index ecb7231..d2a0d1c 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -6541,9 +6541,11 @@ vte_terminal_stop_autoscroll(VteTerminal *terminal)
 static gboolean
 vte_terminal_motion_notify(GtkWidget *widget, GdkEventMotion *event)
 {
-	VteTerminal *terminal;
+        VteTerminal *terminal = VTE_TERMINAL(widget);
+        VteTerminalPrivate *pvt = terminal->pvt;
 	int width, height;
 	long x, y;
+        long cell_x, cell_y;
 	gboolean handled = FALSE;
 
 	/* check to see if it matters */
@@ -6551,16 +6553,16 @@ vte_terminal_motion_notify(GtkWidget *widget, GdkEventMotion *event)
 		return handled;
 	}
 
-	terminal = VTE_TERMINAL(widget);
+        (void) _vte_terminal_xy_to_grid(terminal, event->x, event->y, &cell_x, &cell_y);
 	x = event->x - terminal->pvt->padding.left;
 	y = event->y - terminal->pvt->padding.top;
 	width = terminal->pvt->char_width;
 	height = terminal->pvt->char_height;
 
 	_vte_debug_print(VTE_DEBUG_EVENTS,
-			"Motion notify (%ld,%ld) [%ld, %ld].\n",
-			x, y,
-			x / width, y / height + terminal->pvt->screen->scroll_delta);
+			"Motion notify (%ld,%ld) [grid %ld,%ld].\n",
+			(long)event->x, (long)event->y,
+                        cell_x, cell_y + terminal->pvt->screen->scroll_delta);
 
 	vte_terminal_read_modifiers (terminal, (GdkEvent*) event);
 
@@ -6608,6 +6610,8 @@ vte_terminal_motion_notify(GtkWidget *widget, GdkEventMotion *event)
 	/* Save the pointer coordinates for later use. */
 	terminal->pvt->mouse_last_x = x;
 	terminal->pvt->mouse_last_y = y;
+        pvt->mouse_last_cell_x = cell_x;
+        pvt->mouse_last_cell_y = cell_y;
 
 	return handled;
 }
@@ -6616,15 +6620,15 @@ vte_terminal_motion_notify(GtkWidget *widget, GdkEventMotion *event)
 static gint
 vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
 {
-	VteTerminal *terminal;
+	VteTerminal *terminal = VTE_TERMINAL(widget);
+        VteTerminalPrivate *pvt = terminal->pvt;
 	long height, width, delta;
 	gboolean handled = FALSE;
 	gboolean start_selecting = FALSE, extend_selecting = FALSE;
+        long cell_x, cell_y;
 	long cellx, celly;
 	long x,y;
 
-	terminal = VTE_TERMINAL(widget);
-
 	x = event->x - terminal->pvt->padding.left;
 	y = event->y - terminal->pvt->padding.top;
 
@@ -6639,6 +6643,7 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
 	vte_terminal_read_modifiers (terminal, (GdkEvent*) event);
 
 	/* Convert the event coordinates to cell coordinates. */
+        (void) _vte_terminal_xy_to_grid(terminal, event->x, event->y, &cell_x, &cell_y);
 	cellx = x / width;
 	celly = y / height + delta;
 
@@ -6768,6 +6773,8 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
 	terminal->pvt->mouse_last_button = event->button;
 	terminal->pvt->mouse_last_x = x;
 	terminal->pvt->mouse_last_y = y;
+        pvt->mouse_last_cell_x = cell_x;
+        pvt->mouse_last_cell_y = cell_y;
 
 	return TRUE;
 }
@@ -6776,12 +6783,13 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
 static gint
 vte_terminal_button_release(GtkWidget *widget, GdkEventButton *event)
 {
-	VteTerminal *terminal;
+        VteTerminal *terminal = VTE_TERMINAL(widget);
+        VteTerminalPrivate *pvt = terminal->pvt;
 	gboolean handled = FALSE;
+        long cell_x, cell_y;
 	int x, y;
 
-	terminal = VTE_TERMINAL(widget);
-
+        (void) _vte_terminal_xy_to_grid(terminal, event->x, event->y, &cell_x, &cell_y);
 	x = event->x - terminal->pvt->padding.left;
 	y = event->y - terminal->pvt->padding.top;
 
@@ -6829,6 +6837,8 @@ 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;
+        pvt->mouse_last_cell_x = cell_x;
+        pvt->mouse_last_cell_y = cell_y;
 
 	return TRUE;
 }
@@ -12624,6 +12634,8 @@ vte_terminal_reset(VteTerminal *terminal,
 	pvt->mouse_last_button = 0;
 	pvt->mouse_last_x = 0;
 	pvt->mouse_last_y = 0;
+        pvt->mouse_last_cell_x = 0;
+        pvt->mouse_last_cell_y = 0;
 	/* Clear modifiers. */
 	pvt->modifiers = 0;
 	/* Cause everything to be redrawn (or cleared). */



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