summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authornicm <nicm>2019-03-07 20:24:21 +0000
committernicm <nicm>2019-03-07 20:24:21 +0000
commitf98c66ece81953c777cd332c6bd29d707b1685e5 (patch)
treeb84b2b0bcefcc9e1f2e082234b46f5b6688e34ae /window.c
parent3c24bc5617bfdf90f94cc088f3769397c7569649 (diff)
Add a separate mode struct for the active window mode if any.
Diffstat (limited to 'window.c')
-rw-r--r--window.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/window.c b/window.c
index 673cd84f..366df797 100644
--- a/window.c
+++ b/window.c
@@ -811,7 +811,6 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
wp->event = NULL;
wp->mode = NULL;
- wp->modeprefix = 1;
wp->layout_cell = NULL;
@@ -1054,8 +1053,8 @@ window_pane_resize(struct window_pane *wp, u_int sx, u_int sy)
wp->sy = sy;
screen_resize(&wp->base, sx, sy, wp->saved_grid == NULL);
- if (wp->mode != NULL)
- wp->mode->resize(wp, sx, sy);
+ if (wp->mode != NULL && wp->mode->mode->resize != NULL)
+ wp->mode->mode->resize(wp->mode, sx, sy);
wp->flags |= PANE_RESIZE;
}
@@ -1222,13 +1221,17 @@ window_pane_set_mode(struct window_pane *wp, const struct window_mode *mode,
if (wp->mode != NULL)
return (1);
- wp->mode = mode;
+
+ wp->mode = xcalloc(1, sizeof *wp->mode);
+ wp->mode->wp = wp;
+ wp->mode->mode = mode;
+ wp->mode->prefix = 1;
wp->modelast = time(NULL);
evtimer_set(&wp->modetimer, window_pane_mode_timer, wp);
evtimer_add(&wp->modetimer, &tv);
- if ((s = wp->mode->init(wp, fs, args)) != NULL)
+ if ((s = wp->mode->mode->init(wp->mode, fs, args)) != NULL)
wp->screen = s;
wp->flags |= (PANE_REDRAW|PANE_CHANGED);
@@ -1245,9 +1248,9 @@ window_pane_reset_mode(struct window_pane *wp)
evtimer_del(&wp->modetimer);
- wp->mode->free(wp);
+ wp->mode->mode->free(wp->mode);
+ free(wp->mode);
wp->mode = NULL;
- wp->modeprefix = 1;
wp->screen = &wp->base;
wp->flags |= (PANE_REDRAW|PANE_CHANGED);
@@ -1260,15 +1263,16 @@ void
window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
struct winlink *wl, key_code key, struct mouse_event *m)
{
- struct window_pane *wp2;
+ struct window_mode_entry *wme = wp->mode;
+ struct window_pane *wp2;
if (KEYC_IS_MOUSE(key) && m == NULL)
return;
- if (wp->mode != NULL) {
+ if (wme != NULL) {
wp->modelast = time(NULL);
- if (wp->mode->key != NULL)
- wp->mode->key(wp, c, s, wl, (key & ~KEYC_XTERM), m);
+ if (wme->mode->key != NULL)
+ wme->mode->key(wme, c, s, wl, (key & ~KEYC_XTERM), m);
return;
}