mirror of
https://github.com/tmux/tmux.git
synced 2025-01-15 05:09:04 +00:00
Sync OpenBSD patchset 504:
Use timeout events for the identify and message timers.
This commit is contained in:
parent
bee17719d8
commit
02438c01b7
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-client.c,v 1.15 2009-11-08 23:09:36 tcunha Exp $ */
|
/* $Id: server-client.c,v 1.16 2009-11-08 23:11:23 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -119,8 +119,11 @@ server_client_lost(struct client *c)
|
|||||||
if (c->title != NULL)
|
if (c->title != NULL)
|
||||||
xfree(c->title);
|
xfree(c->title);
|
||||||
|
|
||||||
|
evtimer_del(&c->identify_timer);
|
||||||
|
|
||||||
if (c->message_string != NULL)
|
if (c->message_string != NULL)
|
||||||
xfree(c->message_string);
|
xfree(c->message_string);
|
||||||
|
evtimer_del(&c->message_timer);
|
||||||
|
|
||||||
if (c->prompt_string != NULL)
|
if (c->prompt_string != NULL)
|
||||||
xfree(c->prompt_string);
|
xfree(c->prompt_string);
|
||||||
@ -447,12 +450,6 @@ server_client_check_timers(struct client *c)
|
|||||||
if (gettimeofday(&tv, NULL) != 0)
|
if (gettimeofday(&tv, NULL) != 0)
|
||||||
fatal("gettimeofday failed");
|
fatal("gettimeofday failed");
|
||||||
|
|
||||||
if (c->flags & CLIENT_IDENTIFY && timercmp(&tv, &c->identify_timer, >))
|
|
||||||
server_clear_identify(c);
|
|
||||||
|
|
||||||
if (c->message_string != NULL && timercmp(&tv, &c->message_timer, >))
|
|
||||||
status_message_clear(c);
|
|
||||||
|
|
||||||
if (c->message_string != NULL || c->prompt_string != NULL) {
|
if (c->message_string != NULL || c->prompt_string != NULL) {
|
||||||
/*
|
/*
|
||||||
* Don't need timed redraw for messages/prompts so bail now.
|
* Don't need timed redraw for messages/prompts so bail now.
|
||||||
|
20
server-fn.c
20
server-fn.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-fn.c,v 1.95 2009-11-08 23:09:36 tcunha Exp $ */
|
/* $Id: server-fn.c,v 1.96 2009-11-08 23:11:23 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
|
void server_callback_identify(int, short, void *);
|
||||||
|
|
||||||
void
|
void
|
||||||
server_fill_environ(struct session *s, struct environ *env)
|
server_fill_environ(struct session *s, struct environ *env)
|
||||||
{
|
{
|
||||||
@ -353,10 +355,10 @@ server_set_identify(struct client *c)
|
|||||||
delay = options_get_number(&c->session->options, "display-panes-time");
|
delay = options_get_number(&c->session->options, "display-panes-time");
|
||||||
tv.tv_sec = delay / 1000;
|
tv.tv_sec = delay / 1000;
|
||||||
tv.tv_usec = (delay % 1000) * 1000L;
|
tv.tv_usec = (delay % 1000) * 1000L;
|
||||||
|
|
||||||
if (gettimeofday(&c->identify_timer, NULL) != 0)
|
evtimer_del(&c->identify_timer);
|
||||||
fatal("gettimeofday failed");
|
evtimer_set(&c->identify_timer, server_callback_identify, c);
|
||||||
timeradd(&c->identify_timer, &tv, &c->identify_timer);
|
evtimer_add(&c->identify_timer, &tv);
|
||||||
|
|
||||||
c->flags |= CLIENT_IDENTIFY;
|
c->flags |= CLIENT_IDENTIFY;
|
||||||
c->tty.flags |= (TTY_FREEZE|TTY_NOCURSOR);
|
c->tty.flags |= (TTY_FREEZE|TTY_NOCURSOR);
|
||||||
@ -373,6 +375,14 @@ server_clear_identify(struct client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
server_callback_identify(unused int fd, unused short events, void *data)
|
||||||
|
{
|
||||||
|
struct client *c = data;
|
||||||
|
|
||||||
|
server_clear_identify(c);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
server_update_event(struct client *c)
|
server_update_event(struct client *c)
|
||||||
{
|
{
|
||||||
|
19
status.c
19
status.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: status.c,v 1.126 2009-11-08 22:56:04 tcunha Exp $ */
|
/* $Id: status.c,v 1.127 2009-11-08 23:11:23 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -33,6 +33,7 @@ char *status_job(struct client *, char **);
|
|||||||
void status_job_callback(struct job *);
|
void status_job_callback(struct job *);
|
||||||
size_t status_width(struct winlink *);
|
size_t status_width(struct winlink *);
|
||||||
char *status_print(struct session *, struct winlink *, struct grid_cell *);
|
char *status_print(struct session *, struct winlink *, struct grid_cell *);
|
||||||
|
void status_message_callback(int, short, void *);
|
||||||
|
|
||||||
void status_prompt_add_history(struct client *);
|
void status_prompt_add_history(struct client *);
|
||||||
char *status_prompt_complete(const char *);
|
char *status_prompt_complete(const char *);
|
||||||
@ -579,10 +580,10 @@ status_message_set(struct client *c, const char *fmt, ...)
|
|||||||
delay = options_get_number(&c->session->options, "display-time");
|
delay = options_get_number(&c->session->options, "display-time");
|
||||||
tv.tv_sec = delay / 1000;
|
tv.tv_sec = delay / 1000;
|
||||||
tv.tv_usec = (delay % 1000) * 1000L;
|
tv.tv_usec = (delay % 1000) * 1000L;
|
||||||
|
|
||||||
if (gettimeofday(&c->message_timer, NULL) != 0)
|
evtimer_del(&c->message_timer);
|
||||||
fatal("gettimeofday failed");
|
evtimer_set(&c->message_timer, status_message_callback, c);
|
||||||
timeradd(&c->message_timer, &tv, &c->message_timer);
|
evtimer_add(&c->message_timer, &tv);
|
||||||
|
|
||||||
c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE);
|
c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE);
|
||||||
c->flags |= CLIENT_STATUS;
|
c->flags |= CLIENT_STATUS;
|
||||||
@ -603,6 +604,14 @@ status_message_clear(struct client *c)
|
|||||||
screen_reinit(&c->status);
|
screen_reinit(&c->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
status_message_callback(unused int fd, unused short event, void *data)
|
||||||
|
{
|
||||||
|
struct client *c = data;
|
||||||
|
|
||||||
|
status_message_clear(c);
|
||||||
|
}
|
||||||
|
|
||||||
/* Draw client message on status line of present else on last line. */
|
/* Draw client message on status line of present else on last line. */
|
||||||
int
|
int
|
||||||
status_message_redraw(struct client *c)
|
status_message_redraw(struct client *c)
|
||||||
|
6
tmux.h
6
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.503 2009-11-08 23:09:36 tcunha Exp $ */
|
/* $Id: tmux.h,v 1.504 2009-11-08 23:11:23 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -1073,10 +1073,10 @@ struct client {
|
|||||||
#define CLIENT_DEAD 0x200
|
#define CLIENT_DEAD 0x200
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
struct timeval identify_timer;
|
struct event identify_timer;
|
||||||
|
|
||||||
char *message_string;
|
char *message_string;
|
||||||
struct timeval message_timer;
|
struct event message_timer;
|
||||||
|
|
||||||
char *prompt_string;
|
char *prompt_string;
|
||||||
char *prompt_buffer;
|
char *prompt_buffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user