summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client.c25
-rw-r--r--server-msg.c38
-rw-r--r--tmux.h11
-rw-r--r--tty.c21
4 files changed, 33 insertions, 62 deletions
diff --git a/client.c b/client.c
index ee3bba50..7ef61106 100644
--- a/client.c
+++ b/client.c
@@ -34,7 +34,6 @@
#include "tmux.h"
void client_send_environ(struct client_ctx *);
-void client_handle_winch(struct client_ctx *);
int
client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags)
@@ -100,8 +99,6 @@ server_started:
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
fatal("ioctl(TIOCGWINSZ)");
data.flags = flags;
- data.sx = ws.ws_col;
- data.sy = ws.ws_row;
if (getcwd(data.cwd, sizeof data.cwd) == NULL)
*data.cwd = '\0';
@@ -169,8 +166,10 @@ client_main(struct client_ctx *cctx)
waitpid(WAIT_ANY, NULL, WNOHANG);
sigchld = 0;
}
- if (sigwinch)
- client_handle_winch(cctx);
+ if (sigwinch) {
+ client_write_server(cctx, MSG_RESIZE, NULL, 0);
+ sigwinch = 0;
+ }
if (sigcont) {
siginit();
client_write_server(cctx, MSG_WAKEUP, NULL, 0);
@@ -238,22 +237,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
client_msg_dispatch(struct client_ctx *cctx)
{
diff --git a/server-msg.c b/server-msg.c
index cf0f346c..7f88e262 100644
--- a/server-msg.c
+++ b/server-msg.c
@@ -17,6 +17,7 @@
*/
#include <sys/types.h>
+#include <sys/ioctl.h>
#include <errno.h>
#include <stdlib.h>
@@ -28,7 +29,6 @@
void server_msg_command(struct client *, struct msg_command_data *);
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_print(struct cmd_ctx *, const char *, ...);
@@ -40,7 +40,6 @@ server_msg_dispatch(struct client *c)
struct imsg imsg;
struct msg_command_data commanddata;
struct msg_identify_data identifydata;
- struct msg_resize_data resizedata;
struct msg_unlock_data unlockdata;
struct msg_environ_data environdata;
ssize_t n, datalen;
@@ -81,11 +80,12 @@ server_msg_dispatch(struct client *c)
server_msg_identify(c, &identifydata, imsg.fd);
break;
case MSG_RESIZE:
- if (datalen != sizeof resizedata)
+ if (datalen != 0)
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;
case MSG_EXITING:
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)
c->tty.term_flags |= TERM_HASDEFAULTS;
- 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;
+ tty_resize(&c->tty);
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);
-}
diff --git a/tmux.h b/tmux.h
index bdaf5f6e..6325bca2 100644
--- a/tmux.h
+++ b/tmux.h
@@ -19,7 +19,7 @@
#ifndef TMUX_H
#define TMUX_H
-#define PROTOCOL_VERSION 2
+#define PROTOCOL_VERSION 3
#include <sys/param.h>
#include <sys/time.h>
@@ -337,14 +337,6 @@ struct msg_identify_data {
#define IDENTIFY_88COLOURS 0x4
#define IDENTIFY_HASDEFAULTS 0x8
int flags;
-
- u_int sx;
- u_int sy;
-};
-
-struct msg_resize_data {
- u_int sx;
- u_int sy;
};
struct msg_unlock_data {
@@ -1199,6 +1191,7 @@ void tty_puts(struct tty *, const char *);
void tty_putc(struct tty *, u_char);
void tty_pututf8(struct tty *, const struct grid_utf8 *);
void tty_init(struct tty *, int, char *);
+void tty_resize(struct tty *);
void tty_start_tty(struct tty *);
void tty_stop_tty(struct tty *);
void tty_detect_utf8(struct tty *);
diff --git a/tty.c b/tty.c
index 574e9a7b..12535f94 100644
--- a/tty.c
+++ b/tty.c
@@ -73,6 +73,27 @@ tty_init(struct tty *tty, int fd, char *term)
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
tty_open(struct tty *tty, const char *overrides, char **cause)
{