Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2017-05-11 10:01:10 +01:00
commit def8f852e3
3 changed files with 43 additions and 25 deletions

View File

@ -129,9 +129,8 @@ static void
cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m) cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m)
{ {
struct winlink *wl; struct winlink *wl;
struct window_pane *wp; struct window_pane *loop, *wp_x, *wp_y;
int found; u_int y, ly, x, lx, sx, sy, ex, ey;
u_int y, ly;
wl = cmd_mouse_window(m, NULL); wl = cmd_mouse_window(m, NULL);
if (wl == NULL) { if (wl == NULL) {
@ -139,37 +138,48 @@ cmd_resize_pane_mouse_update(struct client *c, struct mouse_event *m)
return; return;
} }
y = m->y; y = m->y; x = m->x;
if (m->statusat == 0 && y > 0) if (m->statusat == 0 && y > 0)
y--; y--;
else if (m->statusat > 0 && y >= (u_int)m->statusat) else if (m->statusat > 0 && y >= (u_int)m->statusat)
y = m->statusat - 1; y = m->statusat - 1;
ly = m->ly; ly = m->ly; lx = m->lx;
if (m->statusat == 0 && ly > 0) if (m->statusat == 0 && ly > 0)
ly--; ly--;
else if (m->statusat > 0 && ly >= (u_int)m->statusat) else if (m->statusat > 0 && ly >= (u_int)m->statusat)
ly = m->statusat - 1; ly = m->statusat - 1;
found = 0; wp_x = wp_y = NULL;
TAILQ_FOREACH(wp, &wl->window->panes, entry) { TAILQ_FOREACH(loop, &wl->window->panes, entry) {
if (!window_pane_visible(wp)) if (!window_pane_visible(loop))
continue; continue;
if (wp->xoff + wp->sx == m->lx && sx = loop->xoff;
wp->yoff <= 1 + ly && if (sx != 0)
wp->yoff + wp->sy >= ly) { sx--;
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, m->x - m->lx, 0); ex = loop->xoff + loop->sx;
found = 1;
} sy = loop->yoff;
if (wp->yoff + wp->sy == ly && if (sy != 0)
wp->xoff <= 1 + m->lx && sy--;
wp->xoff + wp->sx >= m->lx) { ey = loop->yoff + loop->sy;
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, y - ly, 0);
found = 1; if ((lx == sx || lx == ex) &&
} (ly >= sy && ly <= ey) &&
(wp_x == NULL || loop->sy > wp_x->sy))
wp_x = loop;
if ((ly == sy || ly == ey) &&
(lx >= sx && lx <= ex) &&
(wp_y == NULL || loop->sx > wp_y->sx))
wp_y = loop;
} }
if (found) if (wp_x == NULL && wp_y == NULL) {
server_redraw_window(wl->window);
else
c->tty.mouse_drag_update = NULL; c->tty.mouse_drag_update = NULL;
return;
}
if (wp_x != NULL)
layout_resize_pane(wp_x, LAYOUT_LEFTRIGHT, x - lx, 0);
if (wp_y != NULL)
layout_resize_pane(wp_y, LAYOUT_TOPBOTTOM, y - ly, 0);
server_redraw_window(wl->window);
} }

View File

@ -208,9 +208,15 @@ environ_push(struct environ *env)
/* Log the environment. */ /* Log the environment. */
void void
environ_log(struct environ *env, const char *prefix) environ_log(struct environ *env, const char *fmt, ...)
{ {
struct environ_entry *envent; struct environ_entry *envent;
va_list ap;
char *prefix;
va_start(ap, fmt);
vasprintf(&prefix, fmt, ap);
va_end(ap);
RB_FOREACH(envent, environ, env) { RB_FOREACH(envent, environ, env) {
if (envent->value != NULL && *envent->name != '\0') { if (envent->value != NULL && *envent->name != '\0') {
@ -218,6 +224,8 @@ environ_log(struct environ *env, const char *prefix)
envent->value); envent->value);
} }
} }
free(prefix);
} }
/* Create initial environment for new child. */ /* Create initial environment for new child. */

2
tmux.h
View File

@ -1625,7 +1625,7 @@ void environ_put(struct environ *, const char *);
void environ_unset(struct environ *, const char *); void environ_unset(struct environ *, const char *);
void environ_update(struct options *, struct environ *, struct environ *); void environ_update(struct options *, struct environ *, struct environ *);
void environ_push(struct environ *); void environ_push(struct environ *);
void environ_log(struct environ *, const char *); void printflike(2, 3) environ_log(struct environ *, const char *, ...);
struct environ *environ_for_session(struct session *, int); struct environ *environ_for_session(struct session *, int);
/* tty.c */ /* tty.c */