about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--jabber.c7
-rw-r--r--windows.c63
2 files changed, 35 insertions, 35 deletions
diff --git a/jabber.c b/jabber.c
index 8cef3c52..cd291858 100644
--- a/jabber.c
+++ b/jabber.c
@@ -179,6 +179,7 @@ static int _jabber_message_handler(xmpp_conn_t * const conn,
     char *message = xmpp_stanza_get_text(body);
     char *from = xmpp_stanza_get_attribute(stanza, "from");
     win_show_incomming_msg(from, message);
+    win_page_off();
 
     return 1;
 }
@@ -197,6 +198,7 @@ static void _jabber_conn_handler(xmpp_conn_t * const conn,
         title_bar_connected();
 
         cons_show(line);
+        win_page_off();
         status_bar_print_message(jid);
         status_bar_refresh();
 
@@ -214,6 +216,7 @@ static void _jabber_conn_handler(xmpp_conn_t * const conn,
     }
     else {
         cons_bad_show("Login failed.");
+        win_page_off();
         log_msg(CONN, "disconnected");
         xmpp_stop(ctx);
         jabber_conn.conn_status = JABBER_DISCONNECTED;
@@ -251,6 +254,8 @@ static int _roster_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanz
             }
         
             item = xmpp_stanza_get_next(item);
+
+            win_page_off();
         }
     }
     
@@ -310,6 +315,8 @@ static int _jabber_presence_handler(xmpp_conn_t * const conn,
     else // offline
         win_contact_offline(short_from, show_str, status_str);
 
+    win_page_off();
+
     return 1;
 }
 
diff --git a/windows.c b/windows.c
index 114626f7..bbc85c8e 100644
--- a/windows.c
+++ b/windows.c
@@ -264,19 +264,17 @@ void win_handle_switch(int *ch)
 void win_page_off(void)
 {
     int rows, cols;
-        getmaxyx(stdscr, rows, cols);
-    if (_curr_prof_win == 0) {
-        _wins[0].paged = 0;
-        
-        int y, x;
-        getyx(_cons_win, y, x);
+    getmaxyx(stdscr, rows, cols);
+    _wins[_curr_prof_win].paged = 0;
+    
+    int y, x;
+    getyx(_wins[_curr_prof_win].win, y, x);
 
-        int size = rows - 3;
+    int size = rows - 3;
 
-        _wins[0].y_pos = y - (size - 1);
-        if (_wins[0].y_pos < 0)
-            _wins[0].y_pos = 0;
-    }
+    _wins[_curr_prof_win].y_pos = y - (size - 1);
+    if (_wins[_curr_prof_win].y_pos < 0)
+        _wins[_curr_prof_win].y_pos = 0;
 }
 
 void win_handle_page(int *ch)
@@ -285,25 +283,21 @@ void win_handle_page(int *ch)
         int rows, cols;
         getmaxyx(stdscr, rows, cols);
 
-        if (_curr_prof_win == 0) {
-            _wins[0].y_pos = _wins[0].y_pos - (rows - 4);
-            if (_wins[0].y_pos < 0)
-                _wins[0].y_pos = 0;
-        }
-           
-        _wins[0].paged = 1;
+        _wins[_curr_prof_win].y_pos = _wins[_curr_prof_win].y_pos - (rows - 4);
+        if (_wins[_curr_prof_win].y_pos < 0)
+            _wins[_curr_prof_win].y_pos = 0;
+       
+        _wins[_curr_prof_win].paged = 1;
     } else if (*ch == KEY_NPAGE) {
         int rows, cols, y, x;
         getmaxyx(stdscr, rows, cols);
-        getyx(_cons_win, y, x);
+        getyx(_wins[_curr_prof_win].win, y, x);
 
-        if (_curr_prof_win == 0) {
-            _wins[0].y_pos = _wins[0].y_pos + (rows - 4);
-            if (_wins[0].y_pos >= y)
-                _wins[0].y_pos = y - 1;
-        }
+        _wins[_curr_prof_win].y_pos = _wins[_curr_prof_win].y_pos + (rows - 4);
+        if (_wins[_curr_prof_win].y_pos >= y)
+            _wins[_curr_prof_win].y_pos = y - 1;
            
-        _wins[0].paged = 1;
+        _wins[_curr_prof_win].paged = 1;
     }
 }
 
@@ -334,7 +328,9 @@ static void _create_windows(void)
     for (i = 1; i < NUM_WINS; i++) {
         struct prof_win chat;
         strcpy(chat.from, "");
-        chat.win = newwin(rows-3, cols, 1, 0);
+        chat.win = newpad(PAD_SIZE, cols);
+        chat.y_pos = 0;
+        chat.paged = 0;
         wattrset(chat.win, A_BOLD);
         scrollok(chat.win, TRUE);
         _wins[i] = chat;
@@ -368,8 +364,10 @@ static int _new_prof_win(char *contact)
 }
 static void _win_switch_if_active(int i)
 {
+    win_page_off();
     if (strcmp(_wins[i].from, "") != 0) {
         _curr_prof_win = i;
+        win_page_off();
 
         if (i == 0)
             title_bar_title();
@@ -405,15 +403,10 @@ static void _current_window_refresh()
 {
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
-    
-    if (_curr_prof_win == 0) {
-        touchwin(_cons_win);
-        prefresh(_cons_win, _wins[0].y_pos, 0, 1, 0, rows-3, cols-1);
-    } else {
-        WINDOW *current = _wins[_curr_prof_win].win;
-        touchwin(current);
-        wrefresh(current);
-    }
+
+    WINDOW *current = _wins[_curr_prof_win].win;
+    touchwin(current);
+    prefresh(current, _wins[_curr_prof_win].y_pos, 0, 1, 0, rows-3, cols-1);
 }
 
 static void _show_status_string(WINDOW *win, char *from, char *show, char *status,