mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-31 22:25:25 -04:00
Consolidate redraw scheduling in window.c
This commit is contained in:
parent
0953162db8
commit
80d746f6e3
5 changed files with 57 additions and 89 deletions
|
|
@ -50,7 +50,6 @@ static int option_fullscreen;
|
|||
struct terminal {
|
||||
struct window *window;
|
||||
struct display *display;
|
||||
int redraw_scheduled;
|
||||
char *data;
|
||||
int width, height, start, row, column;
|
||||
int fd, master;
|
||||
|
|
@ -219,15 +218,12 @@ terminal_draw(struct terminal *terminal)
|
|||
window_commit(terminal->window, 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
idle_redraw(void *data)
|
||||
static void
|
||||
redraw_handler(struct window *window, void *data)
|
||||
{
|
||||
struct terminal *terminal = data;
|
||||
|
||||
terminal_draw(terminal);
|
||||
terminal->redraw_scheduled = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define STATE_NORMAL 0
|
||||
|
|
@ -236,15 +232,6 @@ idle_redraw(void *data)
|
|||
static void
|
||||
terminal_data(struct terminal *terminal, const char *data, size_t length);
|
||||
|
||||
static void
|
||||
terminal_schedule_redraw(struct terminal *terminal)
|
||||
{
|
||||
if (!terminal->redraw_scheduled) {
|
||||
g_idle_add(idle_redraw, terminal);
|
||||
terminal->redraw_scheduled = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
handle_escape(struct terminal *terminal)
|
||||
{
|
||||
|
|
@ -396,15 +383,7 @@ terminal_data(struct terminal *terminal, const char *data, size_t length)
|
|||
}
|
||||
}
|
||||
|
||||
terminal_schedule_redraw(terminal);
|
||||
}
|
||||
|
||||
static void
|
||||
resize_handler(struct window *window, void *data)
|
||||
{
|
||||
struct terminal *terminal = data;
|
||||
|
||||
terminal_schedule_redraw(terminal);
|
||||
window_schedule_redraw(terminal->window);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -420,7 +399,7 @@ key_handler(struct window *window, uint32_t key, uint32_t unicode,
|
|||
break;
|
||||
terminal->fullscreen ^= 1;
|
||||
window_set_fullscreen(window, terminal->fullscreen);
|
||||
terminal_schedule_redraw(terminal);
|
||||
window_schedule_redraw(terminal->window);
|
||||
break;
|
||||
default:
|
||||
if (state && unicode)
|
||||
|
|
@ -436,7 +415,7 @@ keyboard_focus_handler(struct window *window,
|
|||
struct terminal *terminal = data;
|
||||
|
||||
terminal->focused = (device != NULL);
|
||||
terminal_schedule_redraw(terminal);
|
||||
window_schedule_redraw(terminal->window);
|
||||
}
|
||||
|
||||
static struct terminal *
|
||||
|
|
@ -459,7 +438,8 @@ terminal_create(struct display *display, int fullscreen)
|
|||
terminal->margin = 5;
|
||||
|
||||
window_set_fullscreen(terminal->window, terminal->fullscreen);
|
||||
window_set_resize_handler(terminal->window, resize_handler, terminal);
|
||||
window_set_redraw_handler(terminal->window,
|
||||
redraw_handler, terminal);
|
||||
|
||||
window_set_key_handler(terminal->window, key_handler, terminal);
|
||||
window_set_keyboard_focus_handler(terminal->window,
|
||||
|
|
@ -475,7 +455,6 @@ terminal_create(struct display *display, int fullscreen)
|
|||
cairo_destroy(cr);
|
||||
cairo_surface_destroy(surface);
|
||||
|
||||
|
||||
terminal_draw(terminal);
|
||||
|
||||
return terminal;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue