Save last user-selected window to switch back to from M-a

weechat-hashes
C. McEnroe 2020-04-19 21:13:02 -04:00
parent 98cbb44c0d
commit 2f5ff45db0
1 changed files with 6 additions and 7 deletions

13
ui.c
View File

@ -102,6 +102,7 @@ static struct {
uint len; uint len;
uint show; uint show;
uint swap; uint swap;
uint user;
} windows; } windows;
static uint windowPush(struct Window *window) { static uint windowPush(struct Window *window) {
@ -825,6 +826,7 @@ static void windowShow(uint num) {
touchwin(windows.ptrs[num]->pad); touchwin(windows.ptrs[num]->pad);
windows.swap = windows.show; windows.swap = windows.show;
windows.show = num; windows.show = num;
windows.user = num;
mark(windows.ptrs[windows.swap]); mark(windows.ptrs[windows.swap]);
unmark(windows.ptrs[windows.show]); unmark(windows.ptrs[windows.show]);
inputUpdate(); inputUpdate();
@ -877,10 +879,6 @@ static void toggleIgnore(struct Window *window) {
} }
static void showAuto(void) { static void showAuto(void) {
static uint swap;
if (windows.swap != swap) {
swap = windows.show;
}
uint minHot = UINT_MAX, numHot; uint minHot = UINT_MAX, numHot;
uint minWarm = UINT_MAX, numWarm; uint minWarm = UINT_MAX, numWarm;
for (uint num = 0; num < windows.len; ++num) { for (uint num = 0; num < windows.len; ++num) {
@ -896,14 +894,15 @@ static void showAuto(void) {
numWarm = num; numWarm = num;
} }
} }
uint user = windows.user;
if (minHot < UINT_MAX) { if (minHot < UINT_MAX) {
windowShow(numHot); windowShow(numHot);
windows.swap = swap; windows.user = user;
} else if (minWarm < UINT_MAX) { } else if (minWarm < UINT_MAX) {
windowShow(numWarm); windowShow(numWarm);
windows.swap = swap; windows.user = user;
} else { } else {
windowShow(windows.swap); windowShow(user);
} }
} }