1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

Add active_window_ignore_refnum option

With active_window_ignore_refnum = ON, the current behavior
for the active_window key (meta-a by default) is preserved:
windows are cycled in the order of most recent activity,
highest activity first.

With active_window_ignore_refnum = OFF, the old behavior is
used: windows are cycled in the order of most recent
activity, where ties of equally high activity are broken by
refnums. Windows with lower refnums and equal activity will
be chosen first.

Submitted by Matt Sparks
Bug #667


git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@5096 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Jilles Tjoelker 2009-09-02 21:22:37 +00:00 committed by jilles
parent cb68d5f4e6
commit 178cd0acfb

View File

@ -24,6 +24,7 @@
#include "commands.h" #include "commands.h"
#include "misc.h" #include "misc.h"
#include "servers.h" #include "servers.h"
#include "settings.h"
#include "levels.h" #include "levels.h"
@ -244,16 +245,23 @@ static void cmd_window_refnum(const char *data)
window_set_active(window); window_set_active(window);
} }
/* return the first window number with the highest activity */ /**
static WINDOW_REC *window_highest_activity(WINDOW_REC *window) * return the window with the highest activity
*
* If ignore_refnum is true, the most recently active window with the highest
* activity will be returned. If ignore_refnum is false, the refnum will be used
* to break ties between windows with equally high activity.
*/
static WINDOW_REC *window_highest_activity(WINDOW_REC *window,
int ignore_refnum)
{ {
WINDOW_REC *rec, *max_win; WINDOW_REC *rec, *max_win;
GSList *tmp; GSList *tmp;
int max_act, through; int max_act, max_ref, through;
g_return_val_if_fail(window != NULL, NULL); g_return_val_if_fail(window != NULL, NULL);
max_win = NULL; max_act = 0; through = FALSE; max_win = NULL; max_act = 0; max_ref = 0; through = FALSE;
tmp = g_slist_find(windows, window); tmp = g_slist_find(windows, window);
for (;; tmp = tmp->next) { for (;; tmp = tmp->next) {
@ -267,10 +275,22 @@ static WINDOW_REC *window_highest_activity(WINDOW_REC *window)
rec = tmp->data; rec = tmp->data;
if (rec->data_level > 0 && max_act < rec->data_level) { /* ignore refnum */
if (ignore_refnum &&
rec->data_level > 0 && max_act < rec->data_level) {
max_act = rec->data_level; max_act = rec->data_level;
max_win = rec; max_win = rec;
} }
/* windows with lower refnums break ties */
else if (!ignore_refnum &&
rec->data_level > 0 &&
(rec->data_level > max_act ||
(rec->data_level == max_act && rec->refnum < max_ref))) {
max_act = rec->data_level;
max_win = rec;
max_ref = rec->refnum;
}
} }
return max_win; return max_win;
@ -333,7 +353,8 @@ static void cmd_window_goto(const char *data)
return; return;
if (g_ascii_strcasecmp(target, "active") == 0) if (g_ascii_strcasecmp(target, "active") == 0)
window = window_highest_activity(active_win); window = window_highest_activity(active_win,
settings_get_bool("active_window_ignore_refnum"));
else { else {
window = window_find_name(target); window = window_find_name(target);
if (window == NULL && active_win->active_server != NULL) if (window == NULL && active_win->active_server != NULL)
@ -823,6 +844,8 @@ static void cmd_foreach_window(const char *data)
void window_commands_init(void) void window_commands_init(void)
{ {
settings_add_bool("lookandfeel", "active_window_ignore_refnum", TRUE);
command_bind("window", NULL, (SIGNAL_FUNC) cmd_window); command_bind("window", NULL, (SIGNAL_FUNC) cmd_window);
command_bind("window new", NULL, (SIGNAL_FUNC) cmd_window_new); command_bind("window new", NULL, (SIGNAL_FUNC) cmd_window_new);
command_bind("window close", NULL, (SIGNAL_FUNC) cmd_window_close); command_bind("window close", NULL, (SIGNAL_FUNC) cmd_window_close);