summaryrefslogtreecommitdiff
path: root/testing/toxic/friendlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic/friendlist.c')
-rw-r--r--testing/toxic/friendlist.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c
index 2d060ae0..647f563d 100644
--- a/testing/toxic/friendlist.c
+++ b/testing/toxic/friendlist.c
@@ -13,9 +13,9 @@
13#include "windows.h" 13#include "windows.h"
14 14
15extern char WINDOW_STATUS[TOXWINDOWS_MAX_NUM]; 15extern char WINDOW_STATUS[TOXWINDOWS_MAX_NUM];
16extern int add_window(ToxWindow w); 16extern int add_window(ToxWindow w, int n);
17extern int focus_window(int num);
18extern ToxWindow new_chat(int friendnum); 17extern ToxWindow new_chat(int friendnum);
18extern int w_active;
19 19
20typedef struct { 20typedef struct {
21 uint8_t name[MAX_NAME_LENGTH]; 21 uint8_t name[MAX_NAME_LENGTH];
@@ -52,7 +52,17 @@ void friendlist_onMessage(ToxWindow* self, int num, uint8_t* str, uint16_t len)
52 return; 52 return;
53 53
54 if(friends[num].chatwin == -1) { 54 if(friends[num].chatwin == -1) {
55 friends[num].chatwin = add_window(new_chat(num)); 55 friends[num].chatwin = num;
56 int i;
57 /* Find first open slot to hold chat window */
58 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; i++) {
59 if (WINDOW_STATUS[i] == -1) {
60 WINDOW_STATUS[i] = num;
61 add_window(new_chat(num_selected), i);
62 w_active = i;
63 break;
64 }
65 }
56 } 66 }
57} 67}
58 68
@@ -104,17 +114,18 @@ static void friendlist_onKey(ToxWindow* self, int key) {
104 int i; 114 int i;
105 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; i++) { 115 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; i++) {
106 if (WINDOW_STATUS[i] == num_selected) { 116 if (WINDOW_STATUS[i] == num_selected) {
107 focus_window(i); 117 w_active = i;
108 break; 118 break;
109 } 119 }
110 } 120 }
111 }else { 121 }else {
112 friends[num_selected].chatwin = add_window(new_chat(num_selected));
113 focus_window(friends[num_selected].chatwin);
114 int i; 122 int i;
115 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; i++) { // Find open slot 123 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; i++) {
116 if (WINDOW_STATUS[i] == -1) { 124 if (WINDOW_STATUS[i] == -1) {
117 WINDOW_STATUS[i] = num_selected; 125 WINDOW_STATUS[i] = num_selected;
126 friends[num_selected].chatwin = num_selected;
127 add_window(new_chat(num_selected), i);
128 w_active = i;
118 break; 129 break;
119 } 130 }
120 } 131 }
@@ -178,4 +189,4 @@ ToxWindow new_friendlist() {
178 strcpy(ret.title, "[friends]"); 189 strcpy(ret.title, "[friends]");
179 190
180 return ret; 191 return ret;
181} \ No newline at end of file 192}