aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-04-07 17:54:12 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-04-08 12:28:59 +0200
commitdf84a1c16844c0eaebe12dd0e606d5b2c478c478 (patch)
tree63b46b172a8d1153a559b232db49d03f5eb132b4 /vis.c
parenta2abb7d9c8df32f65f907452f292784d569e8e88 (diff)
downloadvis-df84a1c16844c0eaebe12dd0e606d5b2c478c478.tar.gz
vis-df84a1c16844c0eaebe12dd0e606d5b2c478c478.tar.xz
vis: cleanup window focusing code
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/vis.c b/vis.c
index d2d0c2f..e1f14ff 100644
--- a/vis.c
+++ b/vis.c
@@ -226,24 +226,29 @@ bool vis_window_split(Win *original) {
return true;
}
+void vis_window_focus(Win *win) {
+ if (!win)
+ return;
+ Vis *vis = win->vis;
+ vis->win = win;
+ vis->ui->window_focus(win->ui);
+}
+
void vis_window_next(Vis *vis) {
Win *sel = vis->win;
if (!sel)
return;
- vis->win = vis->win->next;
- if (!vis->win)
- vis->win = vis->windows;
- vis->ui->window_focus(vis->win->ui);
+ vis_window_focus(sel->next ? sel->next : vis->windows);
}
void vis_window_prev(Vis *vis) {
Win *sel = vis->win;
if (!sel)
return;
- vis->win = vis->win->prev;
- if (!vis->win)
- for (vis->win = vis->windows; vis->win->next; vis->win = vis->win->next);
- vis->ui->window_focus(vis->win->ui);
+ sel = sel->prev;
+ if (!sel)
+ for (sel = vis->windows; sel->next; sel = sel->next);
+ vis_window_focus(sel);
}
void vis_draw(Vis *vis) {