about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-10-27 20:40:42 +0000
committerJames Booth <boothj5@gmail.com>2015-10-27 20:40:42 +0000
commit8087053f496ae2bb8c68e56bdcf3dd1eaf8c2827 (patch)
tree069c9968e1af1452093b68b4964ae9e839bfcec5
parent795360f446ee11b9d8d4426a06f7f85c05ff383b (diff)
downloadprofani-tty-8087053f496ae2bb8c68e56bdcf3dd1eaf8c2827.tar.gz
Removed ui_ev_focus_win
-rw-r--r--src/command/commands.c14
-rw-r--r--src/event/ui_events.c8
-rw-r--r--src/event/ui_events.h1
-rw-r--r--src/ui/core.c18
-rw-r--r--src/ui/inputwin.c6
-rw-r--r--src/window_list.c6
6 files changed, 24 insertions, 29 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index fbbb0a8a..4a0cd782 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -913,7 +913,7 @@ cmd_win(ProfWin *window, const char *const command, gchar **args)
     if (!focuswin) {
         cons_show("Window %d does not exist.", num);
     } else {
-        ui_ev_focus_win(focuswin);
+        ui_switch_win(focuswin);
     }
 
     return TRUE;
@@ -1500,7 +1500,7 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args)
             if (!privwin) {
                 privwin = ui_ev_new_private_win(full_jid->str);
             }
-            ui_ev_focus_win((ProfWin*)privwin);
+            ui_switch_win((ProfWin*)privwin);
 
             if (msg) {
                 cl_ev_send_priv_msg(privwin, msg);
@@ -1525,7 +1525,7 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args)
         if (!chatwin) {
             chatwin = ui_ev_new_chat_win(barejid);
         }
-        ui_ev_focus_win((ProfWin*)chatwin);
+        ui_switch_win((ProfWin*)chatwin);
 
         if (msg) {
             cl_ev_send_msg(chatwin, msg);
@@ -2746,7 +2746,7 @@ cmd_form(ProfWin *window, const char *const command, gchar **args)
         if (!new_current) {
             new_current = wins_get_console();
         }
-        ui_ev_focus_win(new_current);
+        ui_switch_win(new_current);
         wins_close_by_num(num);
     }
 
@@ -3052,7 +3052,7 @@ cmd_room(ProfWin *window, const char *const command, gchar **args)
         ProfMucConfWin *confwin = wins_get_muc_conf(mucwin->roomjid);
 
         if (confwin) {
-            ui_ev_focus_win((ProfWin*)confwin);
+            ui_switch_win((ProfWin*)confwin);
         } else {
             iq_request_room_config_form(mucwin->roomjid);
         }
@@ -4668,7 +4668,7 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args)
             if (!chatwin) {
                 chatwin = ui_ev_new_chat_win(barejid);
             }
-            ui_ev_focus_win((ProfWin*)chatwin);
+            ui_switch_win((ProfWin*)chatwin);
         } else {
             chatwin = (ProfChatWin*)window;
             assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
@@ -4869,7 +4869,7 @@ cmd_otr(ProfWin *window, const char *const command, gchar **args)
             if (!chatwin) {
                 chatwin = ui_ev_new_chat_win(barejid);
             }
-            ui_ev_focus_win((ProfWin*)chatwin);
+            ui_switch_win((ProfWin*)chatwin);
 
             if (chatwin->pgp_send) {
                 ui_current_print_formatted_line('!', 0, "You must disable PGP encryption before starting an OTR session.");
diff --git a/src/event/ui_events.c b/src/event/ui_events.c
index a9e71bbd..cbdece4e 100644
--- a/src/event/ui_events.c
+++ b/src/event/ui_events.c
@@ -35,14 +35,6 @@
 #include "ui/ui.h"
 #include "window_list.h"
 
-void
-ui_ev_focus_win(ProfWin *win)
-{
-    if (!wins_is_current(win)) {
-        ui_switch_win(win);
-    }
-}
-
 ProfChatWin*
 ui_ev_new_chat_win(const char *const barejid)
 {
diff --git a/src/event/ui_events.h b/src/event/ui_events.h
index 279d1e2a..b42c6f01 100644
--- a/src/event/ui_events.h
+++ b/src/event/ui_events.h
@@ -35,7 +35,6 @@
 #ifndef UI_EVENTS_H
 #define UI_EVENTS_H
 
-void ui_ev_focus_win(ProfWin *win);
 ProfChatWin* ui_ev_new_chat_win(const char *const barejid);
 ProfPrivateWin* ui_ev_new_private_win(const char *const fulljid);
 
diff --git a/src/ui/core.c b/src/ui/core.c
index a804c53c..0b941b70 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -756,6 +756,10 @@ ui_switch_win(ProfWin *window)
 {
     assert(window != NULL);
 
+    if (wins_is_current(window)) {
+        return;
+    }
+
     ProfWin *old_current = wins_get_current();
     if (old_current->type == WIN_MUC_CONFIG) {
         ProfMucConfWin *confwin = (ProfMucConfWin*)old_current;
@@ -927,7 +931,7 @@ void
 ui_create_xmlconsole_win(void)
 {
     ProfWin *window = wins_new_xmlconsole();
-    ui_ev_focus_win(window);
+    ui_switch_win(window);
 }
 
 void
@@ -935,7 +939,7 @@ ui_open_xmlconsole_win(void)
 {
     ProfXMLWin *xmlwin = wins_get_xmlconsole();
     if (xmlwin) {
-        ui_ev_focus_win((ProfWin*)xmlwin);
+        ui_switch_win((ProfWin*)xmlwin);
     }
 }
 
@@ -969,7 +973,7 @@ ui_room_join(const char *const roomjid, gboolean focus)
 
 
     if (focus) {
-        ui_ev_focus_win(window);
+        ui_switch_win(window);
     } else {
         int num = wins_get_num(window);
         status_bar_active(num);
@@ -983,7 +987,7 @@ void
 ui_switch_to_room(const char *const roomjid)
 {
     ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
-    ui_ev_focus_win(window);
+    ui_switch_win(window);
 }
 
 void
@@ -2162,7 +2166,7 @@ ui_handle_room_configuration(const char *const roomjid, DataForm *form)
     ProfMucConfWin *confwin = (ProfMucConfWin*)window;
     assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
 
-    ui_ev_focus_win(window);
+    ui_switch_win(window);
     ui_show_form(confwin);
 
     win_print(window, '-', 0, NULL, 0, 0, "", "");
@@ -2214,11 +2218,11 @@ ui_handle_room_config_submit_result(const char *const roomjid)
         }
 
         if (muc_window) {
-            ui_ev_focus_win((ProfWin*)muc_window);
+            ui_switch_win((ProfWin*)muc_window);
             win_print(muc_window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room configuration successful");
         } else {
             ProfWin *console = wins_get_console();
-            ui_ev_focus_win(console);
+            ui_switch_win(console);
             cons_show("Room configuration successful: %s", roomjid);
         }
     } else {
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 78cbfab3..21f945f3 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -466,7 +466,7 @@ _go_to_win(int i)
 {
     ProfWin *window = wins_get_by_num(i);
     if (window) {
-        ui_ev_focus_win(window);
+        ui_switch_win(window);
     }
 }
 
@@ -545,7 +545,7 @@ _inp_rl_altleft_handler(int count, int key)
 {
     ProfWin *window = wins_get_previous();
     if (window) {
-        ui_ev_focus_win(window);
+        ui_switch_win(window);
     }
     return 0;
 }
@@ -555,7 +555,7 @@ _inp_rl_altright_handler(int count, int key)
 {
     ProfWin *window = wins_get_next();
     if (window) {
-        ui_ev_focus_win(window);
+        ui_switch_win(window);
     }
     return 0;
 }
diff --git a/src/window_list.c b/src/window_list.c
index c026e875..19c405b4 100644
--- a/src/window_list.c
+++ b/src/window_list.c
@@ -537,7 +537,7 @@ wins_swap(int source_win, int target_win)
             }
             if (wins_get_current_num() == source_win) {
                 wins_set_current_by_num(target_win);
-                ui_ev_focus_win(console);
+                ui_switch_win(console);
             }
             return TRUE;
 
@@ -558,7 +558,7 @@ wins_swap(int source_win, int target_win)
                 status_bar_active(source_win);
             }
             if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
-                ui_ev_focus_win(console);
+                ui_switch_win(console);
             }
             return TRUE;
         }
@@ -618,7 +618,7 @@ wins_tidy(void)
         windows = new_windows;
         current = 1;
         ProfWin *console = wins_get_console();
-        ui_ev_focus_win(console);
+        ui_switch_win(console);
         g_list_free(keys);
         return TRUE;
     } else {