mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 18:38:48 +00:00
Sync OpenBSD patchset 346:
Trim some code by moving the ioctl(TIOCGWINSZ) after SIGWINCH from the client into the server. This is another (the second of four) protocol version changes coming this morning, so again the server should be killed before upgrading.
This commit is contained in:
parent
acedc2dcf2
commit
2acf349d4e
27
client.c
27
client.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: client.c,v 1.72 2009-09-23 14:39:30 tcunha Exp $ */
|
/* $Id: client.c,v 1.73 2009-09-23 14:44:02 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -34,7 +34,6 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
void client_send_environ(struct client_ctx *);
|
void client_send_environ(struct client_ctx *);
|
||||||
void client_handle_winch(struct client_ctx *);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags)
|
client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags)
|
||||||
@ -104,8 +103,6 @@ server_started:
|
|||||||
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
|
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
|
||||||
fatal("ioctl(TIOCGWINSZ)");
|
fatal("ioctl(TIOCGWINSZ)");
|
||||||
data.flags = flags;
|
data.flags = flags;
|
||||||
data.sx = ws.ws_col;
|
|
||||||
data.sy = ws.ws_row;
|
|
||||||
|
|
||||||
if (getcwd(data.cwd, sizeof data.cwd) == NULL)
|
if (getcwd(data.cwd, sizeof data.cwd) == NULL)
|
||||||
*data.cwd = '\0';
|
*data.cwd = '\0';
|
||||||
@ -173,8 +170,10 @@ client_main(struct client_ctx *cctx)
|
|||||||
waitpid(WAIT_ANY, NULL, WNOHANG);
|
waitpid(WAIT_ANY, NULL, WNOHANG);
|
||||||
sigchld = 0;
|
sigchld = 0;
|
||||||
}
|
}
|
||||||
if (sigwinch)
|
if (sigwinch) {
|
||||||
client_handle_winch(cctx);
|
client_write_server(cctx, MSG_RESIZE, NULL, 0);
|
||||||
|
sigwinch = 0;
|
||||||
|
}
|
||||||
if (sigcont) {
|
if (sigcont) {
|
||||||
siginit();
|
siginit();
|
||||||
client_write_server(cctx, MSG_WAKEUP, NULL, 0);
|
client_write_server(cctx, MSG_WAKEUP, NULL, 0);
|
||||||
@ -242,22 +241,6 @@ out:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
client_handle_winch(struct client_ctx *cctx)
|
|
||||||
{
|
|
||||||
struct msg_resize_data data;
|
|
||||||
struct winsize ws;
|
|
||||||
|
|
||||||
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
|
|
||||||
fatal("ioctl failed");
|
|
||||||
|
|
||||||
data.sx = ws.ws_col;
|
|
||||||
data.sy = ws.ws_row;
|
|
||||||
client_write_server(cctx, MSG_RESIZE, &data, sizeof data);
|
|
||||||
|
|
||||||
sigwinch = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
client_msg_dispatch(struct client_ctx *cctx)
|
client_msg_dispatch(struct client_ctx *cctx)
|
||||||
{
|
{
|
||||||
|
40
server-msg.c
40
server-msg.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-msg.c,v 1.85 2009-09-23 14:39:30 tcunha Exp $ */
|
/* $Id: server-msg.c,v 1.86 2009-09-23 14:44:02 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -28,7 +29,6 @@
|
|||||||
|
|
||||||
void server_msg_command(struct client *, struct msg_command_data *);
|
void server_msg_command(struct client *, struct msg_command_data *);
|
||||||
void server_msg_identify(struct client *, struct msg_identify_data *, int);
|
void server_msg_identify(struct client *, struct msg_identify_data *, int);
|
||||||
void server_msg_resize(struct client *, struct msg_resize_data *);
|
|
||||||
|
|
||||||
void printflike2 server_msg_command_error(struct cmd_ctx *, const char *, ...);
|
void printflike2 server_msg_command_error(struct cmd_ctx *, const char *, ...);
|
||||||
void printflike2 server_msg_command_print(struct cmd_ctx *, const char *, ...);
|
void printflike2 server_msg_command_print(struct cmd_ctx *, const char *, ...);
|
||||||
@ -40,7 +40,6 @@ server_msg_dispatch(struct client *c)
|
|||||||
struct imsg imsg;
|
struct imsg imsg;
|
||||||
struct msg_command_data commanddata;
|
struct msg_command_data commanddata;
|
||||||
struct msg_identify_data identifydata;
|
struct msg_identify_data identifydata;
|
||||||
struct msg_resize_data resizedata;
|
|
||||||
struct msg_unlock_data unlockdata;
|
struct msg_unlock_data unlockdata;
|
||||||
struct msg_environ_data environdata;
|
struct msg_environ_data environdata;
|
||||||
ssize_t n, datalen;
|
ssize_t n, datalen;
|
||||||
@ -81,11 +80,12 @@ server_msg_dispatch(struct client *c)
|
|||||||
server_msg_identify(c, &identifydata, imsg.fd);
|
server_msg_identify(c, &identifydata, imsg.fd);
|
||||||
break;
|
break;
|
||||||
case MSG_RESIZE:
|
case MSG_RESIZE:
|
||||||
if (datalen != sizeof resizedata)
|
if (datalen != 0)
|
||||||
fatalx("bad MSG_RESIZE size");
|
fatalx("bad MSG_RESIZE size");
|
||||||
memcpy(&resizedata, imsg.data, sizeof resizedata);
|
|
||||||
|
|
||||||
server_msg_resize(c, &resizedata);
|
tty_resize(&c->tty);
|
||||||
|
recalculate_sizes();
|
||||||
|
server_redraw_client(c);
|
||||||
break;
|
break;
|
||||||
case MSG_EXITING:
|
case MSG_EXITING:
|
||||||
if (datalen != 0)
|
if (datalen != 0)
|
||||||
@ -261,33 +261,7 @@ server_msg_identify(struct client *c, struct msg_identify_data *data, int fd)
|
|||||||
if (data->flags & IDENTIFY_HASDEFAULTS)
|
if (data->flags & IDENTIFY_HASDEFAULTS)
|
||||||
c->tty.term_flags |= TERM_HASDEFAULTS;
|
c->tty.term_flags |= TERM_HASDEFAULTS;
|
||||||
|
|
||||||
c->tty.sx = data->sx;
|
tty_resize(&c->tty);
|
||||||
if (c->tty.sx == 0)
|
|
||||||
c->tty.sx = 80;
|
|
||||||
c->tty.sy = data->sy;
|
|
||||||
if (c->tty.sy == 0)
|
|
||||||
c->tty.sy = 24;
|
|
||||||
|
|
||||||
c->flags |= CLIENT_TERMINAL;
|
c->flags |= CLIENT_TERMINAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
server_msg_resize(struct client *c, struct msg_resize_data *data)
|
|
||||||
{
|
|
||||||
c->tty.sx = data->sx;
|
|
||||||
if (c->tty.sx == 0)
|
|
||||||
c->tty.sx = 80;
|
|
||||||
c->tty.sy = data->sy;
|
|
||||||
if (c->tty.sy == 0)
|
|
||||||
c->tty.sy = 24;
|
|
||||||
|
|
||||||
c->tty.cx = UINT_MAX;
|
|
||||||
c->tty.cy = UINT_MAX;
|
|
||||||
c->tty.rupper = UINT_MAX;
|
|
||||||
c->tty.rlower = UINT_MAX;
|
|
||||||
|
|
||||||
recalculate_sizes();
|
|
||||||
|
|
||||||
/* Always redraw this client. */
|
|
||||||
server_redraw_client(c);
|
|
||||||
}
|
|
||||||
|
13
tmux.h
13
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.451 2009-09-23 14:39:30 tcunha Exp $ */
|
/* $Id: tmux.h,v 1.452 2009-09-23 14:44:02 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#define PROTOCOL_VERSION 2
|
#define PROTOCOL_VERSION 3
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -335,14 +335,6 @@ struct msg_identify_data {
|
|||||||
#define IDENTIFY_88COLOURS 0x4
|
#define IDENTIFY_88COLOURS 0x4
|
||||||
#define IDENTIFY_HASDEFAULTS 0x8
|
#define IDENTIFY_HASDEFAULTS 0x8
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
u_int sx;
|
|
||||||
u_int sy;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct msg_resize_data {
|
|
||||||
u_int sx;
|
|
||||||
u_int sy;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct msg_unlock_data {
|
struct msg_unlock_data {
|
||||||
@ -1197,6 +1189,7 @@ void tty_puts(struct tty *, const char *);
|
|||||||
void tty_putc(struct tty *, u_char);
|
void tty_putc(struct tty *, u_char);
|
||||||
void tty_pututf8(struct tty *, const struct grid_utf8 *);
|
void tty_pututf8(struct tty *, const struct grid_utf8 *);
|
||||||
void tty_init(struct tty *, int, char *);
|
void tty_init(struct tty *, int, char *);
|
||||||
|
void tty_resize(struct tty *);
|
||||||
void tty_start_tty(struct tty *);
|
void tty_start_tty(struct tty *);
|
||||||
void tty_stop_tty(struct tty *);
|
void tty_stop_tty(struct tty *);
|
||||||
void tty_detect_utf8(struct tty *);
|
void tty_detect_utf8(struct tty *);
|
||||||
|
23
tty.c
23
tty.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tty.c,v 1.134 2009-09-23 14:39:30 tcunha Exp $ */
|
/* $Id: tty.c,v 1.135 2009-09-23 14:44:02 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -73,6 +73,27 @@ tty_init(struct tty *tty, int fd, char *term)
|
|||||||
tty->term_flags = 0;
|
tty->term_flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tty_resize(struct tty *tty)
|
||||||
|
{
|
||||||
|
struct winsize ws;
|
||||||
|
|
||||||
|
if (ioctl(tty->fd, TIOCGWINSZ, &ws) != -1) {
|
||||||
|
tty->sx = ws.ws_col;
|
||||||
|
tty->sy = ws.ws_row;
|
||||||
|
}
|
||||||
|
if (tty->sx == 0)
|
||||||
|
tty->sx = 80;
|
||||||
|
if (tty->sy == 0)
|
||||||
|
tty->sy = 24;
|
||||||
|
|
||||||
|
tty->cx = UINT_MAX;
|
||||||
|
tty->cy = UINT_MAX;
|
||||||
|
|
||||||
|
tty->rupper = UINT_MAX;
|
||||||
|
tty->rlower = UINT_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
tty_open(struct tty *tty, const char *overrides, char **cause)
|
tty_open(struct tty *tty, const char *overrides, char **cause)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user