mirror of
https://github.com/tmux/tmux.git
synced 2025-09-03 14:27:09 +00:00
PatchSet 923
Date: 2011/06/05 11:53:05 Author: nicm Branch: HEAD Tag: (none) Log: Get rid of the layout string code which tries to walk through the layout hierarchy and instead just look at what panes are actually in the window.
This commit is contained in:
64
window.c
64
window.c
@ -1,4 +1,4 @@
|
||||
/* $Id: window.c,v 1.147 2011-04-18 22:03:55 nicm Exp $ */
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -353,21 +353,65 @@ window_set_active_pane(struct window *w, struct window_pane *wp)
|
||||
}
|
||||
}
|
||||
|
||||
struct window_pane *
|
||||
window_get_active_at(struct window *w, u_int x, u_int y)
|
||||
{
|
||||
struct window_pane *wp;
|
||||
|
||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||
if (!window_pane_visible(wp))
|
||||
continue;
|
||||
if (x < wp->xoff || x > wp->xoff + wp->sx)
|
||||
continue;
|
||||
if (y < wp->yoff || y > wp->yoff + wp->sy)
|
||||
continue;
|
||||
return (wp);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
void
|
||||
window_set_active_at(struct window *w, u_int x, u_int y)
|
||||
{
|
||||
struct window_pane *wp;
|
||||
|
||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||
if (wp == w->active || !window_pane_visible(wp))
|
||||
continue;
|
||||
if (x < wp->xoff || x >= wp->xoff + wp->sx)
|
||||
continue;
|
||||
if (y < wp->yoff || y >= wp->yoff + wp->sy)
|
||||
continue;
|
||||
wp = window_get_active_at(w, x, y);
|
||||
if (wp != NULL && wp != w->active)
|
||||
window_set_active_pane(w, wp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct window_pane *
|
||||
window_find_string(struct window *w, const char *s)
|
||||
{
|
||||
u_int x, y;
|
||||
|
||||
x = w->sx / 2;
|
||||
y = w->sy / 2;
|
||||
|
||||
if (strcasecmp(s, "top") == 0)
|
||||
y = 0;
|
||||
else if (strcasecmp(s, "bottom") == 0)
|
||||
y = w->sy - 1;
|
||||
else if (strcasecmp(s, "left") == 0)
|
||||
x = 0;
|
||||
else if (strcasecmp(s, "right") == 0)
|
||||
x = w->sx - 1;
|
||||
else if (strcasecmp(s, "top-left") == 0) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
} else if (strcasecmp(s, "top-right") == 0) {
|
||||
x = w->sx - 1;
|
||||
y = 0;
|
||||
} else if (strcasecmp(s, "bottom-left") == 0) {
|
||||
x = 0;
|
||||
y = w->sy - 1;
|
||||
} else if (strcasecmp(s, "bottom-right") == 0) {
|
||||
x = w->sx - 1;
|
||||
y = w->sy - 1;
|
||||
} else
|
||||
return (NULL);
|
||||
|
||||
return (window_get_active_at(w, x, y));
|
||||
}
|
||||
|
||||
struct window_pane *
|
||||
|
Reference in New Issue
Block a user