[vte/vte-next: 33/47] Remove sealed char_{width, height} from public struct
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-next: 33/47] Remove sealed char_{width, height} from public struct
- Date: Tue, 3 May 2011 00:07:44 +0000 (UTC)
commit bcd69507ee94922ea6d1b637f0226c77736c80b7
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 | 11 +++--
src/vteseq.c | 16 ++++----
5 files changed, 77 insertions(+), 72 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index 04a2303..52d1dc3 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 e5694c1..c57ec19 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++;
}
}
@@ -3914,11 +3914,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);
}
@@ -5347,8 +5347,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;
@@ -5397,8 +5397,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;
@@ -5466,8 +5466,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) {
@@ -5528,8 +5528,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;
@@ -5619,8 +5619,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);
@@ -6081,7 +6081,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) {
@@ -6360,8 +6360,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) {
@@ -6660,7 +6660,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;
@@ -6671,8 +6671,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);
@@ -6682,7 +6682,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);
@@ -6734,8 +6734,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",
@@ -6808,8 +6808,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);
@@ -6827,7 +6827,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:
@@ -6901,7 +6901,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) ||
@@ -6923,7 +6923,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) ||
@@ -7187,13 +7187,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;
@@ -7216,8 +7216,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);
@@ -7737,8 +7737,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;
@@ -7878,8 +7878,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;
@@ -7908,8 +7908,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;
@@ -7939,9 +7939,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);
@@ -10161,8 +10161,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 */
@@ -10207,8 +10207,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,
@@ -10267,8 +10267,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))
@@ -10405,8 +10405,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;
@@ -10494,7 +10494,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);
}
@@ -13274,7 +13274,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;
}
/**
@@ -13288,7 +13288,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 1d35779..345d38c 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 984cef3..622d4df 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));
@@ -376,8 +379,8 @@ adjust_font_size(GtkWidget *widget, gpointer data, gint howmuch)
* number of rows and columns. */
vte_terminal_set_font(terminal, desired);
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 3fff7e8..5d76280 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -804,11 +804,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. */
@@ -3115,10 +3115,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;
@@ -3202,8 +3202,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:
@@ -3240,10 +3240,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]