version 1.40, 2009/09/22 12:38:10 |
version 1.41, 2009/09/23 06:18:47 |
|
|
void server_check_window(struct window *); |
void server_check_window(struct window *); |
void server_check_redraw(struct client *); |
void server_check_redraw(struct client *); |
void server_set_title(struct client *); |
void server_set_title(struct client *); |
void server_redraw_locked(struct client *); |
|
void server_check_timers(struct client *); |
void server_check_timers(struct client *); |
void server_second_timers(void); |
void server_second_timers(void); |
int server_update_socket(void); |
int server_update_socket(void); |
|
|
key_bindings_init(); |
key_bindings_init(); |
utf8_build(); |
utf8_build(); |
|
|
server_locked = 0; |
|
server_password = NULL; |
|
server_activity = time(NULL); |
server_activity = time(NULL); |
|
|
start_time = time(NULL); |
start_time = time(NULL); |
|
|
|
|
options_free(&global_s_options); |
options_free(&global_s_options); |
options_free(&global_w_options); |
options_free(&global_w_options); |
if (server_password != NULL) |
|
xfree(server_password); |
|
|
|
return (0); |
return (0); |
} |
} |
|
|
} |
} |
|
|
if (c->flags & CLIENT_REDRAW) { |
if (c->flags & CLIENT_REDRAW) { |
if (server_locked) |
screen_redraw_screen(c, 0); |
server_redraw_locked(c); |
|
else |
|
screen_redraw_screen(c, 0); |
|
c->flags &= ~CLIENT_STATUS; |
c->flags &= ~CLIENT_STATUS; |
} else { |
} else { |
TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) { |
TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) { |
|
|
xfree(title); |
xfree(title); |
} |
} |
|
|
/* Redraw client when locked. */ |
|
void |
|
server_redraw_locked(struct client *c) |
|
{ |
|
struct screen_write_ctx ctx; |
|
struct screen screen; |
|
struct grid_cell gc; |
|
u_int colour, xx, yy, i; |
|
int style; |
|
|
|
xx = c->tty.sx; |
|
yy = c->tty.sy - 1; |
|
if (xx == 0 || yy == 0) |
|
return; |
|
colour = options_get_number(&global_w_options, "clock-mode-colour"); |
|
style = options_get_number(&global_w_options, "clock-mode-style"); |
|
|
|
memcpy(&gc, &grid_default_cell, sizeof gc); |
|
colour_set_fg(&gc, colour); |
|
gc.attr |= GRID_ATTR_BRIGHT; |
|
|
|
screen_init(&screen, xx, yy, 0); |
|
|
|
screen_write_start(&ctx, NULL, &screen); |
|
clock_draw(&ctx, colour, style); |
|
|
|
if (password_failures != 0) { |
|
screen_write_cursormove(&ctx, 0, 0); |
|
screen_write_puts( |
|
&ctx, &gc, "%u failed attempts", password_failures); |
|
if (time(NULL) < password_backoff) |
|
screen_write_puts(&ctx, &gc, "; sleeping"); |
|
} |
|
|
|
screen_write_stop(&ctx); |
|
|
|
for (i = 0; i < screen_size_y(&screen); i++) |
|
tty_draw_line(&c->tty, &screen, i, 0, 0); |
|
screen_redraw_screen(c, 1); |
|
|
|
screen_free(&screen); |
|
} |
|
|
|
/* Check for timers on client. */ |
/* Check for timers on client. */ |
void |
void |
server_check_timers(struct client *c) |
server_check_timers(struct client *c) |
|
|
status_prompt_key(c, key); |
status_prompt_key(c, key); |
continue; |
continue; |
} |
} |
if (server_locked) |
|
continue; |
|
|
|
/* Check for mouse keys. */ |
/* Check for mouse keys. */ |
if (key == KEYC_MOUSE) { |
if (key == KEYC_MOUSE) { |
|
|
tty_cursor(&c->tty, s->cx, s->cy, wp->xoff, wp->yoff); |
tty_cursor(&c->tty, s->cx, s->cy, wp->xoff, wp->yoff); |
|
|
mode = s->mode; |
mode = s->mode; |
if (server_locked) |
|
mode &= ~TTY_NOCURSOR; |
|
tty_update_mode(&c->tty, mode); |
tty_update_mode(&c->tty, mode); |
tty_reset(&c->tty); |
tty_reset(&c->tty); |
} |
} |
|
|
server_second_timers(void) |
server_second_timers(void) |
{ |
{ |
struct window *w; |
struct window *w; |
struct client *c; |
|
struct window_pane *wp; |
struct window_pane *wp; |
u_int i; |
u_int i; |
int xtimeout; |
int xtimeout; |
struct tm now, then; |
|
static time_t last_t = 0; |
|
time_t t; |
time_t t; |
|
|
t = time(NULL); |
t = time(NULL); |
|
|
TAILQ_FOREACH(wp, &w->panes, entry) { |
TAILQ_FOREACH(wp, &w->panes, entry) { |
if (wp->mode != NULL && wp->mode->timer != NULL) |
if (wp->mode != NULL && wp->mode->timer != NULL) |
wp->mode->timer(wp); |
wp->mode->timer(wp); |
} |
|
} |
|
|
|
if (password_backoff != 0 && t >= password_backoff) { |
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { |
|
if ((c = ARRAY_ITEM(&clients, i)) != NULL) |
|
server_redraw_client(c); |
|
} |
|
password_backoff = 0; |
|
} |
|
|
|
/* Check for a minute having passed. */ |
|
gmtime_r(&t, &now); |
|
gmtime_r(&last_t, &then); |
|
if (now.tm_min == then.tm_min) |
|
return; |
|
last_t = t; |
|
|
|
/* If locked, redraw all clients. */ |
|
if (server_locked) { |
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { |
|
if ((c = ARRAY_ITEM(&clients, i)) != NULL) |
|
server_redraw_client(c); |
|
} |
} |
} |
} |
} |
} |