Commit 2eb1be31 authored by Nalin Dahyabhai's avatar Nalin Dahyabhai

fix a couple of #errors. if the area we're invading is on the edge,

* src/vteglyph.c: fix a couple of #errors.
* src/vte.c(vte_invalidate_cells): if the area we're invading is on the edge,
	invalidate the edge as well.
* src/pty.c: implement and use wrappers for read and write which handle EINTR
	and EAGAIN.
* src/vte.c(vte_terminal_scroll_region): don't use gdk_window_scroll if the
	window is frozen for updates.
* src/vte.c(vte_terminal_sequence_handler_sf): when scrolling down with a
	defined scrolling region, freeze the window to avoid flicker.
parent 27571eb6
2003-04-22 nalin
* src/vteglyph.c: fix a couple of #errors.
* src/vte.c(vte_invalidate_cells): if the area we're invading is on the
edge, invalidate the edge as well.
* src/pty.c: implement and use wrappers for read and write which handle
EINTR and EAGAIN.
* src/vte.c(vte_terminal_scroll_region): don't use gdk_window_scroll if
the window is frozen for updates.
* src/vte.c(vte_terminal_sequence_handler_sf): when scrolling down with
a defined scrolling region, freeze the window to avoid flicker.
2003-04-21 nalin
* gnome-pty-helper/gnome-login-support.c(n_read): don't bail out if
read() returns -1 and errno is either EINTR or EAGAIN, candidate fix for
......
......@@ -201,6 +201,64 @@ _vte_pty_pipe_open_bi(int *a, int *b, int *c, int *d)
return ret;
}
/* Like read, but hide EINTR and EAGAIN. */
static ssize_t
n_read(int fd, void *buffer, size_t count)
{
size_t n = 0;
char *buf = buffer;
int i;
while (n < count) {
i = read(fd, buf + n, count - n);
switch (i) {
case 0:
return n;
break;
case -1:
switch (errno) {
case EINTR:
case EAGAIN:
break;
default:
return -1;
}
default:
n += i;
break;
}
}
return n;
}
/* Like write, but hide EINTR and EAGAIN. */
static ssize_t
n_write(int fd, const void *buffer, size_t count)
{
size_t n = 0;
const char *buf = buffer;
int i;
while (n < count) {
i = write(fd, buf + n, count - n);
switch (i) {
case 0:
return n;
break;
case -1:
switch (errno) {
case EINTR:
case EAGAIN:
break;
default:
return -1;
}
default:
n += i;
break;
}
}
return n;
}
/* Run the given command, using the given descriptor as the controlling
* terminal. */
static int
......@@ -283,9 +341,9 @@ _vte_pty_run_on_pty(int fd, int ready_reader, int ready_writer,
fprintf(stderr, "Child sending child-ready.\n");
}
#endif
write(ready_writer, &c, 1);
n_write(ready_writer, &c, 1);
fsync(ready_writer);
read(ready_reader, &c, 1);
n_read(ready_reader, &c, 1);
#ifdef VTE_DEBUG
if (_vte_debug_on(VTE_DEBUG_PTY)) {
fprintf(stderr, "Child received parent-ready.\n");
......@@ -358,7 +416,7 @@ _vte_pty_fork_on_pty_name(const char *path, int parent_fd, char **env_add,
fprintf(stderr, "Parent ready, waiting for child.\n");
}
#endif
read(ready_a[0], &c, 1);
n_read(ready_a[0], &c, 1);
#ifdef VTE_DEBUG
if (_vte_debug_on(VTE_DEBUG_PTY)) {
fprintf(stderr, "Parent received child-ready.\n");
......@@ -370,7 +428,7 @@ _vte_pty_fork_on_pty_name(const char *path, int parent_fd, char **env_add,
fprintf(stderr, "Parent sending parent-ready.\n");
}
#endif
write(ready_b[1], &c, 1);
n_write(ready_b[1], &c, 1);
close(ready_a[0]);
close(ready_b[1]);
......@@ -451,7 +509,7 @@ _vte_pty_fork_on_pty_fd(int fd, char **env_add,
fprintf(stderr, "Parent ready.\n");
}
#endif
read(ready_a[0], &c, 1);
n_read(ready_a[0], &c, 1);
#ifdef VTE_DEBUG
if (_vte_debug_on(VTE_DEBUG_PTY)) {
fprintf(stderr, "Parent received child-ready.\n");
......@@ -463,7 +521,7 @@ _vte_pty_fork_on_pty_fd(int fd, char **env_add,
fprintf(stderr, "Parent sending parent-ready.\n");
}
#endif
write(ready_b[1], &c, 1);
n_write(ready_b[1], &c, 1);
close(ready_a[0]);
close(ready_b[1]);
......@@ -875,21 +933,21 @@ _vte_pty_open_with_helper(pid_t *child, char **env_add,
if (_vte_pty_helper_started) {
ops = op;
/* Send our request. */
if (write(_vte_pty_helper_tunnel,
&ops, sizeof(ops)) != sizeof(ops)) {
if (n_write(_vte_pty_helper_tunnel,
&ops, sizeof(ops)) != sizeof(ops)) {
return -1;
}
/* Read back the response. */
if (read(_vte_pty_helper_tunnel,
&ret, sizeof(ret)) != sizeof(ret)) {
if (n_read(_vte_pty_helper_tunnel,
&ret, sizeof(ret)) != sizeof(ret)) {
return -1;
}
if (ret == 0) {
return -1;
}
/* Read back a tag. */
if (read(_vte_pty_helper_tunnel,
&tag, sizeof(tag)) != sizeof(tag)) {
if (n_read(_vte_pty_helper_tunnel,
&tag, sizeof(tag)) != sizeof(tag)) {
return -1;
}
/* Receive the master and slave ptys. */
......@@ -1018,12 +1076,12 @@ _vte_pty_close(int pty)
ops = GNOME_PTY_CLOSE_PTY;
tag = g_tree_lookup(_vte_pty_helper_map,
GINT_TO_POINTER(pty));
if (write(_vte_pty_helper_tunnel,
&ops, sizeof(ops)) != sizeof(ops)) {
if (n_write(_vte_pty_helper_tunnel,
&ops, sizeof(ops)) != sizeof(ops)) {
return;
}
if (write(_vte_pty_helper_tunnel,
&tag, sizeof(tag)) != sizeof(tag)) {
if (n_write(_vte_pty_helper_tunnel,
&tag, sizeof(tag)) != sizeof(tag)) {
return;
}
/* Remove the item from the map. */
......@@ -1060,14 +1118,14 @@ main(int argc, char **argv)
FALSE, FALSE, FALSE);
g_print("Child pid is %d.\n", (int)child);
do {
ret = read(fd, &c, 1);
ret = n_read(fd, &c, 1);
if (ret == 0) {
break;
}
if ((ret == -1) && (errno != EAGAIN) && (errno != EINTR)) {
break;
}
write(STDOUT_FILENO, &c, 1);
n_write(STDOUT_FILENO, &c, 1);
} while (TRUE);
return 0;
}
......
......@@ -592,8 +592,27 @@ vte_invalidate_cells(VteTerminal *terminal,
* by multiplying by the size of a character cell. */
rect.x = column_start * terminal->char_width + VTE_PAD_WIDTH;
rect.width = column_count * terminal->char_width;
if (column_start == 0) {
/* Include the left border. */
rect.x -= VTE_PAD_WIDTH;
rect.width += VTE_PAD_WIDTH;
}
if (column_start + column_count == terminal->column_count) {
/* Include the right border. */
rect.width += VTE_PAD_WIDTH;
}
rect.y = row_start * terminal->char_height + VTE_PAD_WIDTH;
rect.height = row_count * terminal->char_height;
if (rect.y == 0) {
/* Include the top border. */
rect.y -= VTE_PAD_WIDTH;
rect.height += VTE_PAD_WIDTH;
}
if (row_start + row_count == terminal->row_count) {
/* Include the bottom border. */
rect.height += VTE_PAD_WIDTH;
}
/* Invalidate the rectangle. */
gdk_window_invalidate_rect(widget->window, &rect, FALSE);
......@@ -635,7 +654,9 @@ vte_terminal_scroll_region(VteTerminal *terminal,
long row, glong count, glong delta)
{
GtkWidget *widget;
GdkWindowObject *window;
gboolean repaint = TRUE;
glong height;
if ((delta == 0) || (count == 0)) {
/* Shenanigans! */
......@@ -648,9 +669,15 @@ vte_terminal_scroll_region(VteTerminal *terminal,
(row == terminal->pvt->screen->scroll_delta) &&
(count == terminal->row_count)) {
widget = GTK_WIDGET(terminal);
gdk_window_scroll(widget->window,
0, delta * terminal->char_height);
repaint = FALSE;
if (GTK_WIDGET_REALIZED(widget)) {
window = GDK_WINDOW_OBJECT(widget->window);
if (window->update_freeze_count == 0) {
height = terminal->char_height;
gdk_window_scroll(widget->window,
0, delta * height);
repaint = FALSE;
}
}
}
if (repaint) {
......@@ -3267,7 +3294,7 @@ vte_sequence_handler_sf(VteTerminal *terminal,
{
GtkWidget *widget;
VteRowData *row;
long start, end, bottom;
long start, end, top, bottom;
VteScreen *screen;
widget = GTK_WIDGET(terminal);
......@@ -3293,17 +3320,21 @@ vte_sequence_handler_sf(VteTerminal *terminal,
_vte_ring_insert_preserve(terminal->pvt->screen->row_data,
screen->cursor_current.row,
row);
/* This may generate multiple redraws, so
* freeze it while we do them. */
gdk_window_freeze_updates(widget->window);
/* Force the areas below the region to be
* redrawn -- they've moved. */
top = screen->cursor_current.row;
bottom = screen->insert_delta +
terminal->row_count - 1;
vte_terminal_scroll_region(terminal,
screen->cursor_current.row,
bottom - screen->cursor_current.row + 1,
1);
vte_terminal_scroll_region(terminal, top,
bottom - top + 1, 1);
/* Force scroll. */
vte_terminal_ensure_cursor(terminal, FALSE);
vte_terminal_adjust_adjustments(terminal, TRUE);
/* Allow updates again. */
gdk_window_thaw_updates(widget->window);
} else {
/* If we're at the bottom of the scrolling
* region, add a line at the top to scroll the
......
......@@ -519,7 +519,7 @@ _vte_glyph_get(struct _vte_glyph_cache *cache, gunichar c)
#if HAVE_DECL_ft_pixel_mode_mono
case ft_pixel_mode_mono:
#else
#error Neither ft_pixel_mode_mono nor FT_PIXEL_MODE_MONO is defined!
#error "Neither ft_pixel_mode_mono nor FT_PIXEL_MODE_MONO is defined!"
#endif
#endif
ioffset += (x / 8);
......@@ -555,7 +555,7 @@ _vte_glyph_get(struct _vte_glyph_cache *cache, gunichar c)
#if HAVE_DECL_ft_pixel_mode_grays
case ft_pixel_mode_grays:
#else
#error Neither FT_PIXEL_MODE_GRAY nor ft_pixel_mode_grays is defined!
#error "Neither FT_PIXEL_MODE_GRAY nor ft_pixel_mode_grays is defined!"
#endif
#endif
ioffset += x;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment