1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Window level matching code was a bit messy. Also, now the active window is

preferred if there's multiple matches by the same level.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2525 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-02-22 13:04:07 +00:00 committed by cras
parent dd65d300b0
commit 4d96d7e4df

View File

@ -238,24 +238,26 @@ char *window_get_active_name(WINDOW_REC *window)
return window->name; return window->name;
} }
#define WINDOW_LEVEL_MATCH(window, server, level) \
(((window)->level & level) && \
(server == NULL || (window)->active_server == server))
WINDOW_REC *window_find_level(void *server, int level) WINDOW_REC *window_find_level(void *server, int level)
{ {
WINDOW_REC *match;
GSList *tmp; GSList *tmp;
match = NULL; /* prefer active window if possible */
if (WINDOW_LEVEL_MATCH(active_win, server, level))
return active_win;
for (tmp = windows; tmp != NULL; tmp = tmp->next) { for (tmp = windows; tmp != NULL; tmp = tmp->next) {
WINDOW_REC *rec = tmp->data; WINDOW_REC *rec = tmp->data;
if ((server == NULL || rec->active_server == server) && if (WINDOW_LEVEL_MATCH(rec, server, level))
(rec->level & level)) { return rec;
if (server == NULL || rec->active_server == server)
return rec;
match = rec;
}
} }
return match; return NULL;
} }
WINDOW_REC *window_find_closest(void *server, const char *name, int level) WINDOW_REC *window_find_closest(void *server, const char *name, int level)