[vte/vte-next: 34/223] Remove sealed char_{width, height} from public struct



commit fc1b7614c711cc0c1309dffa136cdf0155fa8580
Author: Christian Persch <chpe gnome org>
Date:   Mon May 2 22:30:35 2011 +0200

    Remove sealed char_{width,height} from public struct

 src/vte-private.h |    3 +
 src/vte.c         |  118 ++++++++++++++++++++++++++--------------------------
 src/vte.h         |    1 -
 src/vteapp.c      |   16 +++++--
 src/vteseq.c      |   16 ++++----
 5 files changed, 82 insertions(+), 72 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index 0db9c80..4fe9e5d 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -317,6 +317,9 @@ struct _VteTerminalPrivate {
 	gboolean fontdirty;
         glong char_ascent;
         glong char_descent;
+        /* dimensions of character cells */
+        glong char_width;
+        glong char_height;
 
 	/* Data used when rendering the text which reflects server resources
 	 * and data, which should be dropped when unrealizing and (re)created
diff --git a/src/vte.c b/src/vte.c
index 57d49c3..6cb4ee1 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -395,21 +395,21 @@ _vte_invalidate_cells(VteTerminal *terminal,
 	 * by multiplying by the size of a character cell.
 	 * Always include the extra pixel border and overlap pixel.
 	 */
-	rect.x = column_start * terminal->char_width - 1;
+	rect.x = column_start * terminal->pvt->char_width - 1;
 	if (column_start != 0) {
 		rect.x += terminal->pvt->inner_border.left;
 	}
-	rect.width = (column_start + column_count) * terminal->char_width + 3 + terminal->pvt->inner_border.left;
+	rect.width = (column_start + column_count) * terminal->pvt->char_width + 3 + terminal->pvt->inner_border.left;
 	if (column_start + column_count == terminal->column_count) {
 		rect.width += terminal->pvt->inner_border.right;
 	}
 	rect.width -= rect.x;
 
-	rect.y = row_start * terminal->char_height - 1;
+	rect.y = row_start * terminal->pvt->char_height - 1;
 	if (row_start != 0) {
 		rect.y += terminal->pvt->inner_border.top;
 	}
-	rect.height = (row_start + row_count) * terminal->char_height + 2 + terminal->pvt->inner_border.top;
+	rect.height = (row_start + row_count) * terminal->pvt->char_height + 2 + terminal->pvt->inner_border.top;
 	if (row_start + row_count == terminal->row_count) {
 		rect.height += terminal->pvt->inner_border.bottom;
 	}
@@ -668,7 +668,7 @@ _vte_invalidate_cell(VteTerminal *terminal, glong col, glong row)
 						terminal->pvt->draw,
 						cell->c,
 						columns, cell->attr.bold) >
-					terminal->char_width * columns) {
+					terminal->pvt->char_width * columns) {
 				columns++;
 			}
 		}
@@ -718,7 +718,7 @@ _vte_invalidate_cursor_once(VteTerminal *terminal, gboolean periodic)
 						terminal->pvt->draw,
 						cell->c,
 						columns, cell->attr.bold) >
-			    terminal->char_width * columns) {
+			    terminal->pvt->char_width * columns) {
 				columns++;
 			}
 		}
@@ -3912,11 +3912,11 @@ next_match:
 	if (gtk_widget_get_realized (&terminal->widget)) {
 		cairo_rectangle_int_t rect;
 		rect.x = terminal->pvt->screen->cursor_current.col *
-			 terminal->char_width + terminal->pvt->inner_border.left;
-		rect.width = terminal->char_width;
+			 terminal->pvt->char_width + terminal->pvt->inner_border.left;
+		rect.width = terminal->pvt->char_width;
 		rect.y = (terminal->pvt->screen->cursor_current.row - delta) *
-			 terminal->char_height + terminal->pvt->inner_border.top;
-		rect.height = terminal->char_height;
+			 terminal->pvt->char_height + terminal->pvt->inner_border.top;
+		rect.height = terminal->pvt->char_height;
 		gtk_im_context_set_cursor_location(terminal->pvt->im_context,
 						   &rect);
 	}
@@ -5345,8 +5345,8 @@ vte_terminal_send_mouse_button_internal(VteTerminal *terminal,
 	unsigned char cb, cx, cy;
 	char buf[LINE_MAX];
 	gint len;
-	int width = terminal->char_width;
-	int height = terminal->char_height;
+	int width = terminal->pvt->char_width;
+	int height = terminal->pvt->char_height;
 	long col = (x - terminal->pvt->inner_border.left) / width;
 	long row = (y - terminal->pvt->inner_border.top) / height;
 
@@ -5395,8 +5395,8 @@ vte_terminal_maybe_send_mouse_drag(VteTerminal *terminal, GdkEventMotion *event)
 	unsigned char cb, cx, cy;
 	char buf[LINE_MAX];
 	gint len;
-	int width = terminal->char_width;
-	int height = terminal->char_height;
+	int width = terminal->pvt->char_width;
+	int height = terminal->pvt->char_height;
 	long col = ((long) event->x - terminal->pvt->inner_border.left) / width;
 	long row = ((long) event->y - terminal->pvt->inner_border.top) / height;
 
@@ -5464,8 +5464,8 @@ vte_terminal_match_hilite_clear(VteTerminal *terminal)
 static gboolean
 cursor_inside_match (VteTerminal *terminal, long x, long y)
 {
-	gint width = terminal->char_width;
-	gint height = terminal->char_height;
+	gint width = terminal->pvt->char_width;
+	gint height = terminal->pvt->char_height;
 	glong col = x / width;
 	glong row = y / height + terminal->pvt->screen->scroll_delta;
 	if (terminal->pvt->match_start.row == terminal->pvt->match_end.row) {
@@ -5526,8 +5526,8 @@ vte_terminal_match_hilite_update(VteTerminal *terminal, long x, long y)
 	VteScreen *screen;
 	long delta;
 
-	width = terminal->char_width;
-	height = terminal->char_height;
+	width = terminal->pvt->char_width;
+	height = terminal->pvt->char_height;
 
 	/* Check for matches. */
 	screen = terminal->pvt->screen;
@@ -5617,8 +5617,8 @@ vte_terminal_match_hilite(VteTerminal *terminal, long x, long y)
 	int width, height;
 	GtkAllocation allocation;
 
-	width = terminal->char_width;
-	height = terminal->char_height;
+	width = terminal->pvt->char_width;
+	height = terminal->pvt->char_height;
 
 	gtk_widget_get_allocation (&terminal->widget, &allocation);
 
@@ -6079,7 +6079,7 @@ vte_terminal_start_selection(VteTerminal *terminal, GdkEventButton *event,
 	terminal->pvt->has_selection = TRUE;
 	terminal->pvt->selection_last.x = event->x - terminal->pvt->inner_border.left;
 	terminal->pvt->selection_last.y = event->y - terminal->pvt->inner_border.top +
-					  (terminal->char_height * delta);
+					  (terminal->pvt->char_height * delta);
 
 	/* Decide whether or not to restart on the next drag. */
 	switch (selection_type) {
@@ -6358,8 +6358,8 @@ vte_terminal_extend_selection(VteTerminal *terminal, long x, long y,
 	gboolean invalidate_selected = FALSE;
 	gboolean had_selection;
 
-	height = terminal->char_height;
-	width = terminal->char_width;
+	height = terminal->pvt->char_height;
+	width = terminal->pvt->char_width;
 
 	/* Confine y into the visible area. (#563024) */
 	if (y < 0) {
@@ -6658,7 +6658,7 @@ vte_terminal_autoscroll(VteTerminal *terminal)
 		_vte_debug_print(VTE_DEBUG_EVENTS, "Autoscrolling down.\n");
 	}
 	if (terminal->pvt->mouse_last_y >=
-	    terminal->row_count * terminal->char_height) {
+	    terminal->row_count * terminal->pvt->char_height) {
 		if (terminal->adjustment) {
 			/* Try to scroll up by one line. */
 			adj = terminal->pvt->screen->scroll_delta + 1;
@@ -6669,8 +6669,8 @@ vte_terminal_autoscroll(VteTerminal *terminal)
 	}
 	if (extend) {
 		/* Don't select off-screen areas.  That just confuses people. */
-		xmax = terminal->column_count * terminal->char_width;
-		ymax = terminal->row_count * terminal->char_height;
+		xmax = terminal->column_count * terminal->pvt->char_width;
+		ymax = terminal->row_count * terminal->pvt->char_height;
 
 		x = CLAMP(terminal->pvt->mouse_last_x, 0, xmax);
 		y = CLAMP(terminal->pvt->mouse_last_y, 0, ymax);
@@ -6680,7 +6680,7 @@ vte_terminal_autoscroll(VteTerminal *terminal)
 			x = 0;
 		}
 		if (terminal->pvt->mouse_last_y >= ymax && !terminal->pvt->selection_block_mode) {
-			x = terminal->column_count * terminal->char_width;
+			x = terminal->column_count * terminal->pvt->char_width;
 		}
 		/* Extend selection to cover the newly-scrolled area. */
 		vte_terminal_extend_selection(terminal, x, y, FALSE, TRUE);
@@ -6732,8 +6732,8 @@ vte_terminal_motion_notify(GtkWidget *widget, GdkEventMotion *event)
 	terminal = VTE_TERMINAL(widget);
 	x = event->x - terminal->pvt->inner_border.left;
 	y = event->y - terminal->pvt->inner_border.top;
-	width = terminal->char_width;
-	height = terminal->char_height;
+	width = terminal->pvt->char_width;
+	height = terminal->pvt->char_height;
 
 	_vte_debug_print(VTE_DEBUG_EVENTS,
 			"Motion notify (%ld,%ld) [%ld, %ld].\n",
@@ -6806,8 +6806,8 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
 	x = event->x - terminal->pvt->inner_border.left;
 	y = event->y - terminal->pvt->inner_border.top;
 
-	height = terminal->char_height;
-	width = terminal->char_width;
+	height = terminal->pvt->char_height;
+	width = terminal->pvt->char_width;
 	delta = terminal->pvt->screen->scroll_delta;
 
 	vte_terminal_match_hilite(terminal, x, y);
@@ -6825,7 +6825,7 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
 		_vte_debug_print(VTE_DEBUG_EVENTS,
 				"Button %d single-click at (%ld,%ld)\n",
 				event->button,
-				x, y + terminal->char_height * delta);
+				x, y + terminal->pvt->char_height * delta);
 		/* Handle this event ourselves. */
 		switch (event->button) {
 		case 1:
@@ -6899,7 +6899,7 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
 		_vte_debug_print(VTE_DEBUG_EVENTS,
 				"Button %d double-click at (%ld,%ld)\n",
 				event->button,
-				x, y + (terminal->char_height * delta));
+				x, y + (terminal->pvt->char_height * delta));
 		switch (event->button) {
 		case 1:
 			if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
@@ -6921,7 +6921,7 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
 		_vte_debug_print(VTE_DEBUG_EVENTS,
 				"Button %d triple-click at (%ld,%ld).\n",
 				event->button,
-				x, y + (terminal->char_height * delta));
+				x, y + (terminal->pvt->char_height * delta));
 		switch (event->button) {
 		case 1:
 			if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
@@ -7185,13 +7185,13 @@ vte_terminal_apply_metrics(VteTerminal *terminal,
 	descent = MAX(descent, 1);
 
 	/* Change settings, and keep track of when we've changed anything. */
-	if (width != terminal->char_width) {
+	if (width != terminal->pvt->char_width) {
 		resize = cresize = TRUE;
-		terminal->char_width = width;
+		terminal->pvt->char_width = width;
 	}
-	if (height != terminal->char_height) {
+	if (height != terminal->pvt->char_height) {
 		resize = cresize = TRUE;
-		terminal->char_height = height;
+		terminal->pvt->char_height = height;
 	}
 	if (ascent != terminal->pvt->char_ascent) {
 		resize = TRUE;
@@ -7214,8 +7214,8 @@ vte_terminal_apply_metrics(VteTerminal *terminal,
 	/* Emit a signal that the font changed. */
 	if (cresize) {
 		vte_terminal_emit_char_size_changed(terminal,
-						    terminal->char_width,
-						    terminal->char_height);
+						    terminal->pvt->char_width,
+						    terminal->pvt->char_height);
 	}
 	/* Repaint. */
 	_vte_invalidate_all(terminal);
@@ -7735,8 +7735,8 @@ vte_terminal_init(VteTerminal *terminal)
 	vte_terminal_set_vadjustment(terminal, NULL);
 
 	/* Set up dummy metrics, value != 0 to avoid division by 0 */
-	terminal->char_width = 1;
-	terminal->char_height = 1;
+	terminal->pvt->char_width = 1;
+	terminal->pvt->char_height = 1;
 	terminal->pvt->char_ascent = 1;
 	terminal->pvt->char_descent = 1;
 	terminal->pvt->line_thickness = 1;
@@ -7876,8 +7876,8 @@ vte_terminal_get_preferred_width(GtkWidget *widget,
 	vte_terminal_ensure_font (terminal);
 
         vte_terminal_refresh_size(terminal);
-	*minimum_width = terminal->char_width * 1;
-        *natural_width = terminal->char_width * terminal->column_count;
+	*minimum_width = terminal->pvt->char_width * 1;
+        *natural_width = terminal->pvt->char_width * terminal->column_count;
 
 	*minimum_width += terminal->pvt->inner_border.left +
                           terminal->pvt->inner_border.right;
@@ -7906,8 +7906,8 @@ vte_terminal_get_preferred_height(GtkWidget *widget,
 	vte_terminal_ensure_font (terminal);
 
         vte_terminal_refresh_size(terminal);
-	*minimum_height = terminal->char_height * 1;
-        *natural_height = terminal->char_height * terminal->row_count;
+	*minimum_height = terminal->pvt->char_height * 1;
+        *natural_height = terminal->pvt->char_height * terminal->row_count;
 
 	*minimum_height += terminal->pvt->inner_border.left +
 			   terminal->pvt->inner_border.right;
@@ -7937,9 +7937,9 @@ vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
 	terminal = VTE_TERMINAL(widget);
 
 	width = (allocation->width - (terminal->pvt->inner_border.left + terminal->pvt->inner_border.right)) /
-		terminal->char_width;
+		terminal->pvt->char_width;
 	height = (allocation->height - (terminal->pvt->inner_border.top + terminal->pvt->inner_border.bottom)) /
-		 terminal->char_height;
+		 terminal->pvt->char_height;
 	width = MAX(width, 1);
 	height = MAX(height, 1);
 
@@ -10159,8 +10159,8 @@ vte_terminal_expand_region (VteTerminal *terminal, cairo_region_t *region, const
 
 	screen = terminal->pvt->screen;
 
-	width = terminal->char_width;
-	height = terminal->char_height;
+	width = terminal->pvt->char_width;
+	height = terminal->pvt->char_height;
 
 	/* increase the paint by one pixel on all sides to force the
 	 * inclusion of neighbouring cells */
@@ -10205,8 +10205,8 @@ vte_terminal_paint_area (VteTerminal *terminal, const cairo_rectangle_int_t *are
 
 	screen = terminal->pvt->screen;
 
-	width = terminal->char_width;
-	height = terminal->char_height;
+	width = terminal->pvt->char_width;
+	height = terminal->pvt->char_height;
 
 	row = MAX(0, (area->y - terminal->pvt->inner_border.top) / height);
 	row_stop = MIN((area->height + area->y - terminal->pvt->inner_border.top) / height,
@@ -10265,8 +10265,8 @@ vte_terminal_paint_cursor(VteTerminal *terminal)
 	col = screen->cursor_current.col;
 	drow = screen->cursor_current.row;
 	row = drow - delta;
-	width = terminal->char_width;
-	height = terminal->char_height;
+	width = terminal->pvt->char_width;
+	height = terminal->pvt->char_height;
 
 	if ((CLAMP(col, 0, terminal->column_count - 1) != col) ||
 	    (CLAMP(row, 0, terminal->row_count    - 1) != row))
@@ -10403,8 +10403,8 @@ vte_terminal_paint_im_preedit_string(VteTerminal *terminal)
 	screen = terminal->pvt->screen;
 
 	/* Keep local copies of rendering information. */
-	width = terminal->char_width;
-	height = terminal->char_height;
+	width = terminal->pvt->char_width;
+	height = terminal->pvt->char_height;
 	ascent = terminal->pvt->char_ascent;
 	descent = terminal->pvt->char_descent;
 	delta = screen->scroll_delta;
@@ -10492,7 +10492,7 @@ vte_terminal_paint(GtkWidget *widget, cairo_region_t *region)
 			_vte_draw_set_background_scroll(terminal->pvt->draw,
 							0,
 							terminal->pvt->screen->scroll_delta *
-							terminal->char_height);
+							terminal->pvt->char_height);
 		} else {
 			_vte_draw_set_background_scroll(terminal->pvt->draw, 0, 0);
 		}
@@ -13272,7 +13272,7 @@ vte_terminal_get_char_width(VteTerminal *terminal)
 {
 	g_return_val_if_fail(VTE_IS_TERMINAL(terminal), -1);
 	vte_terminal_ensure_font (terminal);
-	return terminal->char_width;
+	return terminal->pvt->char_width;
 }
 
 /**
@@ -13286,7 +13286,7 @@ vte_terminal_get_char_height(VteTerminal *terminal)
 {
 	g_return_val_if_fail(VTE_IS_TERMINAL(terminal), -1);
 	vte_terminal_ensure_font (terminal);
-	return terminal->char_height;
+	return terminal->pvt->char_height;
 }
 
 /**
diff --git a/src/vte.h b/src/vte.h
index 9b6b631..30b5342 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -69,7 +69,6 @@ struct _VteTerminal {
 	GtkAdjustment *_VTE_SEAL(adjustment);	/* Scrolling adjustment. */
 
 	/* Metric and sizing data. */
-	glong _VTE_SEAL(char_width), _VTE_SEAL(char_height);	/* dimensions of character cells */
 	glong _VTE_SEAL(row_count), _VTE_SEAL(column_count);	/* dimensions of the window */
 
 	/* Titles. */
diff --git a/src/vteapp.c b/src/vteapp.c
index b7ff5e5..bfb3176 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -352,6 +352,7 @@ adjust_font_size(GtkWidget *widget, gpointer data, gint howmuch)
 {
 	VteTerminal *terminal;
 	PangoFontDescription *desired;
+        glong char_width, char_height;
 	gint newsize;
 	gint columns, rows, owidth, oheight;
 
@@ -362,8 +363,10 @@ adjust_font_size(GtkWidget *widget, gpointer data, gint howmuch)
 
 	/* Take into account padding and border overhead. */
 	gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight);
-	owidth -= terminal->char_width * terminal->column_count;
-	oheight -= terminal->char_height * terminal->row_count;
+        char_width = vte_terminal_get_char_width (terminal);
+        char_height = vte_terminal_get_char_height (terminal);
+	owidth -= char_width * terminal->column_count;
+	oheight -= char_height * terminal->row_count;
 
 	/* Calculate the new font size. */
 	desired = pango_font_description_copy(vte_terminal_get_font(terminal));
@@ -375,9 +378,14 @@ adjust_font_size(GtkWidget *widget, gpointer data, gint howmuch)
 	/* Change the font, then resize the window so that we have the same
 	 * number of rows and columns. */
 	vte_terminal_set_font(terminal, desired);
+
+        /* This above call will have changed the char size! */
+        char_width = vte_terminal_get_char_width (terminal);
+        char_height = vte_terminal_get_char_height (terminal);
+
 	gtk_window_resize(GTK_WINDOW(data),
-			  columns * terminal->char_width + owidth,
-			  rows * terminal->char_height + oheight);
+			  columns * char_width + owidth,
+			  rows * char_height + oheight);
 
 	pango_font_description_free(desired);
 }
diff --git a/src/vteseq.c b/src/vteseq.c
index 7c73175..8df0ab2 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -821,11 +821,11 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal,
 	case 3:
 		vte_terminal_emit_resize_window(terminal,
 						(set ? 132 : 80) *
-						terminal->char_width +
+						terminal->pvt->char_width +
 						terminal->pvt->inner_border.left +
                                                 terminal->pvt->inner_border.right,
 						terminal->row_count *
-						terminal->char_height +
+						terminal->pvt->char_height +
 						terminal->pvt->inner_border.top +
                                                 terminal->pvt->inner_border.bottom);
 		/* Request a resize and redraw. */
@@ -3132,10 +3132,10 @@ vte_sequence_handler_window_manipulation (VteTerminal *terminal, GValueArray *pa
 						"(to %ld columns, %ld rows).\n",
 						arg2, arg1);
 				vte_terminal_emit_resize_window(terminal,
-								arg2 * terminal->char_width +
+								arg2 * terminal->pvt->char_width +
 								terminal->pvt->inner_border.left +
 								terminal->pvt->inner_border.right,
-								arg1 * terminal->char_height +
+								arg1 * terminal->pvt->char_height +
 								terminal->pvt->inner_border.top +
 								terminal->pvt->inner_border.bottom);
 				i += 2;
@@ -3219,8 +3219,8 @@ vte_sequence_handler_window_manipulation (VteTerminal *terminal, GValueArray *pa
 			width = gdk_screen_get_width(gscreen);
 			g_snprintf(buf, sizeof(buf),
 				   _VTE_CAP_CSI "9;%ld;%ldt",
-				   height / terminal->char_height,
-				   width / terminal->char_width);
+				   height / terminal->pvt->char_height,
+				   width / terminal->pvt->char_width);
 			vte_terminal_feed_child(terminal, buf, -1);
 			break;
 		case 20:
@@ -3257,10 +3257,10 @@ vte_sequence_handler_window_manipulation (VteTerminal *terminal, GValueArray *pa
 				/* Resize to the specified number of
 				 * rows. */
 				vte_terminal_emit_resize_window(terminal,
-								terminal->column_count * terminal->char_width +
+								terminal->column_count * terminal->pvt->char_width +
                                                                 terminal->pvt->inner_border.left +
                                                                 terminal->pvt->inner_border.right,
-								param * terminal->char_height +
+								param * terminal->pvt->char_height +
 								terminal->pvt->inner_border.top +
                                                                 terminal->pvt->inner_border.bottom);
 			}



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