diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2014-02-07 17:07:45 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2014-02-07 17:07:45 +0100 |
commit | 43fb54f51d794f45dbcbb64d04639053c905977f (patch) | |
tree | ff184dfd38f50a0de8ba0aa70e84813f9c933baa | |
parent | bbd212c675d20ccd7fd3d1a6a511529f5f7e0d76 (diff) | |
download | weechat-43fb54f51d794f45dbcbb64d04639053c905977f.zip |
core: fix apply of layout when buffers that are not in layout are before some buffers in layout
Now when a layout is applied, the buffers in layout are inserted/sorted
first in the new list. Then the other buffers (not in layout) are added
after this loop, and then they are added after all layout buffers.
-rw-r--r-- | src/gui/gui-buffer.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index e5c72c7fd..6b85f9987 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -3347,12 +3347,47 @@ void gui_buffer_sort_by_layout_number () { struct t_gui_buffer *ptr_buffer, *ptr_next_buffer; + struct t_gui_buffer *extra_buffers, *last_extra_buffer; ptr_buffer = gui_buffers; gui_buffers = NULL; last_gui_buffer = NULL; + /* list with buffers that are NOT in layout (layout_number == 0) */ + extra_buffers = NULL; + last_extra_buffer = NULL; + + while (ptr_buffer) + { + ptr_next_buffer = ptr_buffer->next_buffer; + + /* + * add buffer if it is in layout (if not, it's stored in a temporary + * list and will be added later) + */ + if (ptr_buffer->layout_number > 0) + { + /* insert buffer now in the final list */ + gui_buffer_insert (ptr_buffer); + } + else + { + /* move the buffer in a temporary list */ + ptr_buffer->prev_buffer = last_extra_buffer; + ptr_buffer->next_buffer = NULL; + if (extra_buffers) + last_extra_buffer->next_buffer = ptr_buffer; + else + extra_buffers = ptr_buffer; + last_extra_buffer = ptr_buffer; + } + + ptr_buffer = ptr_next_buffer; + } + + /* add buffers that are NOT in layout */ + ptr_buffer = extra_buffers; while (ptr_buffer) { ptr_next_buffer = ptr_buffer->next_buffer; |