mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Do pane resize ioctls once at the end of the server loop rather than
immediately.
This commit is contained in:
		
							
								
								
									
										25
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								window.c
									
									
									
									
									
								
							@@ -314,20 +314,32 @@ window_create(const char *name, const char *cmd, const char *shell,
 | 
			
		||||
{
 | 
			
		||||
	struct window		*w;
 | 
			
		||||
	struct window_pane	*wp;
 | 
			
		||||
	const char		*prefix;
 | 
			
		||||
	char			*cmd1;
 | 
			
		||||
 | 
			
		||||
	w = window_create1(sx, sy);
 | 
			
		||||
	wp = window_add_pane(w, hlimit);
 | 
			
		||||
	layout_init(w);
 | 
			
		||||
	if (window_pane_spawn(wp, cmd, shell, cwd, env, tio, cause) != 0) {
 | 
			
		||||
 | 
			
		||||
	if (*cmd != '\0') {
 | 
			
		||||
		prefix = options_get_string(&w->options, "command-prefix");
 | 
			
		||||
		xasprintf(&cmd1, "%s%s", prefix, cmd);
 | 
			
		||||
	} else
 | 
			
		||||
		cmd1 = xstrdup("");
 | 
			
		||||
	if (window_pane_spawn(wp, cmd1, shell, cwd, env, tio, cause) != 0) {
 | 
			
		||||
		window_destroy(w);
 | 
			
		||||
		free(cmd1);
 | 
			
		||||
		return (NULL);
 | 
			
		||||
	}
 | 
			
		||||
	free(cmd1);
 | 
			
		||||
 | 
			
		||||
	w->active = TAILQ_FIRST(&w->panes);
 | 
			
		||||
	if (name != NULL) {
 | 
			
		||||
		w->name = xstrdup(name);
 | 
			
		||||
		options_set_number(&w->options, "automatic-rename", 0);
 | 
			
		||||
	} else
 | 
			
		||||
		w->name = default_window_name(w);
 | 
			
		||||
 | 
			
		||||
	return (w);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -704,6 +716,8 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
 | 
			
		||||
		wp->cwd = xstrdup(cwd);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log_debug("spawn: %s -- %s", wp->shell, wp->cmd);
 | 
			
		||||
 | 
			
		||||
	memset(&ws, 0, sizeof ws);
 | 
			
		||||
	ws.ws_col = screen_size_x(&wp->base);
 | 
			
		||||
	ws.ws_row = screen_size_y(&wp->base);
 | 
			
		||||
@@ -840,23 +854,14 @@ window_pane_error_callback(
 | 
			
		||||
void
 | 
			
		||||
window_pane_resize(struct window_pane *wp, u_int sx, u_int sy)
 | 
			
		||||
{
 | 
			
		||||
	struct winsize	ws;
 | 
			
		||||
 | 
			
		||||
	if (sx == wp->sx && sy == wp->sy)
 | 
			
		||||
		return;
 | 
			
		||||
	wp->sx = sx;
 | 
			
		||||
	wp->sy = sy;
 | 
			
		||||
 | 
			
		||||
	memset(&ws, 0, sizeof ws);
 | 
			
		||||
	ws.ws_col = sx;
 | 
			
		||||
	ws.ws_row = sy;
 | 
			
		||||
 | 
			
		||||
	screen_resize(&wp->base, sx, sy, wp->saved_grid == NULL);
 | 
			
		||||
	if (wp->mode != NULL)
 | 
			
		||||
		wp->mode->resize(wp, sx, sy);
 | 
			
		||||
 | 
			
		||||
	if (wp->fd != -1 && ioctl(wp->fd, TIOCSWINSZ, &ws) == -1)
 | 
			
		||||
		fatal("ioctl failed");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user