struct terminal {
struct window *window;
struct wl_display *display;
- int resize_scheduled;
+ int redraw_scheduled, redraw_pending;
char *data;
int width, height, tail, row, column, total_rows;
int fd, master;
#define STATE_SKIP_TO_ALPHA 1
static void
+terminal_schedule_redraw(struct terminal *terminal)
+{
+ if (!terminal->redraw_scheduled) {
+ g_idle_add(idle_redraw, terminal);
+ terminal->redraw_scheduled = 1;
+ } else {
+ terminal->redraw_pending = 1;
+ }
+}
+
+static void
terminal_data(struct terminal *terminal, const char *data, size_t length)
{
int i;
break;
}
}
+
+ terminal_schedule_redraw(terminal);
}
static void
{
struct terminal *terminal = data;
- if (!terminal->resize_scheduled) {
- g_idle_add(idle_redraw, terminal);
- terminal->resize_scheduled = 1;
- }
+ terminal_schedule_redraw(terminal);
}
static void
{
struct terminal *terminal = data;
- terminal->resize_scheduled = 0;
+ terminal->redraw_scheduled = 0;
buffer_destroy(terminal->buffer, terminal->fd);
+
+ if (terminal->redraw_pending) {
+ terminal->redraw_pending = 0;
+ terminal_schedule_redraw(terminal);
+ }
}
struct key {
terminal->window = window_create(display, fd, "Wayland Terminal",
500, 100, 500, 400);
terminal->display = display;
- terminal->resize_scheduled = 1;
+ terminal->redraw_scheduled = 1;
terminal->width = 80;
terminal->height = 25;
size = (terminal->width + 1) * terminal->height;
terminal_data(terminal, buffer, bytes_read);
- if (!terminal->resize_scheduled) {
- g_idle_add(idle_redraw, terminal);
- terminal->resize_scheduled = 1;
- }
-
return TRUE;
}