Update context switch logic

This commit is contained in:
Arun Prakash Jana 2019-03-13 22:44:11 +05:30
parent 573c61f330
commit c8f080f0b5
No known key found for this signature in database
GPG Key ID: A75979F35C080412
1 changed files with 21 additions and 19 deletions

View File

@ -3176,11 +3176,11 @@ nochange:
r = cfg.curctx; r = cfg.curctx;
if (fd == '>' || fd == '.') if (fd == '>' || fd == '.')
do do
(r == CTX_MAX - 1) ? (r = 0) : ++r; r = (r + 1) & ~CTX_MAX;
while (!g_ctx[r].c_cfg.ctxactive); while (!g_ctx[r].c_cfg.ctxactive);
else else
do do
(r == 0) ? (r = CTX_MAX - 1) : --r; r = (r + (CTX_MAX - 1)) & (CTX_MAX - 1);
while (!g_ctx[r].c_cfg.ctxactive); // fallthrough while (!g_ctx[r].c_cfg.ctxactive); // fallthrough
fd = '1' + r; // fallthrough fd = '1' + r; // fallthrough
case '1': // fallthrough case '1': // fallthrough
@ -3919,26 +3919,28 @@ nochange:
presel = MSGWAIT; presel = MSGWAIT;
goto nochange; goto nochange;
} }
} // fallthrough }
dentfree(dents);
return;
case SEL_QUITCTX: case SEL_QUITCTX:
if (sel == SEL_QUITCTX) { fd = cfg.curctx;
r = cfg.curctx; for (r = (fd + 1) & ~CTX_MAX;
for (fd = 1; fd < CTX_MAX; ++fd) { (r != fd) && !g_ctx[r].c_cfg.ctxactive;
(r == CTX_MAX - 1) ? (r = 0) : ++r; r = ((r + 1) & ~CTX_MAX));
if (g_ctx[r].c_cfg.ctxactive) {
g_ctx[cfg.curctx].c_cfg.ctxactive = 0;
/* Switch to next active context */ if (r != fd) {
path = g_ctx[r].c_path; g_ctx[fd].c_cfg.ctxactive = 0;
lastdir = g_ctx[r].c_last;
lastname = g_ctx[r].c_name;
cfg = g_ctx[r].c_cfg;
cfg.curctx = r; /* Switch to next active context */
setdirwatch(); path = g_ctx[r].c_path;
goto begin; lastdir = g_ctx[r].c_last;
} lastname = g_ctx[r].c_name;
} cfg = g_ctx[r].c_cfg;
cfg.curctx = r;
setdirwatch();
goto begin;
} }
dentfree(dents); dentfree(dents);