# HG changeset patch # User Mikael Berthe # Date 1300145957 -3600 # Node ID 39021fd6b0e15ba78f66b6f4e7df52a62fad6ca9 # Parent b596bcff758ea601abeca6fb308bdc5f26e08cac Try to improve readmarks in some cases This patch removes the readmark when entering chatmode if the mark is on the last line. This should hopefully fix weird behavior seen under some circumstances. diff -r b596bcff758e -r 39021fd6b0e1 mcabber/mcabber/hbuf.c --- a/mcabber/mcabber/hbuf.c Mon Mar 14 23:45:24 2011 +0100 +++ b/mcabber/mcabber/hbuf.c Tue Mar 15 00:39:17 2011 +0100 @@ -554,6 +554,19 @@ } } +// hbuf_remove_trailing_readmark(hbuf) +// Unset the buffer readmark if it is on the last line +void hbuf_remove_trailing_readmark(GList *hbuf) +{ + hbuf_block *blk; + + if (!hbuf) return; + + hbuf = g_list_last(hbuf); + blk = (hbuf_block*)(hbuf->data); + blk->prefix.flags &= ~HBB_PREFIX_READMARK; +} + // hbuf_get_blocks_number() // Returns the number of allocated hbuf_block's. guint hbuf_get_blocks_number(GList *hbuf) diff -r b596bcff758e -r 39021fd6b0e1 mcabber/mcabber/hbuf.h --- a/mcabber/mcabber/hbuf.h Mon Mar 14 23:45:24 2011 +0100 +++ b/mcabber/mcabber/hbuf.h Tue Mar 15 00:39:17 2011 +0100 @@ -52,6 +52,7 @@ GList *hbuf_jump_readmark(GList *hbuf); gboolean hbuf_remove_receipt(GList *hbuf, gpointer xep184); void hbuf_set_readmark(GList *hbuf, gboolean action); +void hbuf_remove_trailing_readmark(GList *hbuf); void hbuf_dump_to_file(GList *hbuf, const char *filename); diff -r b596bcff758e -r 39021fd6b0e1 mcabber/mcabber/screen.c --- a/mcabber/mcabber/screen.c Mon Mar 14 23:45:24 2011 +0100 +++ b/mcabber/mcabber/screen.c Tue Mar 15 00:39:17 2011 +0100 @@ -1482,7 +1482,7 @@ if (win_entry->bd->lock) setmsgflg = TRUE; else - // If this is an outgoing message, update readmark + // If this is an outgoing message, remove the readmark if (!special && (prefix_flags & (HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT_OUT))) hbuf_set_readmark(win_entry->bd->hbuf, FALSE); // Show and refresh the window @@ -2395,8 +2395,11 @@ } current_buddy = newbuddy; // Lock the buddy in the buddylist if we're in chat mode - if (chatmode) + if (chatmode) { buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); + // Remove the readmark if it is at the end of the buffer + scr_buffer_readmark(-1); + } // We should rebuild the buddylist but not everytime if (!(buddylist_get_filter() & 1<bd->lock) - hbuf_set_readmark(win_entry->bd->hbuf, action); + if (!win_entry->bd->lock) { + if (action >= 0) + hbuf_set_readmark(win_entry->bd->hbuf, action); + else + hbuf_remove_trailing_readmark(win_entry->bd->hbuf); + } } @@ -3037,8 +3049,11 @@ // Public function to (un)set chatmode... inline void scr_set_chatmode(int enable) { + gboolean enter_chatmode = enable && chatmode == FALSE; chatmode = enable; scr_update_chat_status(TRUE); + if (enter_chatmode) + scr_buffer_readmark(-1); } // scr_get_chatmode() diff -r b596bcff758e -r 39021fd6b0e1 mcabber/mcabber/screen.h --- a/mcabber/mcabber/screen.h Mon Mar 14 23:45:24 2011 +0100 +++ b/mcabber/mcabber/screen.h Tue Mar 15 00:39:17 2011 +0100 @@ -156,7 +156,7 @@ void scr_buffer_dump(const char *file); void scr_buffer_list(void); void scr_buffer_scroll_up_down(int updown, unsigned int nblines); -void scr_buffer_readmark(gboolean action); +void scr_buffer_readmark(gchar action); void scr_buffer_jump_readmark(void); bool scr_roster_color(const char *status, const char *wildcard,