about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/commands.c22
-rw-r--r--src/ui/core.c16
-rw-r--r--src/ui/ui.h2
-rw-r--r--tests/ui/stub_ui.c9
4 files changed, 13 insertions, 36 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index ada5c114..150ee364 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1342,7 +1342,9 @@ cmd_msg(gchar **args, struct cmd_help_t help)
         if (!chatwin) {
             chatwin = ui_ev_new_chat_win(barejid);
         }
-        ui_ev_focus_win((ProfWin*)chatwin);
+        if (!wins_is_current((ProfWin*)chatwin)) {
+            ui_ev_focus_win((ProfWin*)chatwin);
+        }
 
         if (msg) {
             cl_ev_send_msg(chatwin, msg);
@@ -3191,7 +3193,7 @@ cmd_close(gchar **args, struct cmd_help_t help)
     int count = 0;
 
     if (args[0] == NULL) {
-        index = ui_current_win_index();
+        index = wins_get_current_num();
     } else if (strcmp(args[0], "all") == 0) {
         count = ui_close_all_wins();
         if (count == 0) {
@@ -3226,19 +3228,15 @@ cmd_close(gchar **args, struct cmd_help_t help)
         return TRUE;
     }
 
-    if (!ui_win_exists(index)) {
+    ProfWin *window = wins_get_by_num(index);
+    if (!window) {
         cons_show("Window is not open.");
         return TRUE;
     }
 
     // check for unsaved form
     if (ui_win_has_unsaved_form(index)) {
-        ProfWin *window = wins_get_current();
-        if (wins_is_current(window)) {
-            ui_current_print_line("You have unsaved changes, use /form submit or /form cancel");
-        } else {
-            cons_show("Cannot close form window with unsaved changes, use /form submit or /form cancel");
-        }
+        ui_current_print_line("You have unsaved changes, use /form submit or /form cancel");
         return TRUE;
     }
 
@@ -3259,7 +3257,7 @@ cmd_leave(gchar **args, struct cmd_help_t help)
 {
     jabber_conn_status_t conn_status = jabber_get_connection_status();
     win_type_t win_type = ui_current_win_type();
-    int index = ui_current_win_index();
+    int index = wins_get_current_num();
 
     if (win_type != WIN_MUC) {
         cons_show("You can only use the /leave command in a chat room.");
@@ -4239,7 +4237,9 @@ cmd_otr(gchar **args, struct cmd_help_t help)
             if (!chatwin) {
                 chatwin = ui_ev_new_chat_win(barejid);
             }
-            ui_ev_focus_win((ProfWin*)chatwin);
+            if (!wins_is_current((ProfWin*)chatwin)) {
+                ui_ev_focus_win((ProfWin*)chatwin);
+            }
 
             if (ui_current_win_is_otr()) {
                 ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
diff --git a/src/ui/core.c b/src/ui/core.c
index b985e52b..59144223 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -282,13 +282,6 @@ ui_load_colours(void)
 }
 
 gboolean
-ui_win_exists(int index)
-{
-    ProfWin *window = wins_get_by_num(index);
-    return (window != NULL);
-}
-
-gboolean
 ui_xmlconsole_exists(void)
 {
     ProfXMLWin *xmlwin = wins_get_xmlconsole();
@@ -882,7 +875,8 @@ ui_switch_win(ProfWin *win)
 gboolean
 ui_switch_win_num(const int i)
 {
-    if (ui_win_exists(i)) {
+    ProfWin *window = wins_get_by_num(i);
+    if (window) {
         ProfWin *old_current = wins_get_current();
         if (old_current->type == WIN_MUC_CONFIG) {
             ProfMucConfWin *confwin = (ProfMucConfWin*)old_current;
@@ -1257,12 +1251,6 @@ ui_current_win_is_otr(void)
     }
 }
 
-int
-ui_current_win_index(void)
-{
-    return wins_get_current_num();
-}
-
 win_type_t
 ui_win_type(int index)
 {
diff --git a/src/ui/ui.h b/src/ui/ui.h
index e98a105e..e42505bc 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -98,7 +98,6 @@ int ui_close_read_wins(void);
 // current window actions
 void ui_clear_current(void);
 win_type_t ui_current_win_type(void);
-int ui_current_win_index(void);
 gboolean ui_current_win_is_otr(void);
 
 ProfChatWin *ui_get_current_chat(void);
@@ -110,7 +109,6 @@ void ui_win_error_line(ProfWin *window, const char * const msg);
 
 win_type_t ui_win_type(int index);
 void ui_close_win(int index);
-gboolean ui_win_exists(int index);
 int ui_win_unread(int index);
 char * ui_ask_password(void);
 
diff --git a/tests/ui/stub_ui.c b/tests/ui/stub_ui.c
index faea7dd3..16933e5d 100644
--- a/tests/ui/stub_ui.c
+++ b/tests/ui/stub_ui.c
@@ -135,11 +135,6 @@ win_type_t ui_current_win_type(void)
     return (win_type_t)mock();
 }
 
-int ui_current_win_index(void)
-{
-    return 0;
-}
-
 gboolean ui_current_win_is_otr(void)
 {
     return (gboolean)mock();
@@ -180,10 +175,6 @@ win_type_t ui_win_type(int index)
 }
 
 void ui_close_win(int index) {}
-gboolean ui_win_exists(int index)
-{
-    return FALSE;
-}
 
 int ui_win_unread(int index)
 {
/014index_addressing.cc?h=hlt&id=836d13dbc92c97cf529d6a51972be350e8ee1b2c'>836d13db ^
c442a5ad ^
836d13db ^

222c31db ^
bb62d65e ^
c442a5ad ^
836d13db ^
bb62d65e ^
631de5d9 ^
836d13db ^
4a943d4e ^





83c67014 ^
4a943d4e ^



83c67014 ^
c82d149b ^
4a943d4e ^







0e87e934 ^
4a943d4e ^



83c67014 ^
4a943d4e ^



83c67014 ^
c82d149b ^
4a943d4e ^







d1df4aca ^


4a943d4e ^





83c67014 ^
4a943d4e ^



83c67014 ^
c82d149b ^
4a943d4e ^








d1df4aca ^







4a943d4e ^





83c67014 ^
4a943d4e ^



83c67014 ^
c82d149b ^
4a943d4e ^








d1df4aca ^




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155