summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-01-01 14:57:55 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-01-01 14:57:55 +0000
commit219c83ae6ab83e546fe18bc697ef3a1ab3d12caa (patch)
tree95bd73fa98004609f0478c4a901e2486b5df5742 /src
parentacf60a729c81b226f7126a94d1c8092f29fec3ca (diff)
downloadirssi-219c83ae6ab83e546fe18bc697ef3a1ab3d12caa.zip
window_item_create(): when there's multiple choices where the window
item could be placed, the first window is now selected instead of the last accessed one of them (which most people think of as a random window). git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1040 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/fe-common/core/fe-windows.c20
-rw-r--r--src/fe-common/core/fe-windows.h2
-rw-r--r--src/fe-common/core/window-commands.c17
-rw-r--r--src/fe-common/core/window-items.c6
4 files changed, 26 insertions, 19 deletions
diff --git a/src/fe-common/core/fe-windows.c b/src/fe-common/core/fe-windows.c
index 8b10b9ac..5e1b785e 100644
--- a/src/fe-common/core/fe-windows.c
+++ b/src/fe-common/core/fe-windows.c
@@ -363,6 +363,26 @@ int windows_refnum_last(void)
return max;
}
+static int window_refnum_cmp(WINDOW_REC *w1, WINDOW_REC *w2)
+{
+ return w1->refnum < w2->refnum ? -1 : 1;
+}
+
+GSList *windows_get_sorted(void)
+{
+ GSList *tmp, *sorted;
+
+ sorted = NULL;
+ for (tmp = windows; tmp != NULL; tmp = tmp->next) {
+ WINDOW_REC *rec = tmp->data;
+
+ sorted = g_slist_insert_sorted(sorted, rec, (GCompareFunc)
+ window_refnum_cmp);
+ }
+
+ return sorted;
+}
+
static void sig_server_looking(SERVER_REC *server)
{
GSList *tmp;
diff --git a/src/fe-common/core/fe-windows.h b/src/fe-common/core/fe-windows.h
index 20bea596..f91e3364 100644
--- a/src/fe-common/core/fe-windows.h
+++ b/src/fe-common/core/fe-windows.h
@@ -68,6 +68,8 @@ int window_refnum_prev(int refnum, int wrap);
int window_refnum_next(int refnum, int wrap);
int windows_refnum_last(void);
+GSList *windows_get_sorted(void);
+
void windows_init(void);
void windows_deinit(void);
diff --git a/src/fe-common/core/window-commands.c b/src/fe-common/core/window-commands.c
index 462125a0..17595f5b 100644
--- a/src/fe-common/core/window-commands.c
+++ b/src/fe-common/core/window-commands.c
@@ -353,23 +353,6 @@ static void cmd_window_move(const char *data, SERVER_REC *server, WI_ITEM_REC *i
}
}
-static int windows_compare(WINDOW_REC *w1, WINDOW_REC *w2)
-{
- return w1->refnum < w2->refnum ? -1 : 1;
-}
-
-static GSList *windows_get_sorted(void)
-{
- GSList *tmp, *list;
-
- list = NULL;
- for (tmp = windows; tmp != NULL; tmp = tmp->next) {
- list = g_slist_insert_sorted(list, tmp->data, (GCompareFunc) windows_compare);
- }
-
- return list;
-}
-
/* SYNTAX: WINDOW LIST */
static void cmd_window_list(void)
{
diff --git a/src/fe-common/core/window-items.c b/src/fe-common/core/window-items.c
index 16686b59..3d820dda 100644
--- a/src/fe-common/core/window-items.c
+++ b/src/fe-common/core/window-items.c
@@ -238,7 +238,7 @@ static int waiting_channels_get(WINDOW_REC *window, const char *tag)
void window_item_create(WI_ITEM_REC *item, int automatic)
{
WINDOW_REC *window;
- GSList *tmp;
+ GSList *tmp, *sorted;
char *str;
int clear_waiting, reuse_unused_windows;
@@ -253,7 +253,8 @@ void window_item_create(WI_ITEM_REC *item, int automatic)
clear_waiting = TRUE;
window = NULL;
- for (tmp = windows; tmp != NULL; tmp = tmp->next) {
+ sorted = windows_get_sorted();
+ for (tmp = sorted; tmp != NULL; tmp = tmp->next) {
WINDOW_REC *rec = tmp->data;
if (reuse_unused_windows &&
@@ -274,6 +275,7 @@ void window_item_create(WI_ITEM_REC *item, int automatic)
}
}
}
+ g_slist_free(sorted);
g_free_not_null(str);
if (window == NULL && !settings_get_bool("autocreate_windows")) {