diff options
author | Timo Sirainen <cras@irssi.org> | 2002-02-22 13:04:07 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-02-22 13:04:07 +0000 |
commit | 4d96d7e4df69b54259c848cbf20958dda39988d6 (patch) | |
tree | f8bd03fdc198d7ff725476c94367342174616ab9 | |
parent | dd65d300b02d6e273a6fc515f1f768775b398acd (diff) | |
download | irssi-4d96d7e4df69b54259c848cbf20958dda39988d6.zip |
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
-rw-r--r-- | src/fe-common/core/fe-windows.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/fe-common/core/fe-windows.c b/src/fe-common/core/fe-windows.c index 985d05c4..fe76427b 100644 --- a/src/fe-common/core/fe-windows.c +++ b/src/fe-common/core/fe-windows.c @@ -238,24 +238,26 @@ char *window_get_active_name(WINDOW_REC *window) 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 *match; 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) { WINDOW_REC *rec = tmp->data; - if ((server == NULL || rec->active_server == server) && - (rec->level & level)) { - if (server == NULL || rec->active_server == server) - return rec; - match = rec; - } + if (WINDOW_LEVEL_MATCH(rec, server, level)) + return rec; } - return match; + return NULL; } WINDOW_REC *window_find_closest(void *server, const char *name, int level) |