diff mcabber/mcabber/screen.c @ 1996:7837d5a3f509

Going back to the first buddy with /roster next_unread when there is no more unread messages.
author Simon Jacquin
date Sun, 22 May 2011 23:30:37 +0200
parents 0870005f7efc
children 555e342556e7
line wrap: on
line diff
--- a/mcabber/mcabber/screen.c	Sat Apr 16 09:25:21 2011 +0200
+++ b/mcabber/mcabber/screen.c	Sun May 22 23:30:37 2011 +0200
@@ -2393,8 +2393,10 @@
 void scr_roster_top(void)
 {
   set_current_buddy(buddylist);
-  if (chatmode)
+  if (chatmode) {
+    last_activity_buddy = current_buddy;
     scr_show_buddy_window();
+  }
 }
 
 //  scr_roster_bottom()
@@ -2402,8 +2404,10 @@
 void scr_roster_bottom(void)
 {
   set_current_buddy(g_list_last(buddylist));
-  if (chatmode)
+  if (chatmode) {
+    last_activity_buddy = current_buddy;
     scr_show_buddy_window();
+  }
 }
 
 //  scr_roster_up_down(updown, n)
@@ -2420,8 +2424,10 @@
     for (i = 0; i < n; i++)
       set_current_buddy(g_list_next(current_buddy));
   }
-  if (chatmode)
+  if (chatmode) {
+    last_activity_buddy = current_buddy;
     scr_show_buddy_window();
+  }
 }
 
 //  scr_roster_prev_group()
@@ -2436,8 +2442,10 @@
       break;
     if (buddy_gettype(BUDDATA(bud)) & ROSTER_TYPE_GROUP) {
       set_current_buddy(bud);
-      if (chatmode)
+      if (chatmode) {
+        last_activity_buddy = current_buddy;
         scr_show_buddy_window();
+      }
       break;
     }
   }
@@ -2455,8 +2463,10 @@
       break;
     if (buddy_gettype(BUDDATA(bud)) & ROSTER_TYPE_GROUP) {
       set_current_buddy(bud);
-      if (chatmode)
+      if (chatmode) {
+        last_activity_buddy = current_buddy;
         scr_show_buddy_window();
+      }
       break;
     }
   }
@@ -2467,8 +2477,10 @@
 void scr_roster_search(char *str)
 {
   set_current_buddy(buddy_search(str));
-  if (chatmode)
+  if (chatmode) {
+    last_activity_buddy = current_buddy;
     scr_show_buddy_window();
+  }
 }
 
 //  scr_roster_jump_jid(bjid)
@@ -2489,8 +2501,10 @@
   buddylist_build();
   // Jump to the buddy
   set_current_buddy(buddy_search_jid(barejid));
-  if (chatmode)
+  if (chatmode) {
+    last_activity_buddy = current_buddy;
     scr_show_buddy_window();
+  }
 }
 
 //  scr_roster_unread_message(next)
@@ -2509,7 +2523,11 @@
   else      refbuddata = NULL;
 
   unread_ptr = unread_msg(refbuddata);
-  if (!unread_ptr) return;
+  if (!unread_ptr) {
+    if (!last_activity_buddy || g_list_position(buddylist, last_activity_buddy) == -1)
+      return;
+    unread_ptr = BUDDATA(last_activity_buddy);
+  }
 
   if (!(buddy_gettype(unread_ptr) & ROSTER_TYPE_SPECIAL)) {
     gpointer ngroup;
@@ -3487,6 +3505,7 @@
 int readline_accept_line(int down_history)
 {
   scr_check_auto_away(TRUE);
+  last_activity_buddy = current_buddy;
   if (process_line(inputLine))
     return 255;
   // Add line to history